python - Cartopy 正在崩溃谷歌代码实验室
问题描述
我正在使用 Cartopy 和 Metpy 创建新图形。当我尝试在我的地图上设置范围时使用谷歌代码实验室时:
track_line_gdf = geopandas.read_file('/content/al112017-020_5day_lin.shp')
cone_gdf = geopandas.read_file('/content/al112017-020_5day_lin.shp')
points_gdf = geopandas.read_file('/content/al112017-020_5day_pts.shp')
map_crs = ccrs.LambertConformal(central_latitude=35, central_longitude=100,
standard_parallels=(30, 60))
data_crs = ccrs.PlateCarree()
fig = plt.figure(figsize=(14 , 12))
ax = plt.subplot(1, 1, 1, projection=map_crs)
ax.set_extent([-90,-72, 20, 55]) #Problem line
我收到警告:“几何必须是点或线串”然后我的笔记本崩溃了。我尝试更改 ax.set_extent() 中的值,但仍然遇到“几何必须是点或线串”的相同问题,然后我的笔记本因“未知”原因而崩溃。我使用的数据也是飓风艾尔玛的形状文件。有没有人见过这个问题?感谢您的帮助!
PS我目前住在关岛,所以与美国大陆相比,我可能会在奇怪的时间做出回应。再次感谢你的帮助!
解决方案
我在 Google Colab 上也发生了这种情况,同样的错误以 Point 或 Linestring 结尾。那条信息似乎很关键。我注意到常规的 apt-get to install cartopy 似乎没有做任何事情——因为它已经安装了,所以我卸载并重新安装了它。但是,我怀疑唯一必要的步骤是之前的帖子发现的: Geometry must be a Point or LineString error using Cartopy
也就是说:在您的 Cartopy 使用前加上:
!apt-get -V -y -qq 安装 python-cartopy python3-cartopy
!pip 匀称卸载 -y
!pip install shapely --no-binary shapely
推荐阅读
- python - Keras模型只能预测一个类
- docker - 无法将文件从 docker 容器复制到 EC2 实例
- spring - 对于具有 ROLE_MANAGER 的用户,日历不显示
- url - 重复,提交的 URL 未被选为规范,而是采用移动网站的随机 URL
- c# - 如何在 .csproj 中引用 NuGet 包
- rdf - SHACL 能否表达对整个数据范围的约束?
- kotlin - 如何修复这些错误以将一些文件上传到与 kotlin 挂起功能相关的服务器?
- cmd - 在 Lua 中从文本文件中附加备注行
- spring - 自定义 Whitelabel 错误页面时控制器无法跳转查看
- tensorflow - tfjs_layers_model 和 tfjs_graph_model 的区别