Skip to main content
Solved

MapnikRasterizer - Cell Spacing from attribute


Greetings to everyone.

I need to rasterize some different cartograms.  That means I got some polygons and need to place them on a map and then get image as a result.  Different cartograms means different sizes on real map (in meters), but in result I need equal-sized images (in pixels).  My idea was to use Raster Properties in MapnikRasterizer by changing Cell Spacing parameter dynamically.  For each cartogram I calculate a new Cell Spacing value using Aggregaror -> BoundingReplacer -> BoundsExtractor -> AttributeCreator with some math inside. AttributeCreator add Kmax attribute that contain exactly what I need - how much meters in one pixel and two values for buffer. Then I clip source map (from SASPlanet if you know) using Clipper and 2DBoxReplacer - adding needed buffer to each x and y value at both sides because I need exatly asked width and height no matter of cartogramm geometry. That is my Raster for Mapnik.  At this step all is fine - including all calculated values, that was shown in Inspectors with best care.

And of course I send some geometry objects to Mapnik - that is my cartogram polygons.

But problem was when I never expect - well, I am pretty new to FME -  MapnikRasterizer send a fatal erro to me because  "No values were specified for either both NUM_ROWS and NUM_COLUMNS, or SPACING.  One or the other must be specified".   If I wrote in CellSpacing something like 

@Max(@Value(Kmax),20)

instead of what I really need:

@Value(Kmax

all is fine with errors but dummy 20 always, never Kmax.  

What I doing wrong?  Thanks for any help!

Best answer by jdh

The first feature in to the MapnikRasterizer needs to have the spacing attribute. If the geometry objects arrive first and doesn't have the attribute it will throw an error, even though the raster is presumably the first/bottom layer in the Mapnik composite.

View original
Did this help you find an answer to your question?

5 replies

jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • Best Answer
  • April 27, 2017

The first feature in to the MapnikRasterizer needs to have the spacing attribute. If the geometry objects arrive first and doesn't have the attribute it will throw an error, even though the raster is presumably the first/bottom layer in the Mapnik composite.


  • Author
  • April 28, 2017
jdh wrote:

The first feature in to the MapnikRasterizer needs to have the spacing attribute. If the geometry objects arrive first and doesn't have the attribute it will throw an error, even though the raster is presumably the first/bottom layer in the Mapnik composite.

Thanks @jdh - then only one question: how can I manage what will arrive first ? If I can ...

takashi
Evangelist
  • April 28, 2017
masolodkov wrote:
Thanks @jdh - then only one question: how can I manage what will arrive first ? If I can ...
If it's hard to control the input order of the features, it could also be a workaround to add the same Kmax to all features belonging to the same group. The FeatureMerger might help you to do that.

 


  • Author
  • April 28, 2017
takashi wrote:
If it's hard to control the input order of the features, it could also be a workaround to add the same Kmax to all features belonging to the same group. The FeatureMerger might help you to do that.

 

Thanks for your avdice, @takashi. I will search some doors in this way.

jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • April 28, 2017
masolodkov wrote:
Thanks @jdh - then only one question: how can I manage what will arrive first ? If I can ...
The answer to that really depends on what you are doing "upstream" of the mapnik rasterizer.

 

Reader order is the primary thing to look at, however any blocking transformers can slow down the features. As @takashi mentioned adding the attribute to all features is one way to make the first feature contains it.

 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings