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

Raster footprint generation #53

Open
drnextgis opened this issue Jun 21, 2023 · 4 comments
Open

Raster footprint generation #53

drnextgis opened this issue Jun 21, 2023 · 4 comments

Comments

@drnextgis
Copy link

rio-stac creates a geometry property using a raster extent. I found this article explaining how to generate convex hulls of valid raster data for use in STAC Item geometries to be very useful. I believe it would be beneficial to have this option incorporated into rio-stac.

@vincentsarago
Copy link
Member

thanks for sharing @drnextgis

I believe I've already implemented some of this in https://github.com/developmentseed/rio-stac/blob/main/rio_stac/stac.py#L53-L73 but I couldn't (or didn't want) to go further down the optimization because:

  • I didn't wanted to add shapely dependency
  • I didn't want to read the data (at least for the geometry part, we read the data for the statistics but we usually use overview)

@drnextgis
Copy link
Author

Fair enough. What would you recommend for a user who loves rio-stac and desires to have an accurate footprint as the geometry of an item? 😊

@vincentsarago
Copy link
Member

I guess you'll need to create some custom code

import rasterio
from rio_stac import create_stac_item

with rasterio.open("my.tif") as src:
    item = create_stac_item(
            src, 
            input_datetime=input_datetime,
            extensions=extensions,
            collection=collection,
            collection_url=collection_url,
            properties=property,
            id=id,
            asset_name=asset_name,
            asset_href=asset_href,
            asset_media_type=asset_mediatype,
            with_proj=with_proj,
            with_raster=with_raster,
            with_eo=with_eo,
            raster_max_size=max_raster_size,
            geom_densify_pts=densify_geom,
            geom_precision=geom_precision,
    )
    item.geometry = get_precise_geo(src)
    

@vincentsarago
Copy link
Member

The more I think about it the more I think that maybe we could add optional dependency (shapely) to allow this!

Like if the user request precise geometry we check first if shapely is available 🤷

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