NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

Is there a way to map out and tag an entity such as county, city or suburb (or state, or village, etc., although I don't work with those as a matter of practice) as a polygon and have its name rendered in the same style and at the same zoom levels as it would be rendered if it were a node tagged as place=*?

Please note that I am not talking about the way the name of the area polygons is rendered, such as landuse=* or a building=* polygons. I am talking about the styles associated with the place=* hierarchy.

I am interested mostly in Mapnik, although if the answer is 'no' for Mapnik and 'yes' for another renderer, I would like to hear about that.

asked 18 Apr '11, 19:45

ponzu's gravatar image

accept rate: 0%

edited 19 Apr '11, 19:52

You might be confusing something when you say you do not want it in the way landuse or buildings behave, because actually it is the exact same way. The font and zoomlevel when the label appears depends on the style sheet. As Andy said: if you use the same styles as there already are for place nodes, the labels will look the same.

(19 Apr '11, 09:44) dieterdreist

I don't think I am too confused. The names of place nodes appear at earlier zooms and have different fonts for different ranks. If I were to convert a place polygon to a multipolygon, as someone suggested elsewhere, then its name would get rendered in the center, but it would be rendered according the same rules as area polygons currently do. I did not want anyone suggesting this again.

I understand about the stylesheets, will query Andy about them more. The question was can I tag for the existing stylesheet to get the desirable result.

(19 Apr '11, 19:55) ponzu

Yes, this is easy to achieve with a customised stylesheet in mapnik.

First, ensure the object is a candidate for the polygons table (in this case key "place" is already marked as such in the osm2pgsql Then you can add a layer definition to your mapnik style referring to the polygons table instead of the nodes table, but otherwise the same as the existing layer showing places.

If you use the same style rules for both the point- and polygon- layers then the text will show up in the same size and zoom levels, regardless of whether it's using the point or polygon table. And mapnik lets you use the same <stylename> declaration in multiple layers, so you don't need to make duplicate of the style rules.

permanent link

answered 19 Apr '11, 08:58

Andy%20Allan's gravatar image

Andy Allan
accept rate: 28%

Well, I have now heard two versions of the answer: "It is easy" and "People have been bugging Mapnik about this for a long time". If it's easy, why hasn't it been implemented? Do you think anyone would mind if this became the standard behavior? We would not need place nodes anymore in addition to place polygons. The advice I received elsewhere was to delete the node once a polygon for the same entity is available. That advice either did not take labeling into consideration or did not apply to places at all (it could have been about parks and such).

(19 Apr '11, 19:58) ponzu

Also, could you please elaborate or point me to the discussion explaining how me customizing a Mapnik stylesheet can help affect what the map looks like in I am not talking about producing a custom map, but about either tweaking my tagging in case it's what's preventing the current "official" Mapnik from rendering the names, or tweaking the "official" Mapniik. I am sorry if I did not make myself clear.

(19 Apr '11, 20:02) ponzu

The reason it isn't being done in mapnik today is because I only recently switched place to be a polygon candidate in osm2pgsql's file. Once we've had a full rendering database reload on, we can start showing place=* polygons as well.

(20 Apr '11, 21:35) Lennard

Excellent news. Follow-up questions: 1)Will the names be rendered in accordance with the place=* styles or same as any polygon? (Hint: I am hoping for the former). 2)Will it work on multipolygons as well as closed ways? 3)Does/will Mapnik support boundary relations? Specifically, will Mapnik respect the "label" role and generate the label where that node points, and will these relations need a place=* tag to get their labels rendered properly, or will Mapnik go on admin_level? If there are existing threads on this subject, please point me to them (Trac, forum, lists, IRC, wiki, etc.)

(20 Apr '11, 22:33) ponzu

1) The plan is to have them in the same style as place=* nodes.

2) They're the same as far as the rendering database is concerned.

3) Support for this would need to come from osm2pgsql in the first place. I'm not a huge fan of the label=* role, and that's an understatement.

Support for place areas is distinctly different from boundary relations and admin_level. So yes, you'd need a place tag on the closed way or multipolygon relation. is an example from trac

(21 Apr '11, 20:52) Lennard

Let's be clear that I am talking about a role=label member of a boundary/multipolgon relation, and not the type=role relation, which is a competing proposal, allegedly honored by Osmarender, which I personally have no experience using and have no interest in. The Trac ticket you linked talks about the role relation, not role member. And when you reference label=* role, this makes me think of the label key applicable, for example, on manhole covers:

(21 Apr '11, 21:59) ponzu

I think that if Mapnik starts rendering the name of a closed way polygon and multipolygon (including boundary relation as a subclass of a multipolygon) in accordance with the style associated with the place=* tag on the (multi)polygon and in the centroid of the polygon, most people should be happy. I personally would not care much if the label role is supported or not. I thought this role was necessary to cause the label the render. But since it has nothing to do with that, I personally lost interest in it. The use cases for this role are pretty specific and rare.

(21 Apr '11, 22:05) ponzu

When will a "full rendering database reload on" happen? Does that only happen irregularly, or is it going to happen automatically sometime, or is that what happens all the time? I don't understand what it means. I tried to search the wiki for an explanation, but couldn't find anything.

(23 Apr '11, 14:09) spod

To be able to render the default map on, we take the OSM database and process/import that into another database to suit the map renderer. This is what a "rendering database reload" means.

Usually, this rendering database is kept up to date by applying changes as they happen. This is the normal operating mode.

Every once in a while, the whole db is reloaded from scratch. This used to happen once a week when we had no minutely updates. Then once these updates matured, the full reload interval increased. The last one was done over a year ago. I'm expecting another one before the summer.

(23 Apr '11, 15:00) Lennard

Thanks for the info Lennard - is there a way of being informed of/finding out when the full database reload has happened, so I can check that my multipolygon labels are then being rendered correctly?

(24 Apr '11, 04:56) spod

@Lennard Let me make sure I understand. You have already made the necessary change to start having place polygon labels rendered in the style consistent with place nodes, and the reason we are not seeing them is because the database has to be fully refreshed? What about a brand new place polygon? Will it get its label rendered? My testing says it does not, but maybe I was testing prior to your change?

(25 Apr '11, 19:14) ponzu
showing 5 of 11 show 6 more comments

The new instructions* to handle place as polygons will only be activated once a full reimport is being done.

*osm2pgsql's file

permanent link

answered 25 Apr '11, 19:29

Lennard's gravatar image

accept rate: 0%

You might want to consider creating a relation for the polygon with boundary=administrative (with the admin_level being appropriate for the type of place). You can make the place node a member of the relation. See the page for details.

permanent link

answered 29 Apr '11, 01:00

Ebenezer's gravatar image

accept rate: 9%

That doesn't do anything. The name of the place will be rendered in the place-appropriate style, but it will be due to the existence of the place node, not it's inclusion in the relation. I confirm that the name of a relation-based polygon (I.e., multipolygon or boundary) does get rendered currently in the centroid, but its style does not follow the place=* styles.

(29 Apr '11, 22:03) ponzu

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 18 Apr '11, 19:45

question was seen: 11,855 times

last updated: 29 Apr '11, 22:03

NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum