Geoscience Reference
In-Depth Information
Chapter 9
Raster Meets Vector Data
As introduced in Sect. 1.3 , geospatial data can be represented by raster grids and
vectors. Depending on the data content and operations to be performed on the
data, one representation is preferred over the other. However, due to subsequent
operations raster data can become more interesting when converted as vectors. For
instance, the output of pixel based target detection algorithm where only a minor-
ity of pixels has been detected as the class of interest could well be represented
as a vector dataset. Conversely, there are cases where you would like to convert
your vector data to rasters. Some typical image processing algorithms including
image filtering techniques are preferably performed on raster data. In this chapter,
we deal with utilities to convert your data from a vector to a raster representation
( gdal_rasterize ) and from raster to vector ( gdal_polygonize.py ). In
addition to gdal_polygonize.py and gdal_rasterize , this chapter dis-
cusses two related GDAL utilities, gdal_sieve.py and gdal_contour .
9.1 gdal_sieve.py
The Python script gdal_sieve.py filters small objects in a raster by replacing
them to the largest neighbor object. In this context, objects are defined as pixels of the
same value that are also connected. The connection can be defined in four directions
(N-S and W-E: 4 connectivity) or eight directions (N-S, W-E and diagonals NW-SE,
NE-SW: 8 connectivity). If the destination file is omitted, the source file is updated
in place. A sieving filter is typically used to remove isolated pixels before applying
a gdal_polygonize.py . Avoiding small polygons also makes the polygonize
step faster. An example on gdal_sieve.py is provided in Sect. 9.2 .
Usage: gdal_sieve.py [-q] [s-st threshold] [-4] [-8] [-o
name=value] srcfile [-nomask] [-mask filename] [-of
format] [dstfile]
 
 
Search WWH ::




Custom Search