Skip to main content
Open

Map legend designer

Related products:Transformers
  • October 30, 2015
  • 6 replies
  • 60 views

Forum|alt.badge.img+5
Now that map making is a lot easier with the mapnik transformer I think a map legend maker would be very useful, as well as templates, north arrows etc The ability to search through all the datasets used and auto create a legend would be brilliant.

6 replies

Forum|alt.badge.img
  • November 2, 2015
This is trickier than it seems I suspect. But the WMS specification does include the ability to create legends; I imagine it would be useful to take a peek at if Safe want to go that way:

 

http://docs.geoserver.org/stable/en/user/services/...

 


redgeographics
VIP
Forum|alt.badge.img+62
I agree, a basic legend coming out of the MapnikRasterizer would be nice, although I think it would only really be doable for the hard-coded styles, as soon as you're using attribute values to determine styles it will become a lot trickier. What would you do if you use an attribute to control opacity for example? Or line width? Seperate legend entry for every unique value?

 


Forum|alt.badge.img+5
  • Author
  • November 6, 2015

I built a legend maker that uses the same look up table as the master mapnik to assign the styling, transparency etc. but its very difficult to build one that will auto resize, its also clunky and complicated.

The Mapnik rasterizer could have another panel that builds the legend and has its own output port. It would have all the data from the attributes for styling.


  • July 31, 2017
Could you help me understand how legend can be made to a map using mapnik rasteriser ?I used the transformer to create a png file based on the filterations coming out of a test filter. Please see the attached screenshot

 

Thanks in advance

 

 

 

capture.jpg

Forum|alt.badge.img+5
  • Author
  • February 2, 2018

 

Hey sorry, I haven't logged in for a while and some how missed this comment. @arvr1991

 

 

The only way I made it work (sure there are other methods) is to use a separate mapnik transformer. So break off another link before your master mapnik that creates the main map and feed the same objects into a new mapnik. Then you can remove the geometry and duplicates and use vertex creators to make a series of points on the page- you have to pretend that the legend has space say its 5m across and 10m long depending on your aspect ratio. Then you can use the same SVGs, PNGs or any other styling to create the legend block. I used a square marker SVG symbol to represent polygon data and set the correct colour, however I guess you could use a 2D box replacer.

 

 

Its clunky and hard to get right and auto resizing and positioning text and symbols is really tricky. But a mixture of attribute creators using conditional values, vertex creators and off setters means you can position equally spaced points, lines or blocks across your legend - assign a new offsetter value to each feature using a counter. In mapnik add the text but use the Dx field on the mapnik controls to offset the text to the side of the feature. You then have an output on a separate image that contains all the features from the map.

 

Happy to add some images if this doesnt make a lot of sense!

 

 


Forum|alt.badge.img+5
  • Author
  • February 2, 2018
I think , although I might be wrong, that WMS getLegend requests just use the SLD styling file that goes with that service. I guess if Safe update styling to include the ability to add in SLD files then that could be used to create a legend. The hardest thing though is layout and styling, my legend creator works but it looks a bit rubbish! So maybe some tweaks to page layouts like the PDF page formatter would be good?