0

I am working with a large GridWorkFlow object; I am not able to load all the tiles due to in-memory compute resources (24.00 GB mem 8 CPU) and do not need to either. I am interested in intersecting the grid with a spatial boundary I have (GeoPandas GeoDataFrame object) and finding the indices of the tiles which intersect the shapes. Any advice on the best approach? I have a POC for converting the grid to GeoPandas object, but would like to know if it is possible without having to convert, and how I might do that?

from datacube import Datacube
from datacube.api import GridWorkflow
from datacube.model import GridSpec
from datacube.utils import geometry

size = (1024*30)
tiles_per_cluster=1
gs = GridSpec(crs=geometry.CRS(102003), tile_size=(size, size), resolution=(15,15))

dc = Datacube(app="my_app")
gw = GridWorkflow(dc.index, grid_spec=gs)

gw.list_tiles(product="landsat7") # breaks memory limits

If I index a particular tile, I am able to intersect it with tile_obj.geobox.extent.intersects(geom_obj) but I need to be able to do this with all tiles without breaking memory limits.

***EDIT:

small_geom = geometry.Geometry(my_polygon, crs=102003)
gw.list_cells(product='landsat7', geopolygon=small_geom)

was the final solution I needed. I did not know the kwarg here was "geopolygon" and that it would do the intersect I hoped for.

1 Answer 1

0

Your arguments to GridSpec are all wrong. Both tile_size and resolution are measured in CRS units and the units for EPSG:4326 are degrees.

So you are asking for tiles that are over 30,000 degrees wide (with pixels 15 degrees by 15 degrees).

Not the answer you're looking for? Browse other questions tagged or ask your own question.