Geoscience Reference
In-Depth Information
Usage: gdal_polygonize.py [-8] [-nomask] [-mask filename]
raster_file [-b band] [-q] [-f ogr_format] out_file
[layer] [fieldname]
-8
(from GDAL 1.10) Use 8 connectedness. Default is 4 connectedness.
-nomask
Do not use the default validity mask for the input band (such as no-data, or alpha
masks).
-mask filename
Use the first band of the specified file as a validity mask (zero is invalid, non-zero
is valid).
raster_file
The source raster file from which polygons are derived.
-b band
The band on raster_file to build the polygons from.
-f ogr_format
Select the output format of the file to be created. Default is GML.
out_file
The destination vector file to which the polygons will be written.
layer
The name of the layer created to hold the polygon features.
fieldname
The name of the field to create (defaults to “DN”).
-q
The script runs in quiet mode. The progress monitor is suppressed and routine
messages are not displayed.
The following snippet creates a vector file, fmap_ie.sqlite , based on the
forest pixels in a forest land cover raster map in Ireland, forest_ie.tif . Forest
pixels have a value 1, whereas no forest pixels have a value of 2. Pixels defined as no
forest must be masked for the polygonize algorithm so we first create a mask using
gdal_merge.py (see Sect. 9.2 ). The result is a raster forest mask with values 0
(no forest) and 1 (forest). This mask is then used for gdal_polygonize.py to
ignore no forest pixels.
gdal_merge.py -n 2 -init 0 -pct -o forest_ie.tif fmap_ie.tif
gdal_polygonize.py -mask forest_ie.tif fmap_ie.tif -f SQLite
fmap_ie.sqlite FTYP
 
Search WWH ::




Custom Search