Geography Reference
In-Depth Information
suppose you just received a CD containing 300 shapefiles that need
to be transformed to a coordinate system compatible with your other
data. Using the OGR utilities with a bit of simple shell, Ruby, or Python
script would make this a simple and quick task. Loading each layer into
a GUI and running a tool to transform the coordinates is fine for one
layer, but not for 300.
Raster Conversion
The reasons for doing a raster conversion are pretty much the same as
those for vector conversion, with the exception of loading into PostGIS.
Let's add a couple more reasons to the list:
• You want to change the compression type of an image.
• You want to set a no-data value in the image to allow displaying
certain areas as transparent.
• You want to rescale (reclass) the pixel values in an image.
In this section, we'll do a few raster conversions to illustrate some of
the possibilities available with gdal_translate and gdalwarp .
Extracting Part of a Raster
Let's start by pulling out a piece of the world mosaic raster using a
latitude/longitude rectangle. Since I happen to know the coordinates
that cover Alaska, we'll use it in our example:
$ gdal_translate -a_ullr -180 72 -129 50 -projwin -180 72 -129 50 \
world_mosaic.tif alaska_mosaic.tif
Input file size is 8192, 4096
Computed -srcwin 0 409 1161 501 from projected window.
0...10...20...30...40...50...60...70...80...90...100 - done.
Take a look at that command. The -projwin option specifies the area we
want to clip out of the image using the coordinate system. Note we could
use the -srcwin option to specify the clip area using pixel coordinates for
the upper-left corner and a size in the x and y directions, also in pixels.
We also used the -a_ullr option to force the output image to have the
bounding coordinates we want; otherwise, it would be offset by a half-
pixel in both the x and y directions (see Section C.2 , Using the Command
Line, on page 307 for more information on the cause of this offset).
To check to see whether this worked, we can open the new file in QGIS
or one of the other applications we have discussed. Since we just want
to see whether it worked, we could use any a graphic viewer on our
system that supports TIFF. In Figure 11.5 , on the next page, you can
 
 
 
Search WWH ::




Custom Search