gdal tutorial notes

I took a quick trip through this gdal tutorial on raster data, albeit with SRTM data instead of the example data. Things I learned:

  • gdalinfo has useful flags for finding min/max values, stats, etc.
  • gdal_translate is how you render a dataset to an image
    gdal_translate -ot byte -scale 1152 3184  -of PNG  N39W120.hgt test.png
    Input range doesn’t seem to autoscale, despite what the docs say. Haven’t figured out how to apply a custom colormap yet. (The FAQ is discouraging, but gdaldem color-relief might do what I need.) The PNG output from GDAL doesn’t seem to have any geodata stored in PNG chunks.
  • gdalwarp is how you reproject data
  • gdal_merge is how you mosaic images. You can use gdalwarp to do it, too, but it’s overkill.
    gdalwarp N39W120.hgt N39W121.hgt N38W120.hgt N38W121.hgt big.tiff
    gdal_translate -outsize 50% 50% -scale 1000 3000 -of PNG big.tiff test.png
  • gdal_rasterize lets you render vector data (via OGR) into raster data
  • gdaladdo creates downsampled overviews for data, for faster access. In my previous experiments the overviews didn’t make mapserver any faster on my SRTM data.
  • gdal has virtual formats which are a text file that describes multiple raster files as a single dataset. mapserver uses something different to accomplish this, a shapefile.