首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >重力场叠加联合法的误差分析

重力场叠加联合法的误差分析
EN

Stack Overflow用户
提问于 2022-03-03 08:53:31
回答 1查看 266关注 0票数 0

(我试图通过安装anaconda和在一个新的环境中安装地质公园来解决这个问题)

我最初的问题是:

我有几个多边形堆叠在一起,我试图使用位势叠加与联合方法,以获得所有可能的几何形状返回。

我没有让它工作,所以我直接尝试了示例代码,ref。https://geopandas.org/en/stable/docs/user_guide/set_operations.html

代码语言:javascript
运行
复制
from shapely.geometry import Polygon
import geopandas

polys1 = geopandas.GeoSeries([Polygon([(0,0), (2,0), (2,2), (0,2)]),
                              Polygon([(2,2), (4,2), (4,4), (2,4)])])


polys2 = geopandas.GeoSeries([Polygon([(1,1), (3,1), (3,3), (1,3)]),
                              Polygon([(3,3), (5,3), (5,5), (3,5)])])


df1 = geopandas.GeoDataFrame({'geometry': polys1, 'df1':[1,2]})

df2 = geopandas.GeoDataFrame({'geometry': polys2, 'df2':[1,2]})

ax = df1.plot(color='red');

df2.plot(ax=ax, color='green', alpha=0.5);

res_union = df1.overlay(df2, how='union')

res_union

但我得到了以下错误:

代码语言:javascript
运行
复制
IntCastingNaNError: Cannot convert non-finite values (NA or inf) to integer

我也尝试过所有其他方法:“交叉”、“联合”、“身份”、“对称差异”、“差异”,但唯一起作用的方法是“交叉”和“差异”。

- Addedd 08.03.2022 -这是抛出的错误的完整路径

~\AppData\Local\Temp/ipykernel_19804/2462211871.py中的

IntCastingNaNError跟踪(最近一次调用)

df2) 322 elif == "identity":323 dfunion = _overlay_union(df1,df2)

~\AppData\Local\Programs\Python\Python39\lib\site-packages\geopandas\tools\overlay.py in _overlay_union(df1,df2) 135“”136个dfinter = _overlay_intersection(df1,df2) ->137dfsym= _overlay_symmetric_diff(df1,df2) 138dfunion= pd.concat(dfinter,dfsym,ignore_index=True,sort=False) 139 #仍保持几何列。

~\AppData\Local\Programs\Python\Python39\lib\site-packages\geopandas\tools\overlay.py in _overlay_symmetric_diff(df1,df2) 115 _ensure_geometry_column(dfdiff2) 116 #合并两种差异数据格式-> 117 dfsym =dfdiff2 1。合并( 118 dfdiff2,on="__idx1","__idx2",how="outer",suffixes=("_1","_2") 119 )

合并中的~\AppData\Local\Programs\Python\Python39\lib\site-packages\geopandas\geodataframe.py (self,*args,**kwargs) 1376 1377“”-> 1378 result = DataFrame.merge(self,*args,**kwargs) 1379 geo_col = self._geometry_column_name 1380,如果结果是isinstance( geo_col,DataFrame)和geo_col:

合并中的~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\frame.py (自、右、如何、on、left_on、right_on、left_index、right_index、排序、后缀、复制、指示符、验证) 9189

从pandas.core.reshape.merge导入合并9190 -> 9191返回合并( 9192 self,9193右转,

合并中的~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\reshape\merge.py (左、右、如何、on、left_on、right_on、left_index、right_index、排序、后缀、复制、指示符、验证) 118 validate=validate,119 )-> 120返回op.get_result() 121 122

~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\reshape\merge.py in get_result(self) 734 self._maybe_add_join_keys=self._indicator_post_merge(结果) 735 -> 736 self._maybe_add_join_keys(self._maybe_add_join_keys,left_indexer,right_indexer) 737 738 self._maybe_restore_index_levels(结果)

~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\reshape\merge.py in _maybe_add_join_keys(self,result,left_indexer,right_indexer) 915916如果result._is_label_reference(名称):-> 917 resultname = Series( 918 key_col,dtype=result_dtype,index=result.index 919 )

~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\series.py in init(self、data、index、dtype、name、copy、fastpath) 381如果dtype不是None: 382 # astype -> 383 data = data.astype(dtype) 384 to : 385 # GH#24096我们需要确保索引保持不变

~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\indexes\numeric.py在astype(self,dtype,copy) 221 # TODO(jreback);一旦我们有一个EA索引类型222 # GH 13149 -> 223 arr = astype_nansafe(self._values,dtype=dtype) 224返回Int64Index(arr,name=self.name) 225,这可能会改变。

~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\dtypes\cast.py in astype_nansafe(arr,dtype,copy,skipna) 11661167 elif np.issubdtype(arr.dtype,np.floating)和np.issubdtype(dtype,np.integer):-> 1168返回astype_float_to_int_nansafe(arr,dtype,copy) 1169 1170 elif is_object_dtype(arr):

~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\dtypes\cast.py in astype_float_to_int_nansafe(值、dtype、拷贝) 1211“”

1212如果不是np.isfinite(值).all():-> 1213引发IntCastingNaNError( 1214“不能将非有限值(NA或inf)转换为整数”1215 )

IntCastingNaNError:无法将非有限值(NA或inf)转换为整数。

EN

回答 1

Stack Overflow用户

发布于 2022-03-03 20:20:20

代码没有问题,请通过以下方法查看您的地质公园版本:

代码语言:javascript
运行
复制
import geopandas as gpd
gpd.__version__

如果不是0.10.2,更新它

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71334369

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档