本文介绍了Python底图“断言失败"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Anaconda 2.1.0,并且底图安装成功

I am using Anaconda 2.1.0 and Basemap installation is successful

conda install basemap
conda install gdal

我有geos版本3.3.3和proj4 4.8.0-0.但是,当我尝试将(纬度,经度)度投影到一个平面上时,仍然出现以下错误:

I have geos version 3.3.3 and proj4 4.8.0-0. However, I keep getting the following error when I try to project (lat,lon) degrees to a planar:

 Assertion failed: (0), function query, file AbstractSTRtree.cpp, line 286.

我的代码如下:

import shapely.geometry as sg
from pymongo import MongoClient
from mpl_toolkits.basemap import Basemap

p = Basemap(projection='sinu',lon_0=0,resolution='c')

projected_xy = p(24.4,45.1)

推荐答案

在使用Geopandas时,我遇到了同样的问题.再次,进口顺序是相关的.在这种情况下,我必须在Basemap之后导入geopandas.我的进口清单如下:

I was running into the same issues when working with geopandas. Again, the order of imports was relevant. In this case, I had to import geopandas after Basemap. My list of imports looks as follows:

from mpl_toolkits.basemap import Basemap
import geopandas as gp
from shapely.geometry import Point, Polygon, MultiPoint, MultiPolygon
from shapely.prepared import prep

请注意,如果您在Jupyter笔记本中工作,则内核连接将崩溃,并且不会提供错误信息.使用python shell之后,给出了以下错误:

Note that if you are working in a Jupyter notebook your Kernel connection will crash and no information of the error will be given. After using the python shell, the following error was given:

Assertion failed: (0), function query, file AbstractSTRtree.cpp, line 285.
Abort trap: 6

这篇关于Python底图“断言失败"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-27 20:18