[gdal-dev] Python BuildPolygonFromEdges fails near equator

Jerl Simpson jsimpson at wxtrends.com
Thu Jun 2 07:29:11 EDT 2011


Hi:

I'm having a weird issue that I'm hoping someone can shed some light
on for me.  I have a python script that reads through a CSV file and
builds a couple ESRI Shapefiles from it.  I'm generating 2 geometries,
POLYGON and LINESTRING.  LINESTRING works great but POLYGON fails when
points are "near" or on the equator.  My basic flow is like the
following for the POLYGON layer:

1) Read in Lat,Lon from CSV
2) Use ogr.ApproximateArcAngles() to turn the lat,lon point into a
circle. This works every time.
3) Use ogr.ForceToMultiLineString() to return a MULTILINESTRING.  Also
works everytime.
4) Use ogr.BuildPolygonFromEdges to build the polygon.  Only works
when "away" from equator. (Fails with ERROR 6: OGR Error: General
Error)
5) Use gdal_rasterize to burn resultant shape files into transparent GeoTiff

I have a CSV file that contains the lat,lon values for points along
every 10th line of latitude.  -90,-80...0,...80,90 and at every 90th
line of longitude -180,-90,0,90,180

After generating the shapefiles, I use gdal_rasterize to burn the
shapes into an image.  I end up with red filled circles with black
borders.  But near the equator I just have black circles with nothing
in them.
With radii 1-3 only the row at the equator is empty, but starting at
radius 4, the 10 and -10 rows are also empty.

Can someone tell me what I'm doing wrong?  I'll be happy to provide
the resultant image that shows what I'm talking about and snippets
from my code where needed.

Thank you,

Jerl


More information about the gdal-dev mailing list