-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Geometric lookups and "vector data cubes" #748
Comments
Dimensional data.jl already handles point lookups a bit, see |
|
For sure. Except for the nesting, and there should be optimisations for finding polygons on these grids? |
If you are interested in DGGS there is also https://github.com/danlooo/DGGS.jl |
Thanks Felix, that seems interesting! Are those actually DimArrays though, or just convenient wrapper structs? I went over the code briefly but am not able to see how this is working... |
I just wrote up a more interesting vector data cube example with polygons. See the following: using DimensionalData
using DimensionalData.Lookups
using DimensionalData.Dimensions
import DimensionalData as DD
# load data
using NaturalEarth
import GeoInterface as GI, GeometryOps as GO
fc = naturalearth("admin_0_countries", 10)
geometries_data = fc.geometry
id_data = fc.ADM0_A3
pop_data = fc.POP_EST .|> Float64
# now for the fun part
# let's define a dimension named Geometry
# TODO: how can we make this be interpreted as (X, Y)? can we somehow hook into the same things that MergeDims does?
@dim Geometry
# create a categorical lookup from the geometry
geometry_lookup = Categorical(geometries_data)
# create dimvectors which have geometry lookups - simple so far
id_dd = DimVector(id_data, Geometry(geometry_lookup))
pop_dd = DimVector(pop_data, Geometry(geometry_lookup))
# stack them so they share dims
fc_stack = DimStack((; id = id_dd, pop = pop_dd))
# Now for the _really_ fun part: mixing dimensions
# create a 2d dimarray, that hypothetically has height measurements over time for each geometry
height_dim_matrix = rand(Geometry(geometry_lookup), Ti(1:10))
# stack 'em!
full_stack = DimStack((; id = id_dd, pop = pop_dd, height = height_dim_matrix))
# select the USA
full_stack[Geometry(Where(x -> GO.contains(x, (-103, 44))))]
full_stack[Geometry(Where(x -> GO.contains(x, (-103, 44))))].id
full_stack[Geometry(Where(x -> GO.contains(x, (-103, 44))))].pop
full_stack[Geometry(Where(x -> GO.contains(x, (-103, 44))))].height
this is pretty sweet I think...now just have to figure out how to actually write this in a CF compliant way, and how to detect these lookups when plotting 😢 |
Just using I guess we can accelerate that for GO predicates with an Extent index, if we use a Fix2 |
yep! I'm building out a PolygonLookup now that would support that, but we could change that to be a more generic GeometricLookup at some point that works for any geometries |
btw the big issue here is probably going to be file I/O. Any suggestions on that? NetCDF has some support for this but I have no clue how we would get this out from a nc file: example.nc.txt |
Have you looked at the python/R vector data cubes ? If we can use something already being standardised... (The CF standard is likely pretty arcane) |
This is really exciting! And making this a
|
Yeah...Ideally we would want a sliced dimtable from the stack, with a given index column |
They also use CF :(( |
Ok guess we will have to implement it... |
It's super easy to create dimension axes that have vector lookups:
but some questions arise here.
color
as the values of the dimvector. What about 2d arrays?Contains
,Touches
,..
,At
, etc work, potentially using GeometryOps? Do we want an extension for this? I think this will involve geometric predicates at least.GI.geometrycolumns
of a raster to point to geometric lookups? Do we want to stash this in the metadata?The text was updated successfully, but these errors were encountered: