
322
|
Chapter 6, Mapping on Your Desktop
#68 Convert Geospatial Data Between Different Formats
HACK
read and write a variety of formats; run it without any options to see which
ones your version supports.
Clipping and Warping Raster Data
gdal_translate has some other tricks up its sleeve. For example, if we want to
extract just the portion of the digital elevation model that covers the Pre-
sidio, a national park in the northwest corner of San Francisco, we can use
the “projection window” parameter of gdal_translate to clip out that bit and
save it to a separate file. (Note that, as usual, longitude comes before lati-
tude because it’s the x-coordinate.)
$ gdal_translate -projwin -122.4862 37.8116 -122.4462 37.7860 sf_dem.tif
presidio.tif
Input file size is 570, 416
Computed -srcwin 111 4 144 92 from projected window.
0...10...20...30...40...50...60...70...80...90...100 - done.
If you don’t specify an output format with -of, gdal_trans-
late assumes you want a GeoTIFF by default.
Another common problem you find when working with geodata is that
you’re using one coordinate system or projection in your GIS—say, Univer-
sal Transverse Mercator—while the data you have is in another projection
or coordinate system, such as latitude and longitude. Unfortunately, the sit-
uation is a bit like apples and oranges, so the new data needs to be con-
verted to your existing projection. This process is referred to