Closed Kirill888 closed 1 year ago
Note: you can use rioxarray to build the geobox: https://corteva.github.io/rioxarray/stable/getting_started/crs_management.html
Here is the function used by Geocube: https://github.com/corteva/geocube/blob/e32d1632c60b27b37c0fd4e5e1195877c48a14d2/geocube/geo_utils/geobox.py#L23
It is used as backup when the geobox is not found: https://github.com/corteva/geocube/blob/e32d1632c60b27b37c0fd4e5e1195877c48a14d2/geocube/geo_utils/geobox.py#L163
Side note: rioxarray
loads 2D coords and names them xc
and yc
.
Thanks for the links Alan. My plan is to capture GeoTransform
from spatial_ref
coordinate as something like original_source_transform
, and then use that for 2 things
1x1, 1xH, Wx1
sizes, as you suggested in #53Currently I'm NOT planning to interpret 2d coords for computing correct transform from cropped arrays, but it should be possible. My issue with 2d coords is that one can't tell if this was produced from a linear mapping of some sorts or from completely non-linear process, like from GCPs. In odc-geo
we use 1-d x/y coords, but store original pixel coordinates there instead: 0.5, 1.5, ...
, these take up less space and are fast to create, we then also capture original transform. Combination of the two allows to dynamically compute correct transform for cropped sources. The limitation of this approach is that you can't use xarray plot utilities with world coords, not until you add those manually anyway.
Side note: rioxarray loads 2D coords and names them xc and yc.
Yes, I'm aware of this now. When I was first debugging this issue I worked with this file:
and it was taking a long time to construct dask representation, so I stopped that and tried with parse_coordinates=False
which produces output much quicker, but that got me confused for a little bit. Question: those xc,yc
2d coords, are they always non-lazy arrays, even when constructing Dask outputs?
Question: those xc,yc 2d coords, are they always non-lazy arrays, even when constructing Dask outputs?
Currently, yes they are always non-lazy.
Geobox from xarrays produced by
rioxarray
from non-rectilinear sources can not be currently extracted.with the current code,
xx.odc.geobox
isNone
, it should not be. We should detect presence ofGeoTransform
attribute on thespatial_ref
coordinate and use that to construct a geobox instead of the normal way of computing rectilinear transform from x/y coordinates that might be absent (when usingparse_coordinates=False
option inrioxarray
).