Using ogr2ogr and python, I'm running into a wall with trying to create a CSV with WKTs for a shapefile that contains multipart polygons. Currently this is this code I'm using (found it on internet):
#Purpose: To export a shapefile to WKT
from osgeo import ogr
import sys, os
input = ogr.Open(sys.argv[1])
layer_in = input.GetLayer()
layer_in.ResetReading()
feature_in = layer_in.GetNextFeature()
outfile = open(sys.argv[1] + ".wkt", "w")
while feature_in is not None:
geom = feature_in.GetGeometryRef()
geom_name = geom.GetGeometryName()
outfile.write(str(geom)+ '\n')
feature_in = layer_in.GetNextFeature()
So, do I need to use a different geometry container or do I need to evaluation each feature and if it's a multipart use a different set of geometry classes? I've looked around in the gdal/ogr documentation but I'm having a hard time reconciling it.
No comments:
Post a Comment