I'm trying to render a map to paper using Mapnik at a specific scale (such as 1:50k), but can't yet figure out how. So far I'm just using map.zoom_to_box:

map.zoom_to_box (mapnik.Envelope (101.5,3.2,102,3.3))

and play with MaxScaleDenominator and MinScaleDenominator in the styling rules..

But when done this way, I can only guess-work the map scale by adjusting the bounding box over and over, which is hard to obtain the exact 1:50k scale that I wanted.. I've also found this: map.scale_denominator() and map.scale(), but I think these are used only to display the map scale - not setting it..

Hi Haziq, welcome to the forums. I'm not a Mapnik user so I haven't tested this, but here's a post regarding the same issue in OpenLayers, which might also be applicable?
–
Stephen LeadSep 17 '12 at 3:22

When the map is panned at the right location, I just read the current map.envelope() values and transfer them into the map.zoom_to_box as the new bounding box. I'll comment out map.pan_and_zoom(+x,+y,z) when I'm done.

Thanks for this. This "guessing" process can be easily automated, but it's a huge hack. Is there really no better way?!
–
kontextifyDec 26 '14 at 7:49

There should be (still waiting for a better answer). I haven't been using Mapnik for a while, and I've long stopped researching for a better answer. Maybe you should take a look at TileMill or Mapbox Studio, and see how they do it.
–
user8723Dec 26 '14 at 8:23

I've already delved into this blog post: that's where I got the idea on how to get the exact numbers for the scale. The problem is I don't where to plug-in that calculated scale-denominater value.. Thx for trying @gomatteo !
–
user8723Sep 17 '12 at 10:01