Skip to content
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

Replace datacube GeoBox with odc-geo GeoBox? #1544

Open
snowman2 opened this issue Feb 6, 2024 · 1 comment
Open

Replace datacube GeoBox with odc-geo GeoBox? #1544

snowman2 opened this issue Feb 6, 2024 · 1 comment

Comments

@snowman2
Copy link
Contributor

snowman2 commented Feb 6, 2024

Testing out 1.9.0rc1:

Related #1424

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
@SpacemanPaul
Copy link
Contributor

SpacemanPaul commented Feb 8, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants