[Community] shapely: unable to get numpy array from linestring geometry

Matthew Perry perrygeo at gmail.com
Thu Sep 13 20:23:43 EEST 2007


Sean,

 Thanks for helping me out with this. I've printed the info below and
attached my test shapefile....


On 9/13/07, Sean Gillies <sgillies at frii.com> wrote:
> Matthew Perry wrote:
> >
> > Any ideas why the linestring geometry is not properly converted to a
> > numpy array?
>
>  Can you give me more information? Print out
>
>    geom.geom_type

LineString

>    geom.coords


<shapely.geometry.base.CoordinateSequence object at 0x8afc14c>


>    line # should be a numpy array

LINESTRING (-118.1344542359263414 36.1719818088280292,
-118.0363326316767854 36.3323268694309576, -118.2253962105966565
36.3514725483089194, -118.3043721359682365 36.6578034103562942,
-118.1679591739627\
710 36.8205416808189625, -118.0578715204144942 36.8755855075931009,
-118.0650511499937352 37.0024256301595926, -118.2253962105966565
37.1220861231468504, -118.5173678134855635 37.0861879752506738, -118.\
5317270726440313 37.0742219259519459, -118.5412999120830051
36.9617410625439291, -118.6657468247897640 36.8109688413799816,
-118.8931017614655445 36.6841287188134899, -118.8931017614655445
36.4926719300\
338789, -118.9170338600630004 36.3131811905529958,
-118.7064313924054204 36.2174527961631867, -118.6992517628261936
36.1336904510721055, -118.7878005276367617 36.0236027975238287,
-119.0031894150138214 \
35.9518065017314754, -119.0031894150138214 35.9518065017314754,
-118.9749086902324393 36.1107213805937803)

>    geom.__array_interface__

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/tmp/python-738I1s.py", line 272, in <module>
    print geom.__array_interface__
  File "build/bdist.linux-i686/egg/shapely/geometry/linestring.py",
line 164, in __array_interface__
  File "build/bdist.linux-i686/egg/shapely/geometry/linestring.py",
line 144, in ctypes
TypeError: unsupported operand type(s) for *: 'int' and 'NoneType'


>
> before you print line[0]. Which of the alpha versions are you using?
>

I'm using svn, revision 874. I had the same issue with alpha2.

-- 
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: line1.zip
Type: application/zip
Size: 1923 bytes
Desc: not available
URL: <http://lists.gispython.org/pipermail/community/attachments/20070913/8c02cea9/attachment.zip>


More information about the Community mailing list