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

  1. GDAL installed (can be as site package of python via or otherwise as part of the OSGEO4W suite of software)
  2. check if gdal_merge.py is available in the installation (if not download it from github)

Step-by-step guide

Follow these steps

  1. Download the appropriate zit of tiles
  2. Unpack them
  3. 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)
  4. Using the dir command create a list of ASCII's

    dir /b /s *.asc > listofascs.txt
  5. Create a batch file in your favorite (plain) text editor with the following line of code

    c:\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 GDAL

  6. In the last step you

    1. can add a coordinate reference system to you file

    2. select a subset of you image

      c:\python27\lib\site-packages\osgeo\gdal_translate -projwin ulx uly lrx lry -of GTiff -a_srs EPSG:code input.format output.format

      where:

      1. -projwin is the window in coordinates (ul = Upper Left and lr = Lower Right) in the projection system specified under -a_srs
      2. -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
      3. -of is the output format
  7. Make a nice visualisation in you favorite software. The picture below is created in QGIS2.10 using two cpt_city colorramps combined.

     

 

You may also want to use visual panels to communicate related information, tips or things users need to be aware of.

Related articles

Related articles appear here based on the labels you select. Click to edit the macro and add or change labels.