我使用pysal/cenpy提取地理信息,但是对象通过调用centroid返回错误
import cenpy as cen
import pysal as ps
import geopandas as gpd
dataset = 'ACSSF5Y2015'
con = cen.base.Connection(dataset)
con.set_mapservice('tigerWMS_ACS2017')
geotmp = con.mapservice.query(layer=84, where='STATE=' + str(1))
type(geotmp)
#pandas.core.frame.DataFrame
type(geotmp.geometry[0])
#pysal.cg.shapes.Polygon
geotmp.geometry.centroid
AttributeError: 'Series' object has no attribute 'centroid'
对来自gds-scipy16的内置数据集进行了相同的检查
type(data_table)
#pandas.core.frame.DataFrame
type(data_table.geometry[0])
#pysal.cg.shapes.Polygon
data_table.geometry[0].centroid
#(-94.90336786329912, 48.771730563701574)
如何纠正错误?你知道吗
虽然这并不能直接回答您的问题,但是有一个更新的
cenpy
out预发布版本,它更加精简,可以避免您上面描述的问题(参见下面的示例)。Instructions for installing the pre-release can be found here和a gist demonstrating functionality here。你知道吗相关问题 更多 >
编程相关推荐