Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: [Award Winner] Managing SRTM information with GDAL

  1. #1
    Guild Novice vehrka's Avatar
    Join Date
    Mar 2009
    Location
    Valencia, Spain
    Posts
    19

    Tutorial [Award Winner] Managing SRTM information with GDAL

    The information from NASA's Shuttle Radar Topography Mission (SRTM) can be used as a basis for hillsades or elevations in fantasy maps. In this tutorial we're going to see how to manage this data using OSGeo Foundation GDAL library. We're going to use this library from the command line utilities included in FWTools.

    The idea is to convert the image Figure 1 into the image Figure 2. Well not exactly the image Figure 2, but at least how to obtain the base information:


    Figure 1

    Figure 2

    1.- Getting the data.

    You can get NASA's SRTM data from several sources:



    Each source has it's pros and cons. If you are using the NASA's FTP you must first know the coordinates of the zone you want to use and what you get are tiles, in the USGS webpage you can get some crops of the zone you want to use, it's better to use this source if you are using small zones or your zone is in between several tiles, with the Google Earth layer you can also get tiles, and in several formats as ARCASCII or GeoTiff.
    Last edited by vehrka; 01-20-2012 at 07:28 AM. Reason: replacing lost images
    --
    vehrka

  2. #2
    Guild Novice vehrka's Avatar
    Join Date
    Mar 2009
    Location
    Valencia, Spain
    Posts
    19

    Post

    I will use the Google Earth layer though it is easyer to use the USGS webpage. On image Figure 3 you can see the Google Earth layer tiles. If you make click on the icon in the center of the tile you'll get a dialog similar to the one on the image Figure 4, were you can find the download link. For example, I need four GeoTiff tiles to cover the all the territory of the Comunidad Valenciana, the place where I live.


    Figure 3

    Figure 4

    Once you have all the zip files that you need you can unzip them in a directory.

    2.- Working with FWTools.

    I'm going to supouse that you have already downloaded and installed FWTools (v2.2.8 in my case, though I think there's a new version right now), I'm not covering the installation stuff, only two Caveat emptor if you are using FWTools in Windows:

    • Remember to run setfw.bat, wich is in the installation directory, before start working.
    • Any of the Python scripts of FWTools that you may run, have to be ran with the Python installation that comes with FWTools, You have to use the entire path to the python.exe that comes with FWTools and the entire path to the script .py you want to run.


    I'm not going to write the entire paths in this tutorial, remember to write them, OK?.
    Last edited by vehrka; 01-20-2012 at 07:31 AM. Reason: replace lost images
    --
    vehrka

  3. #3
    Guild Novice vehrka's Avatar
    Join Date
    Mar 2009
    Location
    Valencia, Spain
    Posts
    19

    Post

    3.-Joinning the tiles.

    We're going to use gdal_merge for joinning the tiles, it's a console apllication (a command) for joinning raster datasets. I you type:

    Code:
    gdal_merge
    you will get a lot of information about this command, but I'm just getting to the meat of the matter:

    If we have four tiles files srtm_36_04.tif, srtm_36_05.tif, srtm_37_04.tif y srtm_37_05.tif; you can join them typping:

    Code:
    gdal_merge -o mosaico.tif srtm_36_04.tif srtm_36_05.tif srtm_37_04.tif srtm_37_05.tif
    After -o comes the name of the output file, after that comes the names of the files, space sepparated; though the desired output format is the same that the standard (GeoTiff) we're not using the -of option.

    4.- Cropping.

    For cropping we are going to use gdalwarp.

    Code:
    gdalwarp -te 626680 4191038 815725 4519394 mosaico.tif mosaico_rer.tif
    after the -te option you must add the area coordinates
    Last edited by vehrka; 05-08-2009 at 03:21 AM.
    --
    vehrka

  4. #4
    Guild Novice vehrka's Avatar
    Join Date
    Mar 2009
    Location
    Valencia, Spain
    Posts
    19

    Post

    5.- Scaling.

    If you use Photoshop this is the end of the mini-tutorial, you can get the final image and start working with it.

    But I use GIMP and we won't get 16bit image support until version 2.8 (if they don't change the milestone again) so I have to scale the images to 8 bits.

    We'll use gdal_translate command for rescaling, but we're also using gdalinfo for getting some info first. With gdalinfo we can get information about the maximum and minimum of the histogram, we will use this information for rescaling to 0~255 greyscale with gdal_translate. For getting the info we type

    Code:
    gdalinfo -hist mosaico_rer.tif
    we are looking for a line wich is similar to " 256 buckets from -32835.4 to 1757". -32835.4 is a way to say NULL or no data, and 1757 is the maximum.

    Code:
    gdal_translate -ot Byte -scale 0 1757 0 255 mosaico_rer.tif mosaico_rer8.tif
    With the -ot option you can set the output data type, we are using 8 bit (1 byte), and again the output format is GeoTiff, the standard one; so we're not using the -of option. With the -scale option you can define the match between the input (0~1757) and output (0~255) range.

    Now you can use the image in GIMP.
    --
    vehrka

  5. #5
    Community Leader Facebook Connected Ascension's Avatar
    Join Date
    Jun 2008
    Location
    St. Charles, Missouri, United States
    Posts
    8,392

    Post

    Good stuff. I was able to follow along and understand even though I have no knowledge of using real world data. I can see this as being very helpful and useful. Good job.
    If the radiance of a thousand suns was to burst at once into the sky, that would be like the splendor of the Mighty One...I am become Death, the Shatterer of worlds.
    -J. Robert Oppenheimer (father of the atom bomb) alluding to The Bhagavad Gita (Chapter 11, Verse 32)


    My Maps ~ My Brushes ~ My Tutorials ~ My Challenge Maps

  6. #6

  7. #7
    Community Leader Guild Sponsor Korash's Avatar
    Join Date
    Nov 2008
    Location
    Montreal, Canada
    Posts
    1,600

    Praise

    Yup, I have had visions of doing stuff like this....just never knew how though.

    Thanks vehrka, have some rep

    Got a question for you....are these progs free and where do you get them?

    I looked through Google Earth (basic, no add-ons) and couldn't come up with those tiles...What am I missing?
    Art Critic = Someone with the Eye of an Artist, Words of a Bard, and the Talent of a Rock.

    Please take my critiques as someone who Wishes he had the Talent

  8. #8

    Default

    Cool to see someone using some of the real world tools out there to make their own maps. I'm a remote sensing guy myself and use GDAL and GIS tools every day, but haven't delved yet into using some of the RS software I have to map creation.

  9. #9
    Guild Novice vehrka's Avatar
    Join Date
    Mar 2009
    Location
    Valencia, Spain
    Posts
    19

    Default

    @Korash: Those programs are not only free, but open source, you can download them as a pack with FWTools (you have the link in the first post, click on FWTools). For Google Earth you have to download the KMZ file (again click on the link in point 1)

    Thanks for the rep guys!
    --
    vehrka

  10. #10
    Community Leader Guild Sponsor Korash's Avatar
    Join Date
    Nov 2008
    Location
    Montreal, Canada
    Posts
    1,600

    Post



    Yup, figured that out and downloaded after I asked. I tried it out but am having trouble with the gdalinfo command = are you supposed to put the entire path to the file you are looking at? what is the "_rer" for? do we need to put it inthe file name?put the path before or after the "-hist"?

    I am stuck here.
    Art Critic = Someone with the Eye of an Artist, Words of a Bard, and the Talent of a Rock.

    Please take my critiques as someone who Wishes he had the Talent

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •