wri / UrbanLandUse

Characterizing urban land use with machine learning
29 stars 10 forks source link

GDAL/OGR: replacing command line usage with proper Python bindings #14

Open pkerins opened 5 years ago

pkerins commented 5 years ago

There are many places in the code where we use various GDAL functions (including OGR stuff) to accomplish various tasks. Currently, these are almost all executed on the command line, either via the Python subprocess library or by Jupyter notebook magic. These have the advantage of simplicity, but also some drawbacks in terms of stability. For example, ogrinfo will work via notebook magic only until the os module is imported, after which it fails--unless you start the notebook server from the geoml environment rather than the base environment.

For greater stability and maximum pythonicness, we can replace these references to Python scripts (eg gdal_merge.py) with actual Python bindings. For example, these bindings are already utilized in load_geotiff, write_1band_geotiff, and write_multiband_geotiff in util_rasters.py. I believe that the osgeo libraries expose all the relevant GDAL functionality; if that is not the case then we may need to modify or close this issue.

Taufiq06 commented 5 years ago

I have run into this issue while trying to run the notebook for preparing ground truth data. The GDAL function for rasterizing via command line was not working even when I was in the geoml environment. I want to give it a shot today for fixing this issue for at least places which prevent the core workflow to perform.