Scripting with OpenEV/GDAL

OpenEV and GDAL's python functions can also be used in standalone scripts. For example, the following script takes in a shapefile and picks out the shapes that have [field] = [value], where [field] is one of the shape's attributes, and [value] is one of the values that attribute can take on. It saves these to a file [inputfile]_[field]_[value].shp, where [inputfile] is the input shapefile name minus its extension.
import gview
import sys

if __name__ == '__main__':

    if len(sys.argv) < 4:
        print " "
        print "    Get relevant polygons from a vector layer."
        print ""
        print "Usage: shapefile field value"
        fshp = sys.argv[1]
        field = sys.argv[2]
        value = sys.argv[3]
        fshp2 = fshp[:-4] + '_' + field + '_' + value + '.shp'
        # Turn the shapefile into a GvShapes object

        # Create a new shapes object to store the 
        # selected shapes
        for shp_indx in range(len(sdata)):
            temp_shp = sdata[shp_indx]
            if temp_shp is None:
            if temp_shp.get_property(field) == value:

        new_shapes.save_to(fshp2)  # save the selected shapes to a file

Developer Course Outline
OpenEV Help