我有一个多边形类型的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);