当s=s_data.loc[s_data[‘geometry‘].contains(row),[‘name‘]].values这个里面的用[‘name’]的时候,会报下面的错误: Exception has occurred: ValueError
Invalid field type <class ‘numpy.ndarray’>
File “D:\CODE\geopandas\main.py”, line 23, in <module>
bwg_data.to_file(‘bwg_new1.geojson’,driver=”GeoJSON”,encoding=’utf-8′)
当s = s_data.loc[s_data[‘geometry‘].contains(row),[‘name‘]].values这个里面的用[‘name’]的时候,会报下面的错误:
Exception has occurred: ValueError
Invalid field type <class ‘numpy.ndarray’>
File “D:\CODE\geopandas\main.py”, line 23, in <module>
bwg_data.to_file(‘bwg_new1.geojson’,driver=”GeoJSON”,encoding=’utf-8′)
但是,当s = s_data.loc[s_data[‘geometry‘].contains(row),’name‘].values,这个里面name没有方括号,就运行正常。其他的地方都是一样的。
我调试了也能出来s的值正常,但就是最后一步to_file报错呢。
是的,加方括号后就不能返回一个数组了,表示有多个列,values是表示数组的。另外to_file报错可能是因为输出里面有不能解析的列,可以把报错信息贴出来看看。