@@ -0,0 +1,1464 @@
+def extract(in_file, out_file, filter_field, filter_values):%0A    '''%0A    Opens the input file, copies it into the oputput file, checking%0A    the filter.%0A    '''%0A    print %22Extracting data%22%0A%0A    in_ds = ogr.Open( in_file )%0A    if in_ds is None:%0A        print %22Open failed.%5Cn%22%0A        sys.exit( 1 )%0A    in_lyr = in_ds.GetLayerByName( splitext(basename(in_file))%5B0%5D )%0A    if in_lyr is None:%0A        print %22Error opening layer%22%0A        sys.exit( 1 )%0A%0A%0A    ##Creating the output file, with its projection%0A    if exists(out_file):%0A        remove(out_file)%0A    driver_name = %22ESRI Shapefile%22%0A    drv = ogr.GetDriverByName( driver_name )%0A    if drv is None:%0A        print %22%25s driver not available.%5Cn%22 %25 driver_name%0A        sys.exit( 1 )%0A    out_ds = drv.CreateDataSource( out_file )%0A    if out_ds is None:%0A        print %22Creation of output file failed.%5Cn%22%0A        sys.exit( 1 )%0A    proj = in_lyr.GetSpatialRef()%0A    ##Creating the layer with its fields%0A    out_lyr = out_ds.CreateLayer(%0A        splitext(basename(out_file))%5B0%5D, proj, ogr.wkbMultiPolygon )%0A    lyr_def = in_lyr.GetLayerDefn ()%0A    for i in range(lyr_def.GetFieldCount()):%0A        out_lyr.CreateField ( lyr_def.GetFieldDefn(i) )%0A%0A%0A    ##Writing all the features%0A    in_lyr.ResetReading()%0A%0A    for feat in in_lyr:%0A        value = feat.GetFieldAsString(feat.GetFieldIndex(filter_field))%0A        if filter_func(value, filter_values):%0A            out_lyr.CreateFeature(feat)%0A%0A    in_ds = None%0A    out_ds = None%0A

Create extract_gis_data.py