[postgis-users] GSHHS and "geometry contains non-closed rings
Guglielmo Celata
guglielmo.celata at gmail.com
Mon Oct 21 04:11:04 PDT 2013
Hi,
I am trying to insert some data from GSHHS (http://www.ngdc.noaa.gov/mgg/shorelines/data/gshhg/latest/),
into Posgis2 (Postgresql 9.1).
I receive the "geometry contains non-closed rings" error on one of the imports.
But right after that, Postgres is not able to insert anything in the DB.
I'm wondering if the data are wrong (they contain some un-closed geometries), or if the whole import
is somehow wrogn or outdated.
Python source is taken from "Python Geospatial Development, 2nd. Edition", ch. 7.
This is the python source:
for level in [1, 2, 3, 4]:
srcFile = os.path.join("data", "gshhg-shp-2.2.2", "GSHHS_shp", "f",
"GSHHS_f_L" + str(level) + ".shp")
shapefile = osgeo.ogr.Open(srcFile)
layer = shapefile.GetLayer(0)
print "start level {0}".format(level)
for i in range(layer.GetFeatureCount()):
feature = layer.GetFeature(i)
wkt = feature.GetGeometryRef().ExportToWkt()
print "."
try:
cursor.execute("INSERT INTO shorelines " +
"(level,outline) VALUES " +
"(%s, ST_GeometryFromText(%s, 4326))",
(level, wkt))
except psycopg2.InternalError as e:
print u"wkt: {0}".format(wkt)
print e
exit()
print ""
print "end level {0}".format(level)
and the exception I trap:
...
.968778,-179.804972 70.969583,-179.807611 70.969556,-179.810111 70.970389,-179.815056 70.970417,-179.817583 70.971222,-179.8225 70.971278,-179.825083 70.972083,-179.827639 70.972056,-179.830083 70.972917,-179.835139 70.972889,-179.8375 70.973722,-179.840139 70.973722,-179.842556 70.974556,-179.847583 70.974583,-179.850167 70.975417,-179.855028 70.975389,-179.857611 70.976194,-179.860083 70.976278,-179.862667 70.977083,-179.865056 70.977056,-179.8675 70.977917,-179.870111 70.977889,-179.872639 70.978694,-179.877556 70.97875,-179.880139 70.979556,-179.885 70.979528,-179.887611 70.980417,-179.917639 70.980389,-179.920111 70.979556,-179.930111 70.979583,-179.932611 70.97875,-179.940083 70.978722,-179.942583 70.977889,-179.952583 70.977917,-179.955083 70.977083,-179.960167 70.977111,-179.962639 70.976278,-179.967556 70.97625,-179.970028 70.975417,-179.975056 70.975389,-179.977611 70.974611,-179.982639 70.974583,-179.985111 70.97375,-179.9925 70.973722,-179.995139 70.972889,-180.0 70.972944))
geometry contains non-closed rings
HINT: "...9.995139 70.972889,-180.0 70.972944))" <-- parse error at position 54107 within geometry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20131021/d497ee3c/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 495 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20131021/d497ee3c/attachment.pgp>
More information about the postgis-users
mailing list