Replace gdal/osgeo dependencies with rasterio and geopandas - #38
Merged
Conversation
The osgeo Python bindings require platform-specific GDAL binaries that are difficult to install, particularly on Windows. Replace all gdal, ogr, and osr calls with rasterio/geopandas equivalents, which ship binary wheels and were already project dependencies. - validate_dem.py: open DEMs with rasterio (geotransform math preserved via transform.to_gdal()); write result geotiffs with rasterio; export vector errors via geopandas instead of an ogr/osr feature loop. - split_dem.py: replace the gdal_translate subprocess call with a rasterio windowed read/write using the same -srcwin semantics. - create_empty_tiff.py, plot_results_slope_centrality.py: trivial ports. - pyproj_funcs.py: delete (dead code, no callers). - pyproject.toml: drop the gdal dependency. - publish-to-pypi.yml: remove the pixi/libgdal-core workaround that existed only to supply GDAL binaries for the install test. Outputs verified identical against a GDAL baseline across all export formats (tif/gpkg/shp/xyz) and split tiles: pixel values, transforms, CRS, nodata, geometries, and attribute values all match.
The package install test ran on Python 3.14 (python-version: "3.x"), where fiona -- a transitive dependency via globato -- has no binary wheel and fails to build from source without GDAL headers. Pin to 3.13, the newest version with full wheel coverage for the dependency tree.
This was referenced Jul 17, 2026
Closed
Collaborator
Author
|
All CI hooks passed except Codacy, which is having persistent issues. We are dropping the Codacy dependency in Issue #28. |
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.
Closes #21.
The
osgeoPython bindings require platform-specific GDAL binaries that are difficult to install, particularly on Windows (see the pip install failure reported in #21). This replaces everygdal,ogr, andosrcall withrasterio/geopandasequivalents — both ship binary wheels and were already declared project dependencies.Changes
src/ivert/validate_dem.py— DEMs are opened withrasterio.open; existing geotransform math is preserved unchanged viads.transform.to_gdal(), which returns the same 6-tuple GDAL ordering.generate_result_geotiffnow writes through rasterio, and_export_errors_vectorbuilds ageopandas.GeoDataFrameand callsto_file()instead of the ogr/osr feature-by-feature loop.src/ivert/utils/split_dem.py— thegdal_translatesubprocess call (which required the GDAL CLI binaries — the same installability problem) is replaced by a rasterio windowed read/write with identical-srcwinsemantics and creation options. Also no longer reads the full raster just to get its shape.src/ivert/utils/create_empty_tiff.py,src/ivert/plot_results_slope_centrality.py— trivial one-spot ports.src/ivert/utils/pyproj_funcs.py— deleted; dead code with zero callers anywhere in the repo.pyproject.toml—gdalremoved from dependencies..github/workflows/publish-to-pypi.yml— the pixi/libgdal-corewrapper on the install-test step existed only to supply GDAL binaries; it and the setup-pixi step are removed.Verification
generate_result_geotiff, all four error-export formats (tif/gpkg/shp/xyz), andsplit_demwith the pre-port GDAL code, then re-ran identically after the port: all 63 comparisons match exactly (pixel values, transforms, CRS, nodata, dtypes, point geometries, and attribute values).ivert.cliimport cleanly withosgeoimport-blocked, simulating an environment without GDAL.grep -r osgeo src/returns nothing; all pre-commit hooks pass.Two known, intentional behavior differences: output GeoTIFFs no longer have band statistics pre-baked into their metadata (GIS software computes these on open), and integer attribute fields in vector exports are written from int32 arrays (identical values and field types).