The Geospatial Data Abstraction Library or GDAL, (http://www.gdal.org/) is the trusty, open source, Swiss army knife of geoprecessing software, providing behind the scenes muscle to many GIS programs, Grass GIS, QGIS and Geoserver included.

Wanting to merge 9 raster maps using gdal_merge.pyto model a watershed, I realized it was not natively available in Grass GIS. Having both a production server running Geoserver and content with my Grass GIS setup on my laptop - I was hesitant to install GDAL on either platform, it has a reputation for being difficult to install, and lacking the confidence to repair any dependency errors - I had two options.

I could have either pulled an oldlaptop out of storage and do a fresh Ubuntu install, orstart a Small (T1) Ubuntu instance through Amazon AWS (aws.amazon.com), install GDALand start and stop the instance it as needed. Taking the AWS route, it took less effort and time than expected. As an added bonus, the instance can beexpanded asneeded to process large datasets - try that with a clunker laptop running 2GB of memory.

Through the AWS Admin panel, I createda Small (T1) Ubuntu Trusty- 14.04 instance. Installing GDAL was painless, for my needs, it required both the GDAL installation plus Python, installed by using apt-get as follows:

sudo apt-get install libgdal-dev

sudo apt-get install python-gdal

Verify that gdal is installed and version by using:

gdal-config –version

After uploading and changing permissions of the files I needed to merge with gdal_merge.py, I ran the script, using thistimesaving tip, which will merge merge all files in the current directory with the .tif extension, as follows:

gdal_merge.py -o output.tif $(ls *.tif)

It took all of 30 seconds to merge all 9 files, and after processing the file was downloaded and worked correctly.

Additional Reading and Resources

Manual page forgdal_merge:http://www.gdal.org/gdal_merge.html

Manual page forgdal-config: http://www.gdal.org/gdal-config.html

http://www.sarasafavi.com/installing-gdalogr-on-ubuntu.html

https://gis.stackexchange.com/questions/116740/gdal-merge-py-on-ubuntu-many-tif-tiles-into-one/116770#116770

http://skipperkongen.dk/2012/02/21/pointers-for-gdal-and-python/

 

https://gis.stackexchange.com/questions/116740/gdal-merge-py-on-ubuntu-many-tif-tiles-into-one/116770#116770

Wetlands in the News

19 May 2024