Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was wondering if anyone knew the math involved, or resources for learning the math involved, in finding the ideal position, scale, and rotation of a label for a line or polygon on a map?

The most I've got so far is finding the centroid for a polygon (though it's not ideal for concave polygons).

share|improve this question
I guess it is best to do this manually. – Jonas Jul 23 '10 at 16:12
Related resource: The Computational Complexity of Cartographic Label Placement. Citation includes other associated references. – glennon Jul 30 '10 at 0:11

Centroid is never the answer but it is a good initial guess. The algorithms which are easiest to implement that solve similar problems usually operate by trying a few reproducible pseudorandom positions and scoring them somehow, keeping the best spots. For further reading I would start by reading up on bin packing algorithms and take it from there.

share|improve this answer

A research paper that addresses this hard issue:

share|improve this answer

Maybe the documentation of the PAL labeling library is a good start for further research. I especially recommend "From Point Feature Label Placement to Map Labelling".

share|improve this answer

Labeling is a nasty endeavor.

At a small scale: you have label overlap problems, so which one do you remove or should all be shown.

At a large scale: if you have a large polygon, where do you display the label. Do you display it multiple times.

share|improve this answer

I've seen maps where they just calculate a bounding box for a complex polygon and place the label in the center of that.

For simple lines, usually it's just the middle of the two endpoints.

I guess it really just depends on what you expect your data to be and how important the location of the label is.

share|improve this answer
What's up with the downvote? A comment might be useful. – Jon Bringhurst Jul 29 '10 at 23:46

You can inspect the code in GeoTools and GeoServer if you grok java - it is a constantly evolving problem as people keep coming up with new corner cases that need fixing.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.