assigning color information to geo-tiff

christ.stark's Avatar

christ.stark

26 Sep, 2011 07:39 PM

Hi,
I would like to assign color information to a srtm-file-geotiff file as described in the knowledge base ("Terrain visualization with digital elevation models and GDAL"). I saved the color information to a text file (saved to a file called ramp.txt) but now don't know how to link this text file to the map and the geo-tiff it concerns... How do I do that? Within the style.mss ?

Best regardes
desputin

  1. Support Staff 2 Posted by AJ on 26 Sep, 2011 07:59 PM

    AJ's Avatar

    Oops, it looks like a very important step is missing from that section of the article (I will update it shortly). Assigning the colors is a step that happens before you bring the geotiff into TileMill. Use the gdaldem command:

    gdaldem color-relief input-dem.tif ramp.txt output-color-relief.tif
    

    Then you can add the file that gets created as a layer in TileMill

  2. 3 Posted by christ.stark on 27 Sep, 2011 07:33 AM

    christ.stark's Avatar

    Hi, thanks,

    I get an error: gdaldem: command not found. Even though I have installed gdal...

  3. Support Staff 4 Posted by AJ on 27 Sep, 2011 02:43 PM

    AJ's Avatar

    Are you using Mac OS X? If so try these commands to put the program in your path variable:

    echo 'export PATH=/Library/Frameworks/GDAL.framework/Programs:$PATH' >> ~/.bash_profile
    source ~/.bash_profile
    
  4. 5 Posted by christ.stark on 27 Sep, 2011 04:00 PM

    christ.stark's Avatar

    No, I am using Linux (Ubuntu, I took the VirtualBox-Image provided by Tilemill)

  5. Support Staff 6 Posted by AJ on 27 Sep, 2011 07:09 PM

    AJ's Avatar

    Ah, ok. It seems that the gdaldem command only comes with GDAL version 1.7.0 or higher, and the Ubuntu 10.10 and 11.04 versions of GDAL are both 1.6.3.

    Upgrading this library is somewhat complicated. You can get an installation package from the Ubuntu GIS PPA, however if you do that you will need to compile Mapnik from source as the pre-compiled packages rely on the old version.

    Another option is compiling a newer version of GDAL without replacing your current version. That way you can use /usr/local/bin/gdaldem to prepare your geotiffs. This option is probably simpler. Just a standard ./configure && make && sudo make install.

  6. 7 Posted by christ.stark on 28 Sep, 2011 04:40 PM

    christ.stark's Avatar

    Ok, thanks. I did this, installed the newest gdal version1.8.1 with configure, make, make install. I think worked.

    [...] make[1]: Leaving directory/home/ubuntu/Downloads/gdal-1.8.1/apps' for f in LICENSE.TXT data/. ; do /home/ubuntu/Downloads/gdal-1.8.1/install-sh -c -m 0644 $f /usr/local/share/gdal ; done`

    But the gdal command doesn't seem to work:

    ubuntu@ubuntu-VirtualBox:~/Downloads/gdal-1.8.1$ gdaldem color-relief brd-srtm-tm-mercator.tif ramp.txt brd-srtm-tm-mercator-farben.tif gdaldem: error while loading shared libraries: libgdal.so.1: cannot open shared object file: No such file or directory

    or

    ubuntu@ubuntu-VirtualBox:~/Downloads/gdal-1.8.1$ /usr/local/bin/gdaldem color-relief brd-srtm-tm-mercator.tif ramp.txt brd-srtm-tm-mercator-farben.tif /usr/local/bin/gdaldem: error while loading shared libraries: libgdal.so.1: cannot open shared object file: No such file or directory

    Do you know if SAGA Gis or QGIS can also assign colors to geotiffs? Maybe that would be easier.

  7. Support Staff 8 Posted by AJ on 28 Sep, 2011 05:28 PM

    AJ's Avatar

    Does running this command help at all? sudo ldconfig

    QGIS has a plugin that can color geotiffs, but I believe it relies on the same newer version of GDAL. I'm not familiar with SAGA GIS.

  8. 9 Posted by christ.stark on 28 Sep, 2011 05:43 PM

    christ.stark's Avatar

    I don't get any output but also no error:

    'root@ubuntu-VirtualBox:/home/ubuntu/Downloads/gdal-1.8.1# ldconfig root@ubuntu-VirtualBox:/home/ubuntu/Downloads/gdal-1.8.1# '

  9. 10 Posted by christ.stark on 28 Sep, 2011 05:44 PM

    christ.stark's Avatar

    root@ubuntu-VirtualBox:/home/ubuntu/Downloads/gdal-1.8.1# ldconfig
    root@ubuntu-VirtualBox:/home/ubuntu/Downloads/gdal-1.8.1#

  10. Support Staff 11 Posted by AJ on 28 Sep, 2011 05:45 PM

    AJ's Avatar

    No output is expected. Do you still get an error trying to run /usr/local/bin/gdaldem color-relief ...?

  11. 12 Posted by christ.stark on 28 Sep, 2011 05:56 PM

    christ.stark's Avatar

    Hi, strangely now it worked.

    root@ubuntu-VirtualBox:/home/ubuntu/Downloads/gdal-1.8.1# /usr/local/bin/gdaldem color-relief /home/ubuntu/Downloads/brd-srtm-tm-mercator.tif /home/ubuntu/Downloads/ramp.txt /home/ubuntu/Downloads/brd-srtm-tm-mercator-farben.tif
    0...10...20...30...40...50...60...70...80...90...100 - done.

    Thank you!

  12. Support Staff 13 Posted by AJ on 28 Sep, 2011 06:11 PM

    AJ's Avatar

    Glad it worked!

    ldconfig refreshes Linux's dynamically-linked library cache. (This usually happens automatically when you install a program, but I forgot this step is necessary when compiling a new program from source.)

  13. AJ closed this discussion on 28 Sep, 2011 06:11 PM.

  14. Dane re-opened this discussion on 03 Oct, 2011 11:02 PM

  15. Support Staff 14 Posted by Dane on 03 Oct, 2011 11:02 PM

    Dane's Avatar

    Also, color information can now be dynamically assigned with mapnik: http://trac.mapnik.org/wiki/RasterColorizer, though it is not quite yet exposed in carto: https://github.com/mapbox/carto/issues/5

  16. Will White closed this discussion on 24 Oct, 2011 03:47 PM.

Comments are currently closed for this discussion. You can start a new one.