Код: Выделить всё
map = gpd.read_file("my_shapefile.shp")
map["values"] = np.random.rand(len(map))
fig, ax = plt.subplots(1, 1, figsize=(15, 15))
map.plot(column="values", ax=ax, legend=True, cmap="Reds")
map["county_centers"] = map.geometry.centroid # With this, I get coordinates
# of a point in the center of the polygons
# in "Map"-coordinates
subax = fig.add_axes([0.45, # left
0.45, # bottom
0.1, # width
0.1]) # height
subax.pie([0.2,0.8], labels=["A", "B"])
fig.show()
Я пытался их нормализовать:
Код: Выделить всё
minx, miny, maxx, maxy = map.total_bounds
p = map["county_centers"][0]
x = (p.x - minx) / (maxx - minx)
y = (p.y - miny) / (maxy - miny)
Есть ли способ легко сопоставить центроиды с координатами matplotlib?
Подробнее здесь: https://stackoverflow.com/questions/790 ... oordinates