5

I want to calculate the distance between a point and the border of a country using python / shapely. It should work just fine point.distance(poly) e.g. demonstrated here Find Coordinate of Closest Point on Polygon Shapely but using geopandas I face the issue of: 'GeoSeries' object has no attribute '_geom'

What is wrong in my handling of the data? My border dataset is from http://www.gadm.org/

'GeoSeries' object has no attribute '_geom'

Community
  • 1
  • 1
Georg Heiler
  • 16,916
  • 36
  • 162
  • 292

1 Answers1

6

According to geopandas documentation, a GeoSeries is a vector of geometries (in your case, 0 (POLYGON... tells that you have just one object, but it is still a vector). There should be a way of getting the first geometry element. GeoSeries class implements the __getitem__ method, so austriaBorders.geometry[0] should give you the geometry you need. So, try with point.distance(austriaBorders.geometry[0]).

If you only need the distance to a point, the GeoSeries has the distance method implemented, but it will return a vector with the distance to each geometry it contains (according to documentation).

eguaio
  • 3,754
  • 1
  • 24
  • 38