Please excuse my ignorance...I am new to Python OGR.
I am trying to create a simple square polygon and fail...this produces an empty polygon.
Where did I go wrong?
from osgeo import ogr
driver = ogr.GetDriverByName('ESRI Shapefile')
datasource = driver.CreateDataSource('c:/temp/testPolygon.shp')
layer = datasource.CreateLayer('layerName',geom_type=ogr.wkbPolygon)
#create ring and polygon object:
myRing = ogr.Geometry(type=ogr.wkbLinearRing)
myRing.AddPoint(0.0, 0.0)
myRing.AddPoint(0.0, 10.0)
myRing.AddPoint(10.0, 10.0)
myRing.AddPoint(0.0, 10.0)
myRing.AddPoint(0.0, 0.0)#close ring
myPoly = ogr.Geometry(type=ogr.wkbPolygon)
myPoly.AddGeometry
#this produces myPoly.GetArea() of zero!
#create feature polygon:
feature = ogr.Feature( layer.GetLayerDefn() )
feature.SetGeometry(myPoly)
layer.CreateFeature(feature)
Even the following returns an area of zero: from osgeo import ogr
#create polygon object:
myRing = ogr.Geometry(type=ogr.wkbLinearRing)
myRing.AddPoint(0.0, 0.0)#LowerLeft
myRing.AddPoint(0.0, 10.0)#UpperLeft
myRing.AddPoint(10.0, 10.0)#UpperRight
myRing.AddPoint(10.0, 0.0)#Lower Right
myRing.AddPoint(0.0, 0.0)#close ring
myPoly = ogr.Geometry(type=ogr.wkbPolygon)
myPoly.AddGeometry
print (myPoly.GetArea() ) #returns zero, not 100...
myRing _ .AddPoint
?