datacube-core
datacube-core copied to clipboard
Replace datacube GeoBox with odc-geo GeoBox?
Testing out 1.9.0rc1:
Related #1424
https://github.com/opendatacube/datacube-core/blob/0c5475e54df968aac60864f4542630da20ce7767/datacube/utils/geometry/_base.py#L1009
I am seeing these errors:
):
/opt/venv/lib/python3.11/site-packages/odc/geo/geobox.py:1353: in tiles
yy, xx = self.range_from_bbox(poly.boundingbox)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Tiles: 1x1|76x72px => 76x72px
bbox = BoundingBox(left=147.91658862725055, bottom=-23.50004977137337, right=148.00004211714526, top=-23.416596281478665, crs=CRS('EPSG:4326'))
def range_from_bbox(self, bbox: BoundingBox) -> Tuple[range, range]:
"""
Intersect with a bounding box.
Compute rows and columns overlapping with a given :py:class:`~odc.geo.geom.BoundingBox`.
"""
if bbox.crs is not None:
> bbox = self._gbox.project(bbox.polygon).boundingbox
E AttributeError: 'GeoBox' object has no attribute 'project'
/opt/venv/lib/python3.11/site-packages/datacube/api/core.py:660: in create_storage
coords_default = OrderedDict(**coords, **xr_coords(geobox, spatial_ref))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
gbox = GeoBox(1066, 973, Affine(1.0, 0.0, -10402223.0,
0.0, -1.0, 5135565.0), PROJCRS["WGS 84 / Pseudo-Mercator",BASEG... mapping and visualisation."],AREA["World between 85.06°S and 85.06°N."],BBOX[-85.06,-180,85.06,180]],ID["EPSG",3857]])
crs_coord_name = 'spatial_ref'
def xr_coords(
gbox: SomeGeoBox, crs_coord_name: Optional[str] = _DEFAULT_CRS_COORD_NAME
) -> Dict[Hashable, xarray.DataArray]:
"""
Dictionary of Coordinates in xarray format.
:param crs_coord_name:
Use custom name for CRS coordinate, default is "spatial_ref". Set to ``None`` to not generate
CRS coordinate at all.
:returns:
Dictionary ``name:str -> xr.DataArray``. Where names are either ``y,x`` for projected or
``latitude, longitude`` for geographic.
"""
attrs = {}
crs = gbox.crs
if crs is not None:
attrs["crs"] = str(crs)
gcps = None
transform: Optional[Affine] = None
if isinstance(gbox, GCPGeoBox):
coords: Dict[Hashable, xarray.DataArray] = {
name: _mk_pixel_coord(name, sz, None)
for name, sz in zip(gbox.dimensions, gbox.shape)
}
gcps = gbox.gcps()
else:
transform = gbox.transform
> if gbox.axis_aligned:
E AttributeError: 'GeoBox' object has no attribute 'axis_aligned'
/opt/venv/lib/python3.11/site-packages/odc/geo/_xr_interop.py:387: AttributeError
There are some minor differences between odc-geo GeoBox and datacube.utils GeoBox, yes.
1.9 will use the odc-geo GeoBox internally, but still provide the old datacube.utils class with a deprecation warning.
(Also it's pre01, not rc1 - it's a pre-release for development coordination purposes, not a release candidate and is still being actively worked on)
Can you post code that triggers the errors above?