Skip to main content

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!

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.


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 ...
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.

 


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.
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.

 


Reply