Skip to main content
Tweeted twitter.com/StackGIS/status/1538854181460922368
added 26 characters in body; edited tags; edited title
Source Link
Taras
  • 34k
  • 4
  • 73
  • 148

Cannot access "AttributeError: 'GeoSeries' object has no attribute 'coords'" when accessing coords property of LineString in GeoDataFrameusing GeoPandas

How can I access the coords.coords property of a LineString in GeoDataFrames? 

I can access other properties, such as area, length, etc, as documented in the  ShapelyShapely's documentation. See reproducible example below:

# create example GeoDataFrame with LineString`
line_new = LineString([(0.3, 0.6), (1.5, 1.6), (0.9,2.5)])
df = gpd.GeoDataFrame()
df.loc[0, 'geometry'] = line_new
# create example GeoDataFrame with LineString`
line_new = LineString([(0.3, 0.6), (1.5, 1.6), (0.9,2.5)])
df = gpd.GeoDataFrame()
df.loc[0, 'geometry'] = line_new

This works:df.geometry.length

0    2.643715
dtype: float64

But this does not: df.geometry.coords. It returns the following error:

    return object.__getattribute__(self, name)

AttributeError: 'GeoSeries' object has no attribute 'coords
    return object.__getattribute__(self, name)

AttributeError: 'GeoSeries' object has no attribute 'coords'

My understanding from the geopandas documentationGeoPandas Documentation was that the 'geometry' GeoSeries in a GeoDataFrame was a Shapely object, and thus the respective properties/methods would be available:

The GeoSeries class implements nearly all of the attributes and methods of Shapely objects.

Is the coords attribute simply one of the few that are not implemented?

Is this the same as what is being asked in hereExtracting points from LineString or Polygon and making dictionary out of them in GeoPandas?

Cannot access coords property of LineString in GeoDataFrame

How can I access the coords property of a LineString in GeoDataFrames? I can access other properties, such as area, length, etc, as documented in the  Shapely documentation. See reproducible example below:

# create example GeoDataFrame with LineString`
line_new = LineString([(0.3, 0.6), (1.5, 1.6), (0.9,2.5)])
df = gpd.GeoDataFrame()
df.loc[0, 'geometry'] = line_new

This works:df.geometry.length

0    2.643715
dtype: float64

But this does not: df.geometry.coords. It returns the following error:

    return object.__getattribute__(self, name)

AttributeError: 'GeoSeries' object has no attribute 'coords

My understanding from the geopandas documentation was that the 'geometry' GeoSeries in a GeoDataFrame was a Shapely object, and thus the respective properties/methods would be available:

The GeoSeries class implements nearly all of the attributes and methods of Shapely objects.

Is the coords attribute simply one of the few that are not implemented?

Is this the same as what is being asked here?

"AttributeError: 'GeoSeries' object has no attribute 'coords'" when accessing coords property of LineString using GeoPandas

How can I access the .coords property of a LineString in GeoDataFrames? 

I can access other properties, such as area, length, etc, as documented in the Shapely's documentation. See reproducible example below:

# create example GeoDataFrame with LineString`
line_new = LineString([(0.3, 0.6), (1.5, 1.6), (0.9,2.5)])
df = gpd.GeoDataFrame()
df.loc[0, 'geometry'] = line_new

This works:df.geometry.length

0    2.643715
dtype: float64

But this does not: df.geometry.coords. It returns the following error:

    return object.__getattribute__(self, name)

AttributeError: 'GeoSeries' object has no attribute 'coords'

My understanding from the GeoPandas Documentation was that the 'geometry' GeoSeries in a GeoDataFrame was a Shapely object, and thus the respective properties/methods would be available:

The GeoSeries class implements nearly all of the attributes and methods of Shapely objects.

Is the coords attribute simply one of the few that are not implemented?

Is this the same as what is being asked in Extracting points from LineString or Polygon and making dictionary out of them in GeoPandas?

Source Link
matt
  • 53
  • 1
  • 1
  • 4

Cannot access coords property of LineString in GeoDataFrame

How can I access the coords property of a LineString in GeoDataFrames? I can access other properties, such as area, length, etc, as documented in the Shapely documentation. See reproducible example below:

# create example GeoDataFrame with LineString`
line_new = LineString([(0.3, 0.6), (1.5, 1.6), (0.9,2.5)])
df = gpd.GeoDataFrame()
df.loc[0, 'geometry'] = line_new

This works:df.geometry.length

0    2.643715
dtype: float64

But this does not: df.geometry.coords. It returns the following error:

    return object.__getattribute__(self, name)

AttributeError: 'GeoSeries' object has no attribute 'coords

My understanding from the geopandas documentation was that the 'geometry' GeoSeries in a GeoDataFrame was a Shapely object, and thus the respective properties/methods would be available:

The GeoSeries class implements nearly all of the attributes and methods of Shapely objects.

Is the coords attribute simply one of the few that are not implemented?

Is this the same as what is being asked here?