如何在Geopandas中显示非英文字符作为标签?

时间:2019-07-05 03:24:50

标签: python matplotlib jupyter-notebook geopandas annotate

我有一个多边形类型的shapefile。在此shapefile的表中,有一列名为NAME的列。此列字符为Farsi字体,非英语。我想用Geopandas中的jupyter读取此文件,然后根据NAME列显示每个多边形标签的名称。我使用下面的代码。它可以显示地图,但是标签显示为????字符。有解决的办法吗?

import geopandas as gpd
import matplotlib.pyplot as plt

cities = gpd.read_file(r'/Maps/my_polygon.shp')

fig, ax = plt.subplots(figsize = (10,5)) 
cities.plot(color='black', edgecolor='k',linewidth = 1,ax=ax)
cities.geometry.boundary.plot(color=None, edgecolor='k',linewidth = 1,ax=ax)

# Labeling name of cities with field of 'NAME'
cities.apply(lambda x: ax.annotate(x.NAME, xy=x.geometry.centroid.coords[0], ha='center'),axis=1);

0 个答案:

没有答案