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

write_cog runs indefinitely #180

Open
jankovicgd opened this issue Dec 11, 2024 · 0 comments
Open

write_cog runs indefinitely #180

jankovicgd opened this issue Dec 11, 2024 · 0 comments

Comments

@jankovicgd
Copy link

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.

import pystac_client
from odc.stac import stac_load, configure_rio
from pandas import to_datetime
import os
import geopandas as gpd
from dask.distributed import Client
configure_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 day
itemcol = 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
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

1 participant