问题:
我有一个多边形,我想用geoplot在地图上绘制。当我尝试这样做时,我得到ValueError:输入GeoDataFrame没有“geometry”列集
如何正确设置多重多边形的格式(可能是规则形状多边形的类似问题),以便在地图上正确绘制
当前代码:
from polygon_geohasher.polygon_geohasher import polygon_to_geohashes, geohashes_to_polygon
from shapely.geometry import Polygon
import geopandas as gpd
import geoplot as gplt
import geoplot.crs as gcrs
# Create multipolygon consisting of two disconnected polygons:
a=geohashes_to_polygon('9v','9x')
# Plot map underlay:
contiguous_usa = gpd.read_file(gplt.datasets.get_path('contiguous_usa'))
ax=gplt.polyplot(contiguous_usa,
projection=gcrs.AlbersEqualArea(),
edgecolor='white',
facecolor='lightgray',
figsize=(12,12),
)
# Add layer with multipolygon in red:
gplt.polyplot(a, ax=ax,facecolor='red',edgecolor='none') # This is the line that causes me problems
# OUTPUT: "ValueError: The input GeoDataFrame does not have a "geometry" column set."
编辑:
将有问题的代码行更改为以下代码可以解决错误,但会导致地图放大红色图层:
gplt.polyplot(gpd.GeoSeries([a]), ax=ax,facecolor='red',edgecolor='none',alpha=.4)
目前没有回答
相关问题 更多 >
编程相关推荐