|
GeoTiff
Introduction GEOTIFF is a metadata standard that allows spatial referencing of TIFF images. Geographic position, projection, datum, and scale are some of the many spatially related information that can be embedded. GIS software like ArcGIS is able to read, manipulate and produce GeoTIFF images. However, incomplete GeoTIFF information such as a missing reference system proves problematic in the display and manipulation of the image. This document outlines the utilization of a GDAL utility called gdalwarp in projecting a GeoTIFF image from an assumed geographic to other projection. The Problem Projecting a GeoTIFF image from an assumed geographic reference system to UTM using ArcGIS raster projection tool produces an output that appears to be unprojected. The source GeoTIFF image was an output of a mosaic process in ArcGIS involving a number of JPEG images. Each JPEG images has an associated world file. The GeoTIFF image however does not have an associated world file and it is assumed that the spatial informations were embedded in the image. What is GDALwarp? Geographic Data Abstraction Library (GDAL) is an open-source translator that supports a number of geographically referenced raster format with GeoTIFF being one of them. It comes with a number of commandline utilities and dynamic link library (DLL) that an application can utilize in manipulating and processing supported raster format. GDALwarp is one of the utilities intended for reprojecting and warping.
gdalwarp [-s_srs srs_def] [-t_srs srs_def] [-order n] [-et err_threshold] [-te xmin ymin xmax ymax] [-tr xres yres] [-ts width height] [-wo “NAME=VALUE”] [-ot Byte/Int16/…] [-wt Byte/Int16] [-srcnodata “value [value…]”] [-dstnodata “value [value…]”] [-rn] [-rb] [-rc] [-rcs] [-wm memory_in_mb] [-multi] [-q] [-of format] [-co “NAME=VALUE”]* srcfile dstfile The syntax above is used at the commandline. Definition of the options is presented in Appendix 1. For the purpose of this exercise the options –s_srs, -t_srs, -rb, srcfile and dstfile were used and is shown in the example below. gdalwarp.exe -s_srs "+proj=latlong +datum=WGS84" -t_srs "+proj=utm +zone=48 +datum=WGS84" -rb ge_20031018_last.tif ge_20031018_last_utm48.tif In the text above: [-s_srs "+proj=latlong +datum=WGS84"] tells gdalwarp that the source image have the following spatial reference system [-t_srs "+proj=utm +zone=48 +datum=WGS84"] tells gdalwarp to reproject the source image to a UTM - Zone 48 - WGS coordinate system. [-rb ] resamples the image using bilinear algorithm The second line (actually part of the first line, but word-wrap is on) shows the path to the source image [ge_20031018_last.tif] and where to write the target image [ge_20031018_last.tif]. You could substitute your own source image name and paths for these two entries. A batch file was created using the gdalwarp utility to assist user in reprojecting assumed geographic geotiff images. With this batch file, the user need only to key in the input image name and the output image name. It is assumed that the hardcoded parameters for gdalwarp are the same. If otherwise, the user can easily modify the batch file for the necessary adjustments. A snippet of the batch file is presented in Appendix 2. Appendix 1. The GDALWarp syntax and options definition gdalwarp simple image reprojection and warping utility Usage: gdalwarp [-s_srs srs_def] [-t_srs srs_def] [-order n] [-et err_threshold] [-te xmin ymin xmax ymax] [-tr xres yres] [-ts width height] [-wo "NAME=VALUE"] [-ot Byte/Int16/...] [-wt Byte/Int16] [-srcnodata "value [value...]"] [-dstnodata "value [value...]"] [-rn] [-rb] [-rc] [-rcs] [-wm memory_in_mb] [-multi] [-q] [-of format] [-co "NAME=VALUE"]* srcfile dstfile The gdalwarp utility is a simple image reprojection and warping utility. The program can reproject to any support projection, and can also apply GCPs stored with the image if the image is "raw" with control information. -s_srs srs def: source spatial reference set. The coordinate systems that can be passed are anything supported by the OGRSpatialReference.SetFromUserInput() call, which includes EPSG PCS and GCSes (ie. EPSG:4296), PROJ.4 declarations (as above), or the name of a .prf file containing well known text. -t_srs srs_def: target spatial reference set. The coordinate systems that can be passed are anything supported by the OGRSpatialReference.SetFromUserInput() call, which includes EPSG PCS and GCSes (ie. EPSG:4296), PROJ.4 declarations (as above), or the name of a .prf file containing well known text. -order n: order of polynomial used for warping (1 to 3). The default is to select a polynomial order based on the number of GCPs. -tps Enable use of thin plate spline transformer based on available GCPs. Use this instead of the -order switch. -et err_threshold: error threshold for transformation approximation (in pixel units - defaults to 0.125). -te xmin ymin xmax ymax: set georeferenced extents of output file to be created. -tr xres yres: set output file resolution (in target georeferenced units) -ts width height: set output file size in pixels and lines -wo "NAME=VALUE": Set a warp options. The GDALWarpOptions::papszWarpOptions docs show all options. Multiple -wo options may be listed. -ot type: For the output bands to be of the indicated data type. -wt type: Working pixel data type. The data type of pixels in the source image and destination image buffers. -rn: Use nearest neighbour resampling (default, fastest algorithm, worst interpolation quality). -rb: Use bilinear resampling. -rc: Use cubic resampling. -rcs: Use cubic spline resampling (slowest algorithm). -srcnodata value [value...]: Set nodata masking values for input bands (different values can be supplied for each band). If more than one value is supplied all values should be quoted to keep them together as a single operating system argument. Masked values will not be used in interpolation. -dstnodata value [value...]: Set nodata values for output bands (different values can be supplied for each band). If more than one value is supplied all values should be quoted to keep them together as a single operating system argument. New files will be initialized to this value and if possible the nodata value will be recorded in the output file. -wm memory_in_mb: Set the amount of memory (in megabytes) that the warp API is allowed to use for caching. -multi: Use multithreaded warping implementation. Multiple threads will be used to process chunks of image and perform input/output operation simultaneously. -q: Be quiet. -of format: Select the output format. The default is GeoTIFF (GTiff). Use the short format name. -co "NAME=VALUE": passes a creation option to the output format driver. Multiple -co options may be listed. See format specific documentation for legal creation options for each format. srcfile: The source file name. dstfile: The destination file name. Mosaicing into an existing output file is supported if the output file already exists. Appendix 2. Snippet of the GDALWAR.BAT @echo off :: checks for input and output
if "%1" == "?" Goto Syntax
if "%1" == "" GOTO Error
if "%2" == "" GOTO Error
:: get the current path
dPath=%cd%
:: run the gdalwarp utility
%dPath%\GDAL\gdalwarp.exe -s_srs "+proj=latlong +datum=WGS84" -t_srs "+proj=utm +zone=48 +datum=WGS84" -rb %1 %2
GOTO:EOF
:: if no input or output is provided display this
:Error
echo.
echo Error: either the input and/or the output file is not provided
echo.
echo example: gdalwarp a.tif b.tif
echo.
goto:EOF
:: More information
:Syntax
echo=======================================================================@
echo = TITLE: gdalwarp.bat
Echo =
Echo = DESCRIPTION: Runs a reprojection utility on Geotiff image
Echo = using GDAL utility known as 'gdalwarp'
Echo =
Echo = AUTHOR: Arnel B. Rala
Echo = DATE: 20061121
Echo =
Echo = Additional notes:
Echo =
Echo = GDALWarp is an image reprojection and warping utility.
echo = It is one of the utility programs distributed with GDAL.
echo =
echo = The following options were used -
echo =
echo = -s_srs source spatial reference set defined as
echo = +proj=latlong +datum=WGS84
echo = -t_srs target spatial reference set defined as
echo = +proj=utm +zone48 +datum=WGS84
echo = -rb bilinear resampling. default is nearest neighbor (-rn).
echo = Other sampling technique is cubic (-rc),and cubic spline (-rcs)
echo =
echo = The are other options and a complete listing is available at
echo = http://www.remotesensing.org/gdal/gdalwarp.html
echo ============================================================================
Last modified June 5, 2008 12:12 am
|