[Gdal-dev] python-gdal: create polygon

Didrik Pinte dpinte at itae.be
Tue Aug 1 03:40:23 EDT 2006


Hi,

Is it possible to get some explanation on the right way to create a
Polygon from scratch using python-gdal ? 

Here is what i've tested (using python-gdal 1.3.1-6):

[1] ogr.CreateGeometryFromWkt : this seems to work fine

[2] I've tried to create a new geometry with type=ogr.wkbPolygon and
then AddPoint to the geometry. This result in a non functionnal geometry
with a geom.GetGeometryType() like -234950345 ....

g = ogr.Geometry(type=ogr.wkbPolygon)
for point in point_list:
    g.AddPoint(point.x, point.y)
g.CloseRings()

[3] I've tried to create a new geometry with type=ogr.wkbPolygon and
then AddGeometry using a LinearRing. I encounter the same problem has
the previous one.

[4] Finally, i've used the wkt option of the ogr.Geometry __init__
method to create the polygon. This works but I add to path ogr.py (see
http://bugzilla.remotesensing.org/show_bug.cgi?id=1255 ).

Do someone knows why method [2] and [3] aren't working ?

I can provide more details if it's not clear.

--
Didrik Pinte
Research Assistant - Université catholique de Louvain
Free-lance developper - IT solutions for the Agro-Environment
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Ceci est une partie de message
	=?ISO-8859-1?Q?num=E9riquement?= =?ISO-8859-1?Q?_sign=E9e?=
Url : http://lists.osgeo.org/pipermail/gdal-dev/attachments/20060801/9bb0f505/attachment.bin


More information about the Gdal-dev mailing list