Matthew Perry
2007-09-13 05:32:35 UTC
Hi all,
Trying to load some linestring geometries into shapely arrays and I'm
getting incorrect results:
ds = ogr.Open("/home/perry/Desktop/line1/line1.shp")
lyr = ds.GetLayer(0)
feat = lyr.GetFeature(0)
geom = loads(feat.GetGeometryRef().ExportToWkb())
print type(geom)
print geom.wkt
line = asarray(geom)
print type(line)
print line[0]
Which gives me:
<class 'shapely.geometry.linestring.LineString'>
LINESTRING (-118.1344542359263414 36.1719818088280292,
-118.0363326316767854 36.3323268694309576, -118.2253962105966565
36.3514725483089194, -118.3043721359682365 36.6578034103562942,
-118.167959173962\
7710 36.8205416808189625, -118.0578715204144942 36.8755855075931009,
-118.0650511499937352 37.0024256301595926, -118.2253962105966565
37.1220861231468504, -118.5173678134855635 37.0861879752506738, -11\
8.5317270726440313 37.0742219259519459, -118.5412999120830051
36.9617410625439291, -118.6657468247897640 36.8109688413799816,
-118.8931017614655445 36.6841287188134899, -118.8931017614655445
36.4926719\
300338789, -118.9170338600630004 36.3131811905529958,
-118.7064313924054204 36.2174527961631867, -118.6992517628261936
36.1336904510721055, -118.7878005276367617 36.0236027975238287,
-119.0031894150138\
214 35.9518065017314754, -119.0031894150138214 35.9518065017314754,
-119.1156702784218453 35.9877046496276520)
<type 'numpy.ndarray'>
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/tmp/python-9523EYK.py", line 241, in <module>
print line[0]
IndexError: 0-d arrays can't be indexed
Any ideas why the linestring geometry is not properly converted to a
numpy array?
Trying to load some linestring geometries into shapely arrays and I'm
getting incorrect results:
ds = ogr.Open("/home/perry/Desktop/line1/line1.shp")
lyr = ds.GetLayer(0)
feat = lyr.GetFeature(0)
geom = loads(feat.GetGeometryRef().ExportToWkb())
print type(geom)
print geom.wkt
line = asarray(geom)
print type(line)
print line[0]
Which gives me:
<class 'shapely.geometry.linestring.LineString'>
LINESTRING (-118.1344542359263414 36.1719818088280292,
-118.0363326316767854 36.3323268694309576, -118.2253962105966565
36.3514725483089194, -118.3043721359682365 36.6578034103562942,
-118.167959173962\
7710 36.8205416808189625, -118.0578715204144942 36.8755855075931009,
-118.0650511499937352 37.0024256301595926, -118.2253962105966565
37.1220861231468504, -118.5173678134855635 37.0861879752506738, -11\
8.5317270726440313 37.0742219259519459, -118.5412999120830051
36.9617410625439291, -118.6657468247897640 36.8109688413799816,
-118.8931017614655445 36.6841287188134899, -118.8931017614655445
36.4926719\
300338789, -118.9170338600630004 36.3131811905529958,
-118.7064313924054204 36.2174527961631867, -118.6992517628261936
36.1336904510721055, -118.7878005276367617 36.0236027975238287,
-119.0031894150138\
214 35.9518065017314754, -119.0031894150138214 35.9518065017314754,
-119.1156702784218453 35.9877046496276520)
<type 'numpy.ndarray'>
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/tmp/python-9523EYK.py", line 241, in <module>
print line[0]
IndexError: 0-d arrays can't be indexed
Any ideas why the linestring geometry is not properly converted to a
numpy array?
--
Matthew T. Perry
http://www.perrygeo.net
"You never change things by fighting the existing reality.
To change something, build a new model that makes
the existing model obsolete" - R. Buckminster Fuller
Matthew T. Perry
http://www.perrygeo.net
"You never change things by fighting the existing reality.
To change something, build a new model that makes
the existing model obsolete" - R. Buckminster Fuller