Dozen of times you come across a pile of tiles of raster. In most cases to use them you want to merge them. This article describes how to do that using open source GDAL combined with good old batching under windows. A nice source of ASCII raster file just (September 2015) made available are Digital Terrain models from the United Kingdom. These can be found via https://data.gov.uk/ or directly via http://environment.data.gov.uk/ds/survey
Prerequisites
- GDAL installed (can be as site package of python via or otherwise as part of the OSGEO4W suite of software)
- check if gdal_merge.py is available in the installation (if not download it from github)
Step-by-step guide
Follow these steps
- Download the appropriate zit of tiles
- Unpack them
- Open a command prompt in windows and navigate to the folder with ASCII's (note, not only ASCII's are supported by GDAL, check this page for all supported raster formats)
Using the dir command create a list of ASCII's
dir commanddir /b /s *.asc > listofascs.txt
Create a batch file in your favorite (plain) text editor with the following line of code
GDAL merge commandc:\python27\python.exe c:\python27\lib\site-packages\osgeo\gdal_merge.py -n -9999 -v -o output.tif --optfile listofascs.txt
Note! In this case Python in c:\Python27 is used including the gdal_merge.py (downloaded from github) under the osgeo site-package of Python27.
More information on the options of gdal_merge.py can be found on the utilities page of GDALIn the last step you
can add a coordinate reference system to you file
select a subset of you image
Adding an SRID and subsetting the rasterc:\python27\lib\site-packages\osgeo\gdal_translate -projwin ulx uly lrx lry -of GTiff -a_srs EPSG:code input.format output.format
where:
- -projwin is the window in coordinates (ul = Upper Left and lr = Lower Right) in the projection system specified under -a_srs
- -a_srs is if the SRID number (WGS84 has EPSG:4326) causes an error than download the correct version from spatialreference.org. You need the Human-Readable OGC WKT version of the list of projection formats. For the UK the data is in EPSG:27700
- -of is the output format
Make a nice visualisation in you favorite software. The picture below is created in QGIS2.10 using two cpt_city colorramps combined.