GDAL reference: Difference between revisions

From Wildsong
Jump to navigationJump to search
Brian Wilson (talk | contribs)
mNo edit summary
Brian Wilson (talk | contribs)
Line 45: Line 45:
== Data management ==
== Data management ==


== Projections ===
=== Projections ===


To reproject data, use [http://gdal.org/gdalwarp.html gdalwarp]
To reproject data, use [http://gdal.org/gdalwarp.html gdalwarp]

Revision as of 21:07, 19 January 2011

Clip or Extract

Geometric

If you want to clip a rectangle out of a larger raster, for example to remove the collar from a scanned map, you can use gdal_translate but only if the input raster is not in a spherical projection. (For example, if it's in WGS84 (EPSG 4326) this will work.)

If the data is not projected you can use a gdal_translate command with either projwin or srcwin specifying a window on the command line.

If it is projected it will fail.

Using a mask

Distance

gdal_proximity

Generalization

gdal_sieve

Raster polygons smaller than a provided threshold size (in pixels) and replaces replaces them with the pixel value of the largest neighbour polygon. The result can be written back to the existing raster band, or copied into a new file.

Map algebra

Data conversion

Raster colorspaces conversion

rgb2pct.py

pct2rgb.py

Raster to Raster

Use gdal_translate

Raster to Polygon

gdal_polygonize

Vector to Raster

gdal_rasterize

Data management

Projections

To reproject data, use gdalwarp

Mosaic

The gdal_merge command creates a single raster output from several inputs. It does this the old-fashioned way by copying pixels.

Build raster catalog

(Or, "what is a VRT")

In GDAL world this is called a VRT = Virtual Dataset (which in my mind would abbreviate to "VD" but no one asked me.)

To build one you can use gdalbuildvrt

I think it creates a small file referencing the members of the dataset, which can then be processed by GDAL commands that accept only one input file.

Surfaces

Contour

To build a vector contour layer from an elevation dataset, use gdal_contour

Raster surfaces

To generate raster surfaces from an elevation dataset, use gdaldem

The list of surfaces you can generate includes

  • hillshade
  • color relief
  • shaded relief
  • slope
  • aspect
  • terrain ruggedness index
  • topographic position index
  • roughness