odc-geo

Overview

This library combines geometry shape classes from shapely with CRS from pyproj to provide projection aware Geometry. It exposes all the functionality provided by shapely modules, but will refuse operations between geometries defined in different projections. Geometries can be brought into a common projection with to_crs() method.

Based on that foundation a number of data types and utilities useful for working with geospatial metadata are implemented. Of particular importance is GeoBox. It is an abstraction for a geo-registered bounded pixel plane where a linear mapping from pixel coordinates to the real world is defined.

from odc.geo.geobox import GeoBox
GeoBox.from_bbox(
   (-2_000_000, -5_000_000,
     2_250_000, -1_000_000),
   "epsg:3577", resolution=1000)

GeoBox

Dimensions
4,250x4,000
EPSG
3577
Resolution
1000m
Cell
500px
WKT
PROJCRS["GDA94 / Australian Albers",
    BASEGEOGCRS["GDA94",
        DATUM["Geocentric Datum of Australia 1994",
            ELLIPSOID["GRS 1980",6378137,298.257222101,
                LENGTHUNIT["metre",1]]],
        PRIMEM["Greenwich",0,
            ANGLEUNIT["degree",0.0174532925199433]],
        ID["EPSG",4283]],
    CONVERSION["Australian Albers",
        METHOD["Albers Equal Area",
            ID["EPSG",9822]],
        PARAMETER["Latitude of false origin",0,
            ANGLEUNIT["degree",0.0174532925199433],
            ID["EPSG",8821]],
        PARAMETER["Longitude of false origin",132,
            ANGLEUNIT["degree",0.0174532925199433],
            ID["EPSG",8822]],
        PARAMETER["Latitude of 1st standard parallel",-18,
            ANGLEUNIT["degree",0.0174532925199433],
            ID["EPSG",8823]],
        PARAMETER["Latitude of 2nd standard parallel",-36,
            ANGLEUNIT["degree",0.0174532925199433],
            ID["EPSG",8824]],
        PARAMETER["Easting at false origin",0,
            LENGTHUNIT["metre",1],
            ID["EPSG",8826]],
        PARAMETER["Northing at false origin",0,
            LENGTHUNIT["metre",1],
            ID["EPSG",8827]]],
    CS[Cartesian,2],
        AXIS["(E)",east,
            ORDER[1],
            LENGTHUNIT["metre",1]],
        AXIS["(N)",north,
            ORDER[2],
            LENGTHUNIT["metre",1]],
    USAGE[
        SCOPE["Statistical analysis."],
        AREA["Australia - Australian Capital Territory; New South Wales; Northern Territory; Queensland; South Australia; Tasmania; Western Australia; Victoria."],
        BBOX[-43.7,112.85,-9.86,153.69]],
    ID["EPSG",3577]]

To make working with geo-registered raster data easier an integration with xarray is provided. Importing odc.geo.xr enables .odc. accessor on every xarray.Dataset and xarray.DataArray that exposes geospatial information of the raster loaded with Open Datacube or rioxarray. Methods for attaching geospatial information to xarray objects in a robust way are also provided. Geospatial information attached in this way survives most operations you might do on the data: basic mathematical operations, type conversions, cropping, serialization to most formats like zarr, netcdf, GeoTIFF.

Installation

Using pip

pip install odc-geo

Using Conda

conda install -c conda-forge odc-geo