holoviz / spatialpandas

Pandas extension arrays for spatial/geometric operations
BSD 2-Clause "Simplified" License
308 stars 25 forks source link

Ring.to_shapely not working #16

Closed philippjfr closed 4 years ago

philippjfr commented 4 years ago

The to_shapely method on Ring geometries does not seem to work:

from spatialpandas.geometry import Ring

Ring([0, 0, 1, 1, 2, 0, 0, 0]).to_shapely()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-70-4983d69e78fb> in <module>
      1 from spatialpandas.geometry import Ring
      2 
----> 3 Ring([0, 0, 1, 1, 2, 0, 0, 0]).to_shapely()

~/development/spatialpandas/spatialpandas/geometry/ring.py in to_shapely(self)
     30         """
     31         import shapely.geometry as sg
---> 32         line_coords = self.data.to_numpy()
     33         return sg.LinearRing(line_coords.reshape(len(line_coords) // 2, 2))
     34 

AttributeError: 'pyarrow.lib.ListValue' object has no attribute 'to_numpy'

Versions:

jonmmease commented 4 years ago

Thanks, I'll take a look

ebo commented 4 years ago

I'm on a machine I cannot test this, BUT I do have an idea on what might be happening...

to_numpy was added recently as I recall. I found a reference to version pandas-0.24.0. Try updating pandas and see if it still is an issue.