Geoscience Reference
In-Depth Information
Fig. 14.4 Vector feature buffers (from top point, line, polygon)
14.2.4 Buffering with OGR
In this section, we will write a Python script that will buffer vector features. Buffering
is a vector operation that creates a zone around existing vector objects that is defined
by a specified distance. Points, lines and polygons can all be buffered with the result
always being a polygon (Fig. 14.4 ). In some cases concentric buffers can be created
using varying buffer distances. In other instances where buffered polygons overlap,
one can either keep the features separate or merge them. The following script will
demonstrate how you can use Python OGR to create a script that reads in a vector
feature and buffers it.
As in Sect. 14.2.3 , we begin our program with the definition of the main function,
import the modules and use the argparse module to define in the command line
options. In this instance, we define three arguments: name of the input file, output
file and the buffer distance in map units.
def main():
import sys, os
try:
from osgeo import ogr
 
 
Search WWH ::




Custom Search