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

rioxarray clip - make sure to pass in the CRS of the geometries #11

Open
snowman2 opened this issue Nov 5, 2021 · 3 comments
Open

rioxarray clip - make sure to pass in the CRS of the geometries #11

snowman2 opened this issue Nov 5, 2021 · 3 comments

Comments

@snowman2
Copy link

snowman2 commented Nov 5, 2021

https://www.earthdatascience.org/courses/use-data-open-source-python/multispectral-remote-sensing/modis-data-in-python/

This is where I noticed it. I would recommend going through and making sure it is used in other clipping examples.

https://corteva.github.io/rioxarray/stable/rioxarray.html#rioxarray.raster_array.RasterArray.clip
https://corteva.github.io/rioxarray/stable/examples/clip_geom.html#Clip-using-a-GeoDataFrame

modis_clip_geometry = modis_bands_pre.rio.clip(
    fire_bound_sin.geometry,
    crs=fire_bound_sin.crs,  ## ADD CRS HERE
    all_touched=True,
    from_disk=True,
)

This ensures that the geometries are the same CRS as the raster when clipping.

@nkorinek
Copy link
Member

nkorinek commented Nov 9, 2021

Hey @snowman2 ! So in regards to this, we did that initially, but started avoiding implementing it in our lessons. We found the way that the clip function reprojects vector data added a slight tilt to the data, which in turn tilted the outcome, which wasn't what we were hoping for in our lessons. I made a gist visually representing the difference we were finding, and this happened across landsat, MODIS, and NAIP data. https://gist.github.com/nkorinek/94a69b125bbb97044c2c49a60cf94643 if there's a solution here please let us know!

@snowman2
Copy link
Author

snowman2 commented Nov 9, 2021

The reason I suggest to add the CRS is that it is a good practice to follow. Since this is a tutorial, I recommend adding it so users are used to doing it.

We found the way that the clip function reprojects vector data added a slight tilt to the data, which in turn tilted the outcome, which wasn't what we were hoping for in our lessons.

The tilt is due to the CRS of the raw raster data. MODIS shows this difference best since as it uses the sinusoidal projection. I think showing the tilt and then re-projecting the raster in the lesson will be valuable for users to see.

@snowman2
Copy link
Author

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