Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create VRT layer from wkt #132

Open
ustroetz opened this issue Mar 5, 2014 · 0 comments
Open

Create VRT layer from wkt #132

ustroetz opened this issue Mar 5, 2014 · 0 comments

Comments

@ustroetz
Copy link
Contributor

ustroetz commented Mar 5, 2014

Do we have a recipe that explains how to create a VRT layer?

If not, I have some ideas, but couldn't get it to work. Maybe somebody can help, then I'll add it as a recipe.

from osgeo import ogr

poly = ogr.CreateGeometryFromWkt('POLYGON((-0.95245901639344266 0.51475409836065578,-0.13606557377049189 0.4459016393442623,-0.45737704918032795 0.04918032786885251,-0.45737704918032795 0.04918032786885251,-0.95245901639344266 0.51475409836065578))')

# Create the output shapefile
vrtDriver = ogr.GetDriverByName("VRT")
outDataSource = vrtDriver.CreateDataSource('test.vrt')
outLayer = outDataSource.CreateLayer('test', geom_type=ogr.wkbPolygon )

# Create the feature and set values
featureDefn = outLayer.GetLayerDefn()
outFeature = ogr.Feature(featureDefn)
outFeature.SetGeometry(poly)
outLayer.CreateFeature(outFeature)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant