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

ENH: Allow geographic-projected custom stacks #170

Open
remi-braun opened this issue Jul 26, 2024 · 0 comments
Open

ENH: Allow geographic-projected custom stacks #170

remi-braun opened this issue Jul 26, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@remi-braun
Copy link
Member

remi-braun commented Jul 26, 2024

We could easily allow custom stacks with a geographic projection

Here is the code to create a VRT from the given input path:

# If we have an EPSG:4326 custom stack, reproject it
with rasterio.open(input_path) as ds:
    if ds.crs.is_geographic:
        utm_crs = gpd.GeoDataFrame(geometry=[geometry.from_bounds_to_polygon(*ds.bounds)], crs=ds.crs).estimate_utm_crs()
        with rasterio.vrt.WarpedVRT(ds, **{"crs": utm_crs.to_epsg()}) as vrt:
            utm_name = path.get_filename(input_path) + f"_{utm_crs.to_epsg()}.vrt"
            utm_path = str(output_folder / utm_name)
            rasterio.shutil.copy(vrt, utm_path, driver="vrt")
            input_path = utm_path
        
# Open the custom stack
prod = reader.open(
    input_path, 
    custom=True,
    sensor_type="OPTICAL",
    band_map=custom_band_map,
    pixel_size=pixel_size,
    remove_tmp=True
)
@remi-braun remi-braun added the enhancement New feature or request label Jul 26, 2024
@remi-braun remi-braun changed the title ENH: Allow geographin custom stacks ENH: Allow geographic custom stacks Jul 26, 2024
@remi-braun remi-braun changed the title ENH: Allow geographic custom stacks ENH: Allow geographic-projected custom stacks Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant