You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey guys, tryting to use odc.stac to write a cog from a combination of stac items on earth search, but the function seems to hang after the tiff is written. This happens when working with the default resolution, however if I bring it down a bit it seems fine.
importpystac_clientfromodc.stacimportstac_load, configure_riofrompandasimportto_datetimeimportosimportgeopandasasgpdfromdask.distributedimportClientconfigure_rio(cloud_defaults=True)
client=Client("localhost:8786")
shapefile="/path/to/.shp"shp=gpd.read_file(shapefile)
client=pystac_client.Client.open("https://earth-search.aws.element84.com/v1")
bands= ["red", "green", "blue"]
output_dir="path/to/out"items=client.search(
intersects=shp['geometry'][0],
datetime="2024-05-01T00:00:00Z/2024-05-01T23:59:59Z",
collections=["sentinel-2-l2a"]
) # for my shp this loaded about 7 items for this dayitemcol=items.item_collection()
ds=stac_load(itemcol, bands=bands, geopolygon=shp, chunks={'x': 2048, 'y': 2048}, groupby="solar_day")
band_name="green"band=ds.isel(time=0)[band_name]
dt=to_datetime(band['time'].values).to_pydatetime().strftime("%Y%m%d") # anyway to do this better?raster_file=f"S2L2A_{dt}_{band_name}.tiff"temp_raster_path=os.path.join(output_dir, raster_file)
band.compute().odc.write_cog( # also tried without compute()temp_raster_path,
overwrite=True,
) # the resulting cog is written after 3 mins and is about 450mb but the cell in the notebook keeps running, tried also with a script and it doesn't exit.
some more info
odc-stac==0.3.10
Python 3.10.4
The text was updated successfully, but these errors were encountered:
Hey guys, tryting to use odc.stac to write a cog from a combination of stac items on earth search, but the function seems to hang after the tiff is written. This happens when working with the default resolution, however if I bring it down a bit it seems fine.
some more info
The text was updated successfully, but these errors were encountered: