Thanks for an amazing library!
I want to plot a choropleth map similar to How to color polygons of a geopandas dataframe in pygmt?, however, I am running across an issue:
import pygmt
fig = pygmt.Figure()
fig.coast(
region='d',
projection='R20/8i',
shorelines=True,
water='lightblue',
land='grey',
frame=True,
)
attribute_df['randNumCol'] = np.random.randint(1, 60, attribute_df.shape[0], dtype=int)
pygmt.makecpt(cmap="batlow", reverse=True, continuous=True, series=[1, 60, 10])
print(attribute_df['randNumCol'])
try:
fig.plot(data=attribute_df, close=True, color='+z', aspatial="Z=randNumCol", cmap=True, label='randNumCol')
except Exception as e:
print(e)
fig.colorbar()
fig.savefig('aa.png', show=True)
However, I get the following error: Unsupported numpy data type '<class 'numpy.object_'>'.
attribute_df
contains regional boundaries for all countries, and looks like below. It also contains a column called shape
which contains shapely information on polygon. I am excluding that column here for brevity.
Country region randNumCol
0 comoros anjouan 7
1 comoros moheli 46
2 comoros ngazidja 2
3 djibouti ali_sabieh 26
4 djibouti dikhil 27
How can I fix this or any tips on how to debug it?