CINXE.COM

Mapnik.org - the core of geospatial visualization & processing

<!DOCTYPE html> <html lang="en-GB"> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta name="description" content="Mapnik - C++/Python GIS toolkit" /> <meta name="keywords" content="mapnik, Mapnik" /> <meta name="robots" content="index, follow" /> <meta name="DC.title" content="Mapnik C++/Python GIS Toolkit" /> <meta name="DC.subject" content="Mapnik GIS webmapping C++ Python" /> <meta name="DC.description" content="Mapnik is a toolkit for developing GIS applications" /> <meta name="DC.creator" content="Artem Pavlenko, artem at mapnik" /> <link href="/css/mapnik.css" rel="stylesheet" type="text/css" media="screen" /> <link rel="alternate" type="application/atom+xml" href="atom.xml" title="Mapnik project news"/> <link rel="shortcut icon" href="/images/favicon.ico" /> <link href='https://fonts.googleapis.com/css?family=Maven+Pro&subset=latin,latin-ext' rel='stylesheet' type='text/css'> <script src='https://code.jquery.com/jquery-2.1.4.js'></script> <script src='/js/mapnik.js'></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <script src="/js/parallax.js"></script> <meta charset="utf-8" /> <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no"/> <title>Mapnik.org - the core of geospatial visualization &amp; processing</title> </head> <body> <!-- header --> <div class="splash"> <div class="gradient"> <div class="col12 clearfix prose"> <div id="logo" class="col5 margin2 pad4y fl"><h1 class="fancy dark">mapnik</h1></div> <div id="tagline" class="col5 space-top4 dark pad4y prose fr">the core of geospatial visualization &amp; processing</div> </div> <div id="intro1" class="col9 margin2 pad2y dark big">mapnik combines pixel-perfect image output with lightning-fast cartographic algorithms, and exposes interfaces in C++, Python, and Node.</div> <div id="intro2" class="col9 margin2 pad2y dark big"> <a href="/pages/downloads.html" class="button stroke white col5">Download mapnik</a> </div> <div id="intro3" class="col9 margin2 pad2y"> <a class="github-button" href="https://github.com/mapnik/mapnik" data-icon="octicon-star" data-size="large" data-show-count="true" aria-label="Star mapnik/mapnik on GitHub">Star</a> <a class="github-button" href="https://github.com/mapnik/mapnik/fork" data-icon="octicon-repo-forked" data-size="large" data-show-count="true" aria-label="Fork mapnik/mapnik on GitHub">Fork</a> </div> </div> <!-- map design --> <div class="module pad8y"></div> </div> <div class="full-content"> <!-- mapnik latest news --><a id="latest-news"></a> <div class="content prose col12 clearfix fill-white"> <div class="col10 margin2 pad2y big">latest news</div> <div class="col6 margin2 pad1y space-bottom4"> <div class="col3"> <h2 class="med-news"><a href="/news/release-4.0.3"> Mapnik 4.0.3 Release</a></h2> <div class="col12"> <div class="col12"><span class="date">Oct 30, 2024</span></div> <div class="col2 space-top1"><img class="dot fl" alt="dot fl" src="/images/authors/artem-pavlenko.jpg" width="30"></div> <div class="col9 space-top1"><span class="date pad1x"> <a href="https://github.com/artemp">Artem Pavlenko</a> </span></div> </div> </div> <div class="col9"> <div class="col1"><img class="fl" alt="fl" src="images/quote-L.png" width="30"></div> <div class="col11 pad1x"><p><img src="/images/dornoch-from-tain.jpg" alt="image" /></p> <a class="news" href="/news/release-4.0.3">read more >> </a></div> </div> </div> <div class="col4 pad4x space-top1"> <div class="col12 space-bottom2"> <a href="/news/release-4.0.2">Mapnik 4.0.2 Release</a><br> <span class="date">Aug 21, 2024 | <a href="https://github.com/artemp">Artem Pavlenko</a></span> </div> <div class="col12 space-bottom2"> <a href="/news/release-4.0.1">Mapnik 4.0.1 Release</a><br> <span class="date">Jul 30, 2024 | <a href="https://github.com/artemp">Artem Pavlenko</a></span> </div> <div class="col12"> <a class="news" href="/news/archive.html">read news archive >> </a> </div> </div> </div> <!-- code bindings --> <a id="code"></a> <div class="content col12 clearfix fill-gray"> <div class="col3 margin2 pad8y prose"> <div class="big">code in your language</div> <p class="space-top1">mapnik's high-quality bindings let's you choose from Node.js, Python, and C++.</p> <div class="col12 pill"> <a href="http://mapnik.org/node-mapnik/documentation/" class="button stroke light short col6">Node.js</a> <a href="http://mapnik.org/docs/v2.2.0/api/python/index.html" class="button light stroke short col6">Python</a> </div> </div> <div class="col7 space-top2 pad4x clearfix"> <div class="col12 pad8y clearfix"> <div class="container"> <ul class="tabs"> <li class="tab-link current" data-tab="tab-1">Python</li> <li class="tab-link" data-tab="tab-2">Node</li> <li class="tab-link" data-tab="tab-3">C++</li> </ul> <div id="tab-1" class="tab-content current"> <figure class="highlight"><pre><code class="language-python" data-lang="python"><span class="kn">import</span> <span class="nn">mapnik</span> <span class="n">m</span> <span class="o">=</span> <span class="n">mapnik</span><span class="p">.</span><span class="n">Map</span><span class="p">(</span><span class="mi">256</span><span class="p">,</span><span class="mi">256</span><span class="p">)</span> <span class="n">mapnik</span><span class="p">.</span><span class="n">load_map</span><span class="p">(</span><span class="n">m</span><span class="p">,</span> <span class="s">"path/to/file.xml"</span><span class="p">)</span> <span class="n">m</span><span class="p">.</span><span class="n">zoom_all</span><span class="p">()</span> <span class="n">mapnik</span><span class="p">.</span><span class="n">render_to_file</span><span class="p">(</span><span class="n">m</span><span class="p">,</span> <span class="s">"the_image.png"</span><span class="p">)</span></code></pre></figure> </div> <div id="tab-2" class="tab-content"> <figure class="highlight"><pre><code class="language-js" data-lang="js"><span class="kd">var</span> <span class="nx">mapnik</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="dl">"</span><span class="s2">mapnik</span><span class="dl">"</span><span class="p">);</span> <span class="kd">var</span> <span class="nx">fs</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="dl">"</span><span class="s2">fs</span><span class="dl">"</span><span class="p">);</span> <span class="nx">mapnik</span><span class="p">.</span><span class="nx">register_default_fonts</span><span class="p">();</span> <span class="nx">mapnik</span><span class="p">.</span><span class="nx">register_default_input_plugins</span><span class="p">();</span> <span class="kd">var</span> <span class="nx">map</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">mapnik</span><span class="p">.</span><span class="nb">Map</span><span class="p">(</span><span class="mi">256</span><span class="p">,</span> <span class="mi">256</span><span class="p">);</span> <span class="nx">map</span><span class="p">.</span><span class="nx">load</span><span class="p">(</span><span class="dl">"</span><span class="s2">./test/stylesheet.xml</span><span class="dl">"</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">map</span><span class="p">)</span> <span class="p">{</span> <span class="nx">map</span><span class="p">.</span><span class="nx">zoomAll</span><span class="p">();</span> <span class="kd">var</span> <span class="nx">im</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">mapnik</span><span class="p">.</span><span class="nx">Image</span><span class="p">(</span><span class="mi">256</span><span class="p">,</span> <span class="mi">256</span><span class="p">);</span> <span class="nx">map</span><span class="p">.</span><span class="nx">render</span><span class="p">(</span><span class="nx">im</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">im</span><span class="p">)</span> <span class="p">{</span> <span class="nx">im</span><span class="p">.</span><span class="nx">encode</span><span class="p">(</span><span class="dl">"</span><span class="s2">png</span><span class="dl">"</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">buffer</span><span class="p">)</span> <span class="p">{</span> <span class="nx">fs</span><span class="p">.</span><span class="nx">writeFile</span><span class="p">(</span><span class="dl">"</span><span class="s2">map.png</span><span class="dl">"</span><span class="p">,</span> <span class="nx">buffer</span><span class="p">);</span> <span class="p">});</span> <span class="p">});</span> <span class="p">});</span></code></pre></figure> </div> <div id="tab-3" class="tab-content"> <figure class="highlight"><pre><code class="language-c--" data-lang="c++"><span class="cp">#include</span> <span class="cpf">&lt;mapnik/map.hpp&gt;</span><span class="cp"> #include</span> <span class="cpf">&lt;mapnik/load_map.hpp&gt;</span><span class="cp"> #include</span> <span class="cpf">&lt;mapnik/agg_renderer.hpp&gt;</span><span class="cp"> #include</span> <span class="cpf">&lt;mapnik/image.hpp&gt;</span><span class="cp"> #include</span> <span class="cpf">&lt;mapnik/image_util.hpp&gt;</span><span class="cp"> </span> <span class="n">main</span><span class="p">()</span> <span class="p">{</span> <span class="n">mapnik</span><span class="o">::</span><span class="n">Map</span> <span class="n">m</span><span class="p">(</span><span class="mi">256</span><span class="p">,</span><span class="mi">256</span><span class="p">);</span> <span class="n">mapnik</span><span class="o">::</span><span class="n">load_map</span><span class="p">(</span><span class="n">m</span><span class="p">,</span> <span class="s">"path/to/file.xml"</span><span class="p">);</span> <span class="n">m</span><span class="p">.</span><span class="n">zoom_all</span><span class="p">();</span> <span class="n">mapnik</span><span class="o">::</span><span class="n">image_rgba8</span> <span class="n">im</span><span class="p">(</span><span class="mi">256</span><span class="p">,</span><span class="mi">256</span><span class="p">);</span> <span class="n">mapnik</span><span class="o">::</span><span class="n">agg_renderer</span><span class="o">&lt;</span><span class="n">mapnik</span><span class="o">::</span><span class="n">image_rgba8</span><span class="o">&gt;</span> <span class="n">ren</span><span class="p">(</span><span class="n">m</span><span class="p">,</span> <span class="n">im</span><span class="p">);</span> <span class="n">ren</span><span class="p">.</span><span class="n">apply</span><span class="p">();</span> <span class="n">mapnik</span><span class="o">::</span><span class="n">save_to_file</span><span class="p">(</span><span class="n">im</span><span class="p">,</span> <span class="s">"the_image.png"</span><span class="p">);</span> <span class="p">}</span></code></pre></figure> </div> </div> </div> </div> </div> <!-- xml stylesheets --> <a id="xml"></a> <div class="content col12 clearfix fill-gray"> <div class="col3 margin2 pad2y"> <h2 class="big">style with a stylesheet</h2> <div class="col10 pad2y">Only a single XML stylesheet for your map, regardless of the code binding.</div> <a href="https://github.com/mapnik/mapnik/wiki/XMLConfigReference" class="space-top1 button stroke light short col8">XML Configuration</a> </div> <div class="col7 pad4x space-bottom4"> <div class="fill-white"> <figure class="highlight"><pre><code class="language-xml" data-lang="xml"><span class="nt">&lt;Map</span> <span class="na">background-color=</span><span class="s">"blue"</span> <span class="na">srs=</span><span class="s">"+init=epsg:4326"</span><span class="nt">&gt;</span> <span class="nt">&lt;Style</span> <span class="na">name=</span><span class="s">"My Style"</span><span class="nt">&gt;</span> <span class="nt">&lt;Rule&gt;</span> <span class="nt">&lt;PolygonSymbolizer</span> <span class="na">fill=</span><span class="s">"#f2eff9"</span> <span class="nt">/&gt;</span> <span class="nt">&lt;LineSymbolizer</span> <span class="na">stroke=</span><span class="s">"rgb(50%,50%,50%)"</span> <span class="na">stroke-width=</span><span class="s">"0.1"</span> <span class="nt">/&gt;</span> <span class="nt">&lt;/Rule&gt;</span> <span class="nt">&lt;/Style&gt;</span> <span class="nt">&lt;Layer</span> <span class="na">name=</span><span class="s">"world"</span> <span class="na">srs=</span><span class="s">"+init=epsg:4326"</span><span class="nt">&gt;</span> <span class="nt">&lt;StyleName&gt;</span>My Style<span class="nt">&lt;/StyleName&gt;</span> <span class="nt">&lt;Datasource&gt;</span> <span class="nt">&lt;Parameter</span> <span class="na">name=</span><span class="s">"file"</span><span class="nt">&gt;</span>path/to/shapefile.shp<span class="nt">&lt;/Parameter&gt;</span> <span class="nt">&lt;Parameter</span> <span class="na">name=</span><span class="s">"type"</span><span class="nt">&gt;</span>shape<span class="nt">&lt;/Parameter&gt;</span> <span class="nt">&lt;/Datasource&gt;</span> <span class="nt">&lt;/Layer&gt;</span> <span class="nt">&lt;/Map&gt;</span></code></pre></figure> </div> </div> </div> <!-- blog --> <div class="fill-gray content col12 clearfix pad1y"> <div class="big quote center pad4y">above all else, beautiful maps</div> </div> <div class='content col12 clearfix fill-sky pad4y'> <div class='big light space-bottom2 center'>stacks built with mapnik</div> <div class='pad1y center lite'> <a class='dark' href='http://www.openstreetmap.org/'>OpenStreetMap</a> | <a class='dark' href='http://www.mapbox.com/'>Mapbox</a> | <a class='dark' href='https://cartodb.com/'>CartoDB</a> | <a class='dark' href='http://stamen.com/'>Stamen</a> | <a class='dark' href='http://www.mapquest.com/'>MapQuest</a> | <a class='dark' href='https://github.com/kosmtik/kosmtik'>Kosmtik</a> </div> </div> <div class='content col12 center caption small fill-sea dark pad1y'> Copyright 漏 2024 Artem Pavlenko | <a href='/pages/downloads.html'>Downloads</a> | <a href='/pages/license.html'>License</a> | <a href='/pages/media.html'>Media</a> | <a href='/pages/dependencies.html'>Developer</a> </div> <!-- end content --> </div> <script async defer id="github-bjs" src="https://buttons.github.io/buttons.js"></script> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10