mapnik's high-quality bindings let's you choose from Node.js, Python, and C++.
import mapnik m = mapnik.Map(256,256) mapnik.load_map(m, "path/to/file.xml") m.zoom_all() mapnik.render_to_file(m, "the_image.png")
var mapnik = require("mapnik"); var fs = require("fs"); mapnik.register_default_fonts(); mapnik.register_default_input_plugins(); var map = new mapnik.Map(256, 256); map.load("./test/stylesheet.xml", function(err, map) { map.zoomAll(); var im = new mapnik.Image(256, 256); map.render(im, function(err, im) { im.encode("png", function(err, buffer) { fs.writeFile("map.png", buffer); }); }); });
#include <mapnik/map.hpp> #include <mapnik/load_map.hpp> #include <mapnik/agg_renderer.hpp> #include <mapnik/image.hpp> #include <mapnik/image_util.hpp> main() { mapnik::Map m(256,256); mapnik::load_map(m, "path/to/file.xml"); m.zoom_all(); mapnik::image_rgba8 im(256,256); mapnik::agg_renderer<mapnik::image_rgba8> ren(m, im); ren.apply(); mapnik::save_to_file(im, "the_image.png"); }
<Map background-color="blue" srs="+init=epsg:4326"> <Style name="My Style"> <Rule> <PolygonSymbolizer fill="#f2eff9" /> <LineSymbolizer stroke="rgb(50%,50%,50%)" stroke-width="0.1" /> </Rule> </Style> <Layer name="world" srs="+init=epsg:4326"> <StyleName>My Style</StyleName> <Datasource> <Parameter name="file">path/to/shapefile.shp</Parameter> <Parameter name="type">shape</Parameter> </Datasource> </Layer> </Map>