【发布时间】:2019-07-04 01:27:42
【问题描述】:
在编码(新手编码器)时,我在 geopandas 中使用 GeoDataFrames 时反复收到相同的错误消息:AttributeError: 'GeoDataFrame' object has no attribute XYZ。
代码中的多个点都会发生相同的错误(似乎几乎我尝试实现的每个操作)。
conflict_events = []
for index, row in polys.iterrows():
polygon = polys.geometry[0]
subset = conflict[conflict.within(polygon)]
# print(subset)
conflict_events.append(subset)
print(polys.conflict_events)
Error = AttributeError: 'GeoDataFrame' 对象没有属性 'conflict_events'
polys 是一个 shapefile。冲突是一个点数据集。
for index, row in val.iterrows():
# print(type(row['val_mar19']))
# print(type(polys_val.loc[index].count))
val_calc = row['val_mar19'] / float(polys_val.loc[index]['count'])
if not math.isnan(val_calc):
val_calc = int(val_calc)
polys.REFPOP.iloc[[polys.NAME_1 == row.NAME_1]] = val_calc
polys.to_file("val_pop.shp")
scaler = preprocessing.StandardScaler()
scaled_actual = scaler.fit_transform(output.row['simEnd'])
scale_predicted = scaler.fit_transform(val.row['val_mar19'])
Error = AttributeError: 'GeoDataFrame' 对象没有属性 ''row'
val 是一个 shapefile。
在这两种情况下,同样的错误。在第一种情况下,我试图遍历多边形,确定每个(计数)中有多少点,并将该值保存到新行“conflict_events”中。在第二种情况下,我尝试使用 sklearn 将两个 shapefile(输出和 val)中的两行(simEnd 和 val_mar19)中的值分别标准化为 0-1。我相信我在处理 GeoDataFrames 时处理不当。
【问题讨论】:
标签: python dataframe gis geopandas