Geography Reference
In-Depth Information
The information for the raster confirms that it was assigned the same
coordinate system as the source image since we didn't specify other-
wise. You can also see the bounding coordinates of the image exactly
match those we specified with
-projwin
. You might also notice we didn't
specify an output format. This is because the default output format for
gdal_translate
is a GeoTIFF. If we wanted to convert the format at the
same time, we would have specified it with the
-of
switch.
GDAL supports more than sixty raster formats, some of which are read-
only. Those that are read-write we can be specified as an output format.
Let's take a simple example and convert the
alaska_mosaic.tif
to a PNG:
$
gdal_translate -of PNG
-co "WORLDFILE=YES" alaska_mosaic.tif \
alaska_mosaic.png
Input file size is 1161, 501
0...10...20...30...40...50...60...70...80...90...100 - done.
Notice we provided the
-co
option to create a world file in addition to
the PNG. This allows us to use the PNG in a GIS application and have
it display in the proper location. When using world files, you have to
make sure they stay with the raster file. This is one of the advantages
of a GeoTIFF, since it encodes the coordinate system information right
in the raster.
Changing the Coordinate System
Let's do another example and change the coordinate system of
alaska_
mosaic.tif
to Alaska Albers Equal Area, a projection commonly used for
Alaska data. The EPSG code for the projection is 2964; however, it spec-
ifies the units as feet rather than meters. All my other Alaska data is
in meters, so for this transformation, we'll go the hard way and specify
the projection parameters in
proj
format:
$
gdal_translate -b 1 -b 2 -b 3 alaska_mosaic.tif alaska_mosaic_noalpha.tif
$
gdalwarp -t_srs '+proj=aea +lat_1=55 +lat_2=65 +lat_0=50 +lon_0=-154 +x_0=0 \
+y_0=0 +ellps=clrk66 +datum=NAD27' alaska_mosaic_noalpha.tif \
alaska_mosaic_albers.tif
Creating output file that is 1296P x 944L.
Processing input file alaska_mosaic_noalpha.tif.
:0...10...20...30...40...50...60...70...80...90...100 - done.
warping process. Notice that we translated the image before the warp
using
gdal_translate
. This was to remove the alpha channel from the
original image. The alpha channel is used to determine transparency
for each pixel in the image. In the case of our mosaic, it was found by
Search WWH ::
Custom Search