Adding labels to districts in GeoPandas

Once you have your districts drawn up nicely, using the polygons from your shapefile, it would be useful to be able to label them – but of course you need to be able to tell GeoPandas where to place these labels via co-ordinates or points – and in your shapefile you only have polygons which are unsuited to this purpose.

Fortunately GeoPandas provides us with 2 methods to get a set of suitable points from our polygons: centroid (gives us the center point of each polygon) and representative point() (gives us a point which is guaranteed to be within the bounds of the polygon but not necessarily in the center). In the example that I played with the results seemed quite similar, so it’s probably a matter of just playing around with which will suit your mapping project best.

Herewith a quick guide: How it works – labelling districts in GeoPandas.

Comments are closed.

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: