Question

Legend creation for a raster map


Hi,

I am trying to create a map in a raster format and write it to MSWord ( using MSWordStyler) however I seem not to be able to create a legend for my map. ( a table holing the name of the attributes visualised on the map and their symbology on the next column) in my case the symbology is easy. just colored circles.

Does any one have an experience with this orhave an idea what transformer to use in order to get this result?

 

the part of my work space that creates the raster map:


10 replies

Badge +4

Not sure if this will help you or not, but I was doing something similar where I was creating a raster output that I was writing into Excel and needed a legend. My legend didn't need to be dynamic, so I created a simple legend in FME using Creators and Offsetters before the MapNikRasterizer. From there I did some manual edits in Paint, and then added it to my Excel template. If you're needing a dynamic legend this might not work for you, but I'm thinking the FME part could be similar.

One Creator makes the box for the legend, the other Creator makes 6 points that I then filter and offset differently to spread out inside the box. The Offset for Labels are then offset from the point offsets and then all go into the MapnikRasterizer on separate layers with unique symbology or labels being all created right in the MapnikRasterizer. The output is simple but effective:

Badge +22

If you want a graphic legend then the MapnikRasterizer is the way to go. You can even make it dynamic with some logic in regards to the layout (the modulo counter will help if there are multiple columns).

 

 

But if I understand correctly you want something more like this, where the table is part of the word document.

There are two routes to go down, one is to generate an image for each layer and follow the workflow of https://knowledge.safe.com/questions/88061/mswordstyler-how-to-include-picture-in-table.html

 

 

The other, since you just have circles as your symbols, they can be represented by the ? character. Unfortunately the MSWordStyler transformer does not include msword_font_color option for tables like it does for paragraphs and lists, so you would probably have to go the python route as well.
Badge +3

@sevda

You can use for each a "marker" and "text" symboliser (split the input)

You can use the transform parameter to apply desired transformation, including move.

You must first place the legend location, as you have no control over that in Mapnik. (marker symboliser is a directional linesymboliser and you can't extract coordinates at that stage)

 

You do not need all those ofsetters, one counter (if no sequential id exists) and a vertexcreator complemented by "translate" in Mapnik suffices.

 

@jdh you can make circles (or other elipse with the standard marker symboliser) See my workbench. Other shapes or picture can be used by using svg files. (make sure to set it on the paperspace and clean up! Else it will show.)

See workspace.

Maponik labelcontrol.fmwt

Badge +3

@sevda

You can use for each a "marker" and "text" symboliser (split the input)

You can use the transform parameter to apply desired transformation, including move.

You must first place the legend location, as you have no control over that in Mapnik. (marker symboliser is a directional linesymboliser and you can't extract coordinates at that stage)

 

You do not need all those ofsetters, one counter (if no sequential id exists) and a vertexcreator complemented by "translate" in Mapnik suffices.

 

@jdh you can make circles (or other elipse with the standard marker symboliser) See my workbench. Other shapes or picture can be used by using svg files. (make sure to set it on the paperspace and clean up! Else it will show.)

See workspace.

Maponik labelcontrol.fmwt

here is same with more contro9l relegated trough parameters.

Maponik labelcontrol.fmwt

the dX in the text symboliser could do with some added intelligence.

Badge +3

@sevda

You can use for each a "marker" and "text" symboliser (split the input)

You can use the transform parameter to apply desired transformation, including move.

You must first place the legend location, as you have no control over that in Mapnik. (marker symboliser is a directional linesymboliser and you can't extract coordinates at that stage)

 

You do not need all those ofsetters, one counter (if no sequential id exists) and a vertexcreator complemented by "translate" in Mapnik suffices.

 

@jdh you can make circles (or other elipse with the standard marker symboliser) See my workbench. Other shapes or picture can be used by using svg files. (make sure to set it on the paperspace and clean up! Else it will show.)

See workspace.

Maponik labelcontrol.fmwt

and a pic of part of the output..

Not sure if this will help you or not, but I was doing something similar where I was creating a raster output that I was writing into Excel and needed a legend. My legend didn't need to be dynamic, so I created a simple legend in FME using Creators and Offsetters before the MapNikRasterizer. From there I did some manual edits in Paint, and then added it to my Excel template. If you're needing a dynamic legend this might not work for you, but I'm thinking the FME part could be similar.

One Creator makes the box for the legend, the other Creator makes 6 points that I then filter and offset differently to spread out inside the box. The Offset for Labels are then offset from the point offsets and then all go into the MapnikRasterizer on separate layers with unique symbology or labels being all created right in the MapnikRasterizer. The output is simple but effective:

Hi, I am struggling to create legend for the map and found your answer is the most potential effective. However, how did you setup the Offset, and MapnikTasterizer? Do you mind if I can have a look at your workspace? Thank you.

Badge +3

here is same with more contro9l relegated trough parameters.

Maponik labelcontrol.fmwt

the dX in the text symboliser could do with some added intelligence.

please,could u provide me with ur workspace if u still have it , i am still struggling to create legend to write in sheet at excel file .i have FME 2018

thanks

Badge +3

here is same with more contro9l relegated trough parameters.

Maponik labelcontrol.fmwt

the dX in the text symboliser could do with some added intelligence.

@spiderman​ 

 

Hi friendly neighbourhood spider.

 

Here is a workbench.

Added labels with text in it.

For further info check the mapnik site for settings.

 

succes!

 

 

 

 

 

 

Badge +3

here is same with more contro9l relegated trough parameters.

Maponik labelcontrol.fmwt

the dX in the text symboliser could do with some added intelligence.

added some for sorting the labels in legend.

 

 

Badge +3

here is same with more contro9l relegated trough parameters.

Maponik labelcontrol.fmwt

the dX in the text symboliser could do with some added intelligence.

@spiderman​ 

 

Hi Again.

 

I added spatial labelsorting to the workbench.

 

 

Reply