无法使用hvplot在地图平铺上打印

2024-06-10 04:26:41 发布

您现在位置:Python中文网/ 问答频道 /正文

以下代码成功生成我想要的UK choropleth地图:

plot2 = itv_region_map_gdf.hvplot.polygons(color="ITV Region",
                                           hover_cols=['Postcode District', 'Easting', 'Northing', 
                                                       'Grid Reference', 'Town/Area', 'Region', 
                                                       'Postcodes','Active postcodes', 'Population',  
                                                       'Households', 'Nearby districts'],
                                           cmap = ["#6495ED","#FF7F50","#8A2BE2",
                                                   "#A52A2A","#483D8B","#0000CD",
                                                   "#D46A4C","#FAA61A","#FDF38E",
                                                   "#DC241f","#00FFFF","#A52A2A",
                                                   "#8A2BE2"], tiles='OSM'
                                          ).opts(width=750,height=900)
plot2

enter image description here

但是,它无法在地图平铺上绘制我的地图。 我的geodataframe itv_region_mapcrs4326

itv_region_map_gdf.crs
<Geographic 2D CRS: EPSG:4326>
Name: WGS 84
Axis Info [ellipsoidal]:
- Lat[north]: Geodetic latitude (degree)
- Lon[east]: Geodetic longitude (degree)
Area of Use:
- name: World
- bounds: (-180.0, -90.0, 180.0, 90.0)
Datum: World Geodetic System 1984
- Ellipsoid: WGS 84
- Prime Meridian: Greenwich

这就是我使用GeoView(使用gv.Polygons)成功生成英国Choropleth的crs

我试图生成plot2设置crs='4326'crs=4326crs={'espg':'4326'}crs={'espg':4326}crs={'init':'4326'}crs={'init':4326},但它们都不起作用。(我在前两次尝试中得到的错误是ValueError: '4326' must be either a valid crs or an reference to a `data.attr` containing a valid crs,在其他4次尝试中得到的错误是 TypeError: unhashable type: 'dict'

我阅读了https://hvplot.holoviz.org/user_guide/Geographic_Data.html,但我看不到我缺少什么。当用hvplotgeoviews进行绘图时,我必须使用不同的crs

谢谢


Tags: map地图arearegionwgscrsgdfdegree