Geoscience Reference
In-Depth Information
process at the cost of precision using the option -te . By default, gdalwarp
uses an approximation that can result in a maximum error of a quarter of a pixel
( -te 0.25 ).
In order to preserve the no-data values of the input images, you need to explicitly
instruct gdalwarp to do so using the option -dstnodata . The reason for this
is that multiple input images can have different no-data values. In the following
example, the first input image has a no-data value of 255. For the second input image
the no-data value has not been set, but wewant it to be 0.We can use gdal_edit.py
for that:
gdal_edit.py -a_nodata 0 input2.tif
We then use gdalwarp to mosaic the two input images, with the instruction to
set 0 as the output no-data value:
gdalwarp input1.tif input2.tif -dstnodata 0 mosaic_nodata0.tif
Creating mosaics can result in sharp edges near the input image borders which
can be an aesthetic problem. One option is to blend the images across a given cutline
using a vector file as shown in the following example. We use a range of 10pixels at
each side of the cutline.
gdalwarp -cutline theCutline.shp -cl theCutline -cblend 10
inputWest.tif inputEast.tif output.tif
8.3.4 Clip Images
Clipping images from a raster area according to some cutline that is defined in
vector file is another interesting feature of the gdalwarp utility. You can mask
the output file in the area outside the region of interest using the extra option
-crop-to-cutline . Notice that, unlike a vector format, the output raster image
always remains rectangular. The result after clipping is just that the pixel values
outside the selected region are set to a fixed ( -dstnodata ) value. A schematic
overview is shown in Fig. 8.6 .
Fig. 8.6 Clip image using
gdalwarp .The dark area
outside the region of interest
is masked as no-data
 
 
Search WWH ::




Custom Search