dshean / demcoreg

Utilities for DEM and point cloud co-registration
MIT License
110 stars 42 forks source link

get_rgi.sh - switch to OGR Merge and and set -e #21

Closed elischwat closed 4 years ago

elischwat commented 4 years ago

Adding a note about how the get_rgi.sh script will fail if the pygeotools library is not added to your path.

I also added set -e to the get_rgi.sh script which will cause the script to exit upon the first failure encountered. This generally makes error messages easier to understand.

When you run the get_rgi.sh script and the pygeotools lib is not on your path, you now see logs like this

Merging region shp for global shp
./demcoreg/get_rgi.sh: line 81: ogr_merge.sh: command not found

while previously a bunch more error messages printed afterwards, but only because of this initial failure.

dshean commented 4 years ago

Thanks @elischwat. Looks like GDAL/OGR now bundles a python script that can accomplish this, which eliminates the need for the pygeotools ogr_merge.sh: https://gdal.org/programs/ogrmerge.html

Can you modify get_rgi.sh to use this tool? Should simplify things moving forward. If you don't have time, I can take a crack at it later. Thanks!

elischwat commented 4 years ago

OK, I'll look into it. Do you know if installing GDAL in the manner recommended in the beginner_doc, IE conda create -c conda-forge -n demcoreg_env python=3.7 gdal=2.4 rasterio geopandas will automatically add ogrmerge.py to the path? If not, instructions might need to be updated.

I have it on my path already but I'm not sure how it happened as I've had GDAL installed for quite some time.

elischwat commented 4 years ago

ok @dshean I've switched to use the official OGR merge. I tested that it works as expected and visually checked that the files generated look the same as those generated by the pygeotools merge script.

dshean commented 4 years ago

Awesome. Looks great. Can you remove the other modification to the beginners doc about pygeotools in the PATH?

And to answer your earlier question, looks like ogrmerge.py was added to standard GDAL executables in v2.2. When GDAL is installed with conda, it will add ogrmerge.py and other GDAL utilities to the conda environment bin directory, which should be added to your PATH when you conda activate that environment.

dshean commented 4 years ago

Thanks again for your help on this one.