use fiona-based antimeridian-safe crop and reprojection for land cover map#3
Open
Timothy-W-Hilton wants to merge 4 commits intotglauch:mainfrom
Open
Conversation
apply black formatter (https://black.readthedocs.io/en/stable/index.html) to Python source files. Ran black with default options in top-level pyVPRM directory (`black --verbose .`). versions used: black, 24.8.0 (compiled: no) Python (CPython) 3.12.5
replace "print(...)" with "loguru.logger.info(...)" provides time-stamps and source line attributions to progress updates. The time stamps are particularly useful for understanding which pieces are taking a long time on a long-running simulation. https://loguru.readthedocs.io/en/stable/index.html https://github.com/Delgan/loguru
- fixes a bug by passing cartesian coordinates to rasterio.coords.disjoint_bounds() - rasterio.coords.disjoint_bounds requires cartesian coords (https://rasterio.readthedocs.io/en/stable/api/rasterio.coords.html#module-rasterio.coords). The Copernicus land cover map data are in longitude/latitude. Transforming the land cover map data and the vegetation data to the land cover map CRS passed these non-cartesian coordinates to rasterio.coords.disjoint. This failed for areas spanning 180 E/W longitude, and possibly others.
- change the reprojection tool for cropping the land cover map from geopandas.GeoDataFrame.to_crs() to pyVPRM.lib.reproject_fiona.transform_geodataframe() - the reprojection is applied to the rectangle bounding the extent of the EVI/LSWI product. - transform_geodataframe() uses a reprojection that handles the antimeridian correctly when cropping the land cover map (LCM) to match the extent of the satetllite-derived EVI/LSWI product. pyVPRM.lib.reproject_fiona implements the reprojection based on tools in the fiona package as described in the geopandas documentation here: https://geopandas.org/en/stable/docs/user_guide/reproject_fiona.html#re-projecting-using-gdal-with-rasterio-and-fiona This fiona method is underpinned by GDAL (https://gdal.org). It correctly handles polygons (in this case, bounding rectangles) that cross the antimeridian (180 degrees longitude). geopandas.GeoDataFrame.to_crs() does not handle this situation correctly. All of the MODIS sinusoidal tiles (https://modis-land.gsfc.nasa.gov/MODLAND_grid.html) along the edges of the sinusoidal projection will fail to produce a correct LCM crop using the to_crs() method.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
accompanies/depends on implement antimerdian-safe CRS transformations and reprojections pyVPRM#18
change the reprojection tool for cropping the land cover map from geopandas.GeoDataFrame.to_crs() to pyVPRM.lib.reproject_fiona.transform_geodataframe()
the reprojection is applied to the rectangle bounding the extent of the EVI/LSWI product.
transform_geodataframe() uses a reprojection that handles the 180th meridian correctly when cropping the land cover map (LCM) to match the extent of the satetllite-derived EVI/LSWI product. pyVPRM.lib.reproject_fiona implements the reprojection based on tools in the fiona package as described in the geopandas documentation.
This fiona method is underpinned by GDAL. It correctly handles polygons (in this case, bounding rectangles) that cross the 180th meridian. geopandas.GeoDataFrame.to_crs() does not handle this situation correctly. All of the MODIS sinusoidal tiles along the edges of the sinusoidal projection will fail to produce a correct LCM crop using the to_crs() method.
fixes a bug by passing Cartesian coordinates to rasterio.coords.disjoint_bounds()