Skip to content

use fiona-based antimeridian-safe crop and reprojection for land cover map#3

Open
Timothy-W-Hilton wants to merge 4 commits intotglauch:mainfrom
Timothy-W-Hilton:PR_antimeridian_safe_reproject
Open

use fiona-based antimeridian-safe crop and reprojection for land cover map#3
Timothy-W-Hilton wants to merge 4 commits intotglauch:mainfrom
Timothy-W-Hilton:PR_antimeridian_safe_reproject

Conversation

@Timothy-W-Hilton
Copy link

  • 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()

    • rasterio.coords.disjoint_bounds requires Cartesian coordinates. The Copernicus land cover map data are in longitude/latitude. Transforming the reflectance data to the land cover map CRS passed these non-Cartesian coordinates to rasterio.coords.disjoint_bounds. This failed for areas spanning the 180th meridian, and possibly others.

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.
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

Successfully merging this pull request may close these issues.

1 participant