<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="https://blog.geothings.ch/feed_style.xsl" type="text/xsl"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <tabi:metadata xmlns:tabi="https://github.com/welpo/tabi">
        <tabi:base_url>https://blog.geothings.ch</tabi:base_url>
        <tabi:separator>
            •
        </tabi:separator>
        <tabi:about_feeds>
            This is a web feed, also known as an Atom feed. Subscribe by copying the URL from the address bar into your newsreader. Visit About Feeds to learn more and get started. It's free.
        </tabi:about_feeds>
        <tabi:visit_the_site>
            Visit website
        </tabi:visit_the_site>
        <tabi:recent_posts>
            Recent posts
        </tabi:recent_posts>
        <tabi:last_updated_on>
            Updated on $DATE
        </tabi:last_updated_on>
        <tabi:default_theme></tabi:default_theme>
        <tabi:post_listing_date>date</tabi:post_listing_date>
        <tabi:current_section>tiles</tabi:current_section>
    </tabi:metadata><link rel="extra-stylesheet" href="https://blog.geothings.ch/skins/mint.css?h=504215cf6bc10586b487" /><title>geothings - tiles</title>
        <subtitle>spatial data | open source | oversharing</subtitle>
    <link href="https://blog.geothings.ch/tags/tiles/atom.xml" rel="self" type="application/atom+xml"/>
    <link href="https://blog.geothings.ch/tags/tiles/" rel="alternate" type="text/html"/>
    <generator uri="https://www.getzola.org/">Zola</generator><updated>2024-02-02T00:00:00+00:00</updated><id>https://blog.geothings.ch/tags/tiles/atom.xml</id><entry xml:lang="en">
        <title>PMTiles exploration</title>
        <published>2024-02-02T00:00:00+00:00</published>
        <updated>2024-02-02T00:00:00+00:00</updated>
        <author>
            <name>jujube</name>
        </author>
        <link rel="alternate" href="https://blog.geothings.ch/blog/pmtiles-introduction/" type="text/html"/>
        <id>https://blog.geothings.ch/blog/pmtiles-introduction/</id>
        
            <content type="html">&lt;p&gt;It’s a technology that I came across rather recently. Tile generation when maintaining a geographic oriented website can be a hassle: it can take time, generates a lot of files, and can be a critical process. PMTiles might have the potential to facilitate some of this work and we’ll try to see how.&lt;/p&gt;
&lt;h2 id=&quot;what-are-pmtiles&quot;&gt;What are PMTiles?&lt;/h2&gt;
&lt;p&gt;In itself, PMTiles is a specification for building single-file tile pyramids. It’s open source and part of a larger project called &lt;a rel=&quot;external&quot; href=&quot;https://protomaps.com/&quot;&gt;Protomaps&lt;/a&gt;, and it aims at mapping the World, just that. The major difference with the kind of tiles that I know is that they are embedded as a single file, like the MBTile format, which make the interaction very intuitive, I mean we all get the idea of what a file is. But what does it bring compared to MBTiles? Well from the Protomaps website:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;A MBTiles file needs to be accessed as a SQLite database on disk, so requires a running server and disk storage for cloud hosting. &lt;strong&gt;PMTiles is designed to be cloud-native&lt;/strong&gt; and readable in fine-grained parts from remote storage like Amazon S3.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;It aims at simplifying the manipulation of tiles in a cloud native approach, for worldwide coverage.&lt;/p&gt;
&lt;h2 id=&quot;how-to-create-pmtiles&quot;&gt;How to create PMTiles?&lt;/h2&gt;
&lt;p&gt;The &lt;a rel=&quot;external&quot; href=&quot;https://docs.protomaps.com/pmtiles/create&quot;&gt;Protomaps website&lt;/a&gt; gives us some tools to create these tiles. Let’s try some possibilities.&lt;/p&gt;
&lt;h3 id=&quot;generate-pmtiles-using-gdal&quot;&gt;Generate PMTiles using GDAL&lt;/h3&gt;
&lt;p&gt;Our &lt;a rel=&quot;external&quot; href=&quot;https://www.geothings.ch/posts/gdal-appreciation/&quot;&gt;Swiss Army Knife&lt;/a&gt; is back, starting version 3.8.0 GDAL has native support for PMTiles, so let’s try that.&lt;/p&gt;
&lt;p&gt;First check the GDAL version you’re using, you’ll want 3.8.0 or higher:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;gdalinfo&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; --version&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;--&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; GDAL 3.8.3, released 2024/01/04&lt;/span&gt;&lt;span&gt; (debug&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; build&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let’s start from an OSM &lt;code&gt;.pbf&lt;/code&gt; file (see &lt;a rel=&quot;external&quot; href=&quot;https://www.geothings.ch/posts/vector-tiles-with-martin/#downloading-some-data&quot;&gt;Serving vector tiles with Martin&lt;/a&gt;). To convert this file into a PMTiles file you can enter:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;ogr2ogr&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; -f PMTiles out.pmtiles switzerland-latest.osm.pbf&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The process might take some time if you’re working on a large dataset. By default the MAXZOOM is 5, which is rather low, so the run shouldn’t take to long, but if you start to increase the parameter to around 15, which allows to represent data from much closer, processing time increases.&lt;/p&gt;
&lt;p&gt;But once the command is done, well that’s it!&lt;/p&gt;
&lt;p&gt;Alternatively we can use &lt;a rel=&quot;external&quot; href=&quot;https://github.com/felt/tippecanoe&quot;&gt;tippecanoe&lt;/a&gt; to achieve the same result.&lt;/p&gt;
&lt;h3 id=&quot;generate-pmtiles-using-tippecanoe&quot;&gt;Generate PMTiles using tippecanoe&lt;/h3&gt;
&lt;div class=&quot;admonition warning&quot;&gt;
&lt;div class=&quot;admonition-icon admonition-icon-warning&quot;&gt;&lt;/div&gt;
&lt;div class=&quot;admonition-content&quot;&gt;
&lt;strong class=&quot;admonition-title&quot;&gt;WARNING&lt;/strong&gt;
&lt;p&gt;Under construction&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&quot;visualize-pmtiles&quot;&gt;Visualize PMTiles&lt;/h2&gt;
&lt;p&gt;The easiest way is to go to the &lt;a rel=&quot;external&quot; href=&quot;https://protomaps.github.io/PMTiles/&quot;&gt;PMTiles Viewer Page&lt;/a&gt; and upload your newly created PMTiles file.&lt;/p&gt;
&lt;p&gt;Obviously you can add it to your custom project. The easiest way of doing is by using the Leaflet plugin &lt;a rel=&quot;external&quot; href=&quot;https://github.com/protomaps/protomaps-leaflet&quot;&gt;protomaps-leaflet&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Starting from complete scratch you can create an &lt;code&gt;.html&lt;/code&gt; file with the following content:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;html&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-9&quot;&gt;&amp;lt;!DOCTYPE&lt;/span&gt;&lt;span class=&quot;z-10&quot;&gt; html&lt;/span&gt;&lt;span class=&quot;z-9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-1&quot;&gt;    &amp;lt;&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;meta&lt;/span&gt;&lt;span class=&quot;z-10&quot;&gt; charset&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-1&quot;&gt;    &amp;lt;&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;meta&lt;/span&gt;&lt;span class=&quot;z-10&quot;&gt; name&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;&amp;quot;viewport&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-10&quot;&gt; content&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;&amp;quot;width=device-width, initial-scale=1&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-1&quot;&gt;    &amp;lt;&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;link&lt;/span&gt;&lt;span class=&quot;z-10&quot;&gt; rel&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;&amp;quot;stylesheet&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-10&quot;&gt; href&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;&amp;quot;https://unpkg.com/leaflet@1.7.1/dist/leaflet.css&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-1&quot;&gt;    &amp;lt;&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;z-10&quot;&gt; src&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;&amp;quot;https://unpkg.com/leaflet@1.7.1/dist/leaflet.js&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-1&quot;&gt;    &amp;lt;&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;z-10&quot;&gt; src&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;&amp;quot;https://unpkg.com/protomaps-leaflet@latest/dist/protomaps-leaflet.min.js&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-1&quot;&gt;    &amp;lt;&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3&quot;&gt;        body&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;        #&lt;/span&gt;&lt;span class=&quot;z-10&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3&quot;&gt;            height&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-14&quot;&gt; 100&lt;/span&gt;&lt;span class=&quot;z-9&quot;&gt;vh&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3&quot;&gt;            margin&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-14&quot;&gt; 0&lt;/span&gt;&lt;span class=&quot;z-9&quot;&gt;px&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;lt;&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-1&quot;&gt;    &amp;lt;&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;h2&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span&gt;Hey I&amp;#39;m a custom page&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;h2&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-1&quot;&gt;    &amp;lt;&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span&gt;Let&amp;#39;s add some Leaflet and PMTiles.&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-1&quot;&gt;    &amp;lt;&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;z-10&quot;&gt; id&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;&amp;quot;map&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-1&quot;&gt;    &amp;lt;&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-9&quot;&gt;        let&lt;/span&gt;&lt;span&gt; PAINT_RULES&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt; =&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;            {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                dataLayer&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; &amp;quot;multipolygons&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-4 z-i&quot;&gt; //here we render only one layer, check your layers names &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                symbolizer&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-9 z-b&quot;&gt; new&lt;/span&gt;&lt;span&gt; protomapsL&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;PolygonSymbolizer&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;{&lt;/span&gt;&lt;span&gt; fill&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; &amp;quot;steelblue&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt; }&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;            }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        ]&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-9&quot;&gt;        const&lt;/span&gt;&lt;span&gt; map&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-14&quot;&gt; L&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;map&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;&amp;#39;map&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;setView&lt;/span&gt;&lt;span&gt;([&lt;/span&gt;&lt;span class=&quot;z-14&quot;&gt;46.5&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-14&quot;&gt; 6.6&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-14&quot;&gt; 13&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;z-4 z-i&quot;&gt; //chose a view that suits you&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-9&quot;&gt;        var&lt;/span&gt;&lt;span&gt; osm&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-14&quot;&gt; L&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;tileLayer&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;&amp;#39;https://tile.openstreetmap.org/{z}/{x}/{y}.png&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;, {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            maxZoom&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-14&quot;&gt; 19&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            attribution&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; &amp;#39;&amp;amp;copy; &amp;lt;a href=&amp;quot;http://www.openstreetmap.org/copyright&amp;quot;&amp;gt;OpenStreetMap&amp;lt;/a&amp;gt;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;        }&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;addTo&lt;/span&gt;&lt;span&gt;(map)&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-9&quot;&gt;        var&lt;/span&gt;&lt;span&gt; layer&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt; =&lt;/span&gt;&lt;span&gt; protomapsL&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;leafletLayer&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;            {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                url&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; &amp;#39;http://127.0.0.1:8080/your_pmtile_file.pmtiles&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                paint_rules&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;:&lt;/span&gt;&lt;span&gt; PAINT_RULES&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;            }&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;addTo&lt;/span&gt;&lt;span&gt;(map)&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;lt;&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For testing purposes you might have to serve you PMTiles through http. To do so you can do as the Protomaps website suggests:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;npm&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; install -g http-server&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4 z-i&quot;&gt;# Then from the folder containing your PMTiles.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;http-server&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; . --cors&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Open your &lt;code&gt;.html&lt;/code&gt; file on the browser of your choice and you should see the map with your PMTiles displayed.&lt;/p&gt;
&lt;h2 id=&quot;when-should-pmtiles-be-used&quot;&gt;When should PMTiles be used?&lt;/h2&gt;
&lt;p&gt;Again, the documentation on &lt;a rel=&quot;external&quot; href=&quot;https://protomaps.com/faq&quot;&gt;Protomaps website&lt;/a&gt; is quite complete and gives us some insights.&lt;/p&gt;
&lt;h3 id=&quot;cloud-hosting&quot;&gt;Cloud hosting&lt;/h3&gt;
&lt;p&gt;PMTiles are stored as a single file, and compression is so efficient that the size is ridiculous compared to classic png tiles. Number of requests necessary is drastically reduced and thus the cost of operation as well.&lt;/p&gt;
&lt;h3 id=&quot;static-data&quot;&gt;Static data&lt;/h3&gt;
&lt;p&gt;PMTiles don’t support localized updates so each time you’ll need to apply an update, the whole file needs to be rewritten. If your data don’t change that much PMTiles are a wise choice, but If you need to have a more dynamic rendering the documentation recommends PostGIS with the &lt;a rel=&quot;external&quot; href=&quot;https://postgis.net/docs/ST_AsMVT.html&quot;&gt;ST_As_MVT()&lt;/a&gt; function.&lt;/p&gt;
&lt;h3 id=&quot;simplicity&quot;&gt;Simplicity&lt;/h3&gt;
&lt;p&gt;Here it’s more like a feeling about the philosophy of the specification. You have a single file, accessible without introduced complexity, directly from a library like Leaflet, which itself has &lt;em&gt;simplicity&lt;/em&gt; as one of its core objectives. It looks like one of those project that allows you to make complicated-looking things so easily. I guess it’s a sign of a good project.&lt;/p&gt;
&lt;h2 id=&quot;final-words&quot;&gt;Final words&lt;/h2&gt;
&lt;p&gt;Well it was rather easy to discover. I mean we create a file, we basically load it within a project and we’re good to go. Obviously there are some customizations to do with styling and labels etc. But once you have the starting point and your tools, it takes minutes to create what you desire.&lt;/p&gt;
&lt;p&gt;Here we’re just scratching the surface, remains to explore filtering, styling etc. But the concept in itself and the unreasonable performance of the compression make it very interesting if you’re in the situation where PMTiles could give you an advantage; the file created for OSM data Switzerland, with zooms from 0 to 14, is around 1GB, it costs pennies to upload and host on cloud services.&lt;/p&gt;
&lt;p&gt;It’s a project to support and look for, I guess?&lt;/p&gt;
</content>
        <summary type="html">Messing around with something I never used, have some pmtiles.</summary>
        </entry><entry xml:lang="en">
        <title>Serving vector tiles with Martin</title>
        <published>2023-12-20T00:00:00+00:00</published>
        <updated>2023-12-20T00:00:00+00:00</updated>
        <author>
            <name>jujube</name>
        </author>
        <link rel="alternate" href="https://blog.geothings.ch/blog/vector-tiles-with-martin/" type="text/html"/>
        <id>https://blog.geothings.ch/blog/vector-tiles-with-martin/</id>
        
            <content type="html">&lt;p&gt;There are some amazing tools out there, and they are getting build fast. I haven’t had the opportunity to work with vector tiles during my day-to-day jobs, but I wanted to explore what it is and how to set some things up, just for the fun of it. We’ll see here how to start using &lt;a rel=&quot;external&quot; href=&quot;https://github.com/maplibre/martin&quot;&gt;Martin&lt;/a&gt;, a vector tile server built in Rust serving PostGIS data.&lt;/p&gt;
&lt;h2 id=&quot;vector-tiles&quot;&gt;Vector tiles&lt;/h2&gt;
&lt;p&gt;The standard has been set by &lt;a rel=&quot;external&quot; href=&quot;https://www.mapbox.com/&quot;&gt;Mapbox&lt;/a&gt;. In the same manner a WMTS serves raster tiles, vector tiles allow for the visualization of large volumes of data over the web, but as their name suggests, they are vectors.&lt;/p&gt;
&lt;p&gt;It comes with some advantages compared to raster formats:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;It’s significantly lighter, about 20 to 50% of its raster equivalent according to &lt;a rel=&quot;external&quot; href=&quot;https://documentation.maptiler.com/hc/en-us/articles/4411234458385-Raster-vs-Vector-Map-Tiles-What-Is-the-Difference-Between-the-Two-Data-Types-&quot;&gt;MapTiler&lt;/a&gt;. Vector data are series of points and each pixel of the map doesn’t have to have information declared; a rectangle polygon covering thousands of square kilometers can still be defined with 4 points.&lt;/li&gt;
&lt;li&gt;It is stylized dynamically. While raster tiles need to be generated with their style embedded, vector tiles style can just be modified on the fly, without going through the laborious process of tiles generation that can take easily several hours/days.&lt;/li&gt;
&lt;li&gt;It’s fast. Moving through a vector tile map feels smooth, there is no apparent tile loading.&lt;/li&gt;
&lt;li&gt;What you request is what you get. You directly query the tiles, not some sort of other service along your tiles.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;It’s an amazing standard to visualize spatial data in a web map. Obviously it’s not suitable for all kinds of data, you have to have discrete data that make sense to be visualized as vector; I doubt that raw satellites images as vector tiles are a good idea.&lt;/p&gt;
&lt;h2 id=&quot;installing-postgresql-and-postgis&quot;&gt;Installing PostgreSQL and PostGIS&lt;/h2&gt;
&lt;p&gt;First thing first, we need to store data somewhere. Martin is designed to be used with PostGIS, PMTiles and MBTiles, we’ll explore the PostGIS alternative.&lt;/p&gt;
&lt;p&gt;The following commands were used on an Ubuntu distribution.&lt;/p&gt;
&lt;p&gt;Let’s start by installing PostgreSQL:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;apt&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; install postgresql&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then the PostGIS extension:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;apt&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; install postgis&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We’ll already set things up in the database by creating a dedicated user, creating a database and creating the PostGIS extension in there. From psql, create a user:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;sql&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-9&quot;&gt;create user&lt;/span&gt;&lt;span class=&quot;z-3 z-i&quot;&gt; martin_usr&lt;/span&gt;&lt;span class=&quot;z-9&quot;&gt; with password&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; &amp;#39;my_password&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Create a database:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;sql&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-9&quot;&gt;create database&lt;/span&gt;&lt;span class=&quot;z-3 z-i&quot;&gt; martin_db&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Go to your new database (&lt;code&gt;\c martin_db&lt;/code&gt;) and create the extension:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;sql&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-9&quot;&gt;create&lt;/span&gt;&lt;span&gt; extension postgis;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We won’t cover here the more extensive tuning of the database. You should be set on the database side for this example.&lt;/p&gt;
&lt;h2 id=&quot;downloading-some-data&quot;&gt;Downloading some data&lt;/h2&gt;
&lt;p&gt;Obviously you’ll want some data to serve as vector tiles. In a production environment you’ll probably want to serve your own data, so this step would probably not be necessary. For the example we don’t have any data yet, so we’ll use some from osm through &lt;a rel=&quot;external&quot; href=&quot;https://download.geofabrik.de/&quot;&gt;GeoFabrik&lt;/a&gt;. Since I’m in Switzerland, let’s download data over the country:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;curl&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; https://download.geofabrik.de/europe/switzerland-latest.osm.pbf -O&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We are using &lt;code&gt;osm2pgsql&lt;/code&gt; to import data into the database, so the &lt;code&gt;.pbf&lt;/code&gt; format is ideal.&lt;/p&gt;
&lt;p&gt;You can then load your data (&lt;code&gt;apt install osm2pgsql&lt;/code&gt; if you don’t have the tool):&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;osm2pgsql&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; -d martin_db -U martin_usr switzerland-latest.osm.pbf&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We now have osm data over a whole country, easy right?&lt;/p&gt;
&lt;h2 id=&quot;now-install-martin&quot;&gt;Now install Martin&lt;/h2&gt;
&lt;p&gt;Here comes the best part, the vector tile server itself. There are multiple ways to start working with Martin, we’ll use rust and its package manager &lt;a rel=&quot;external&quot; href=&quot;https://doc.rust-lang.org/book/ch01-03-hello-cargo.html&quot;&gt;cargo&lt;/a&gt;. If you don’t want to install those on your server you might prefer the &lt;a rel=&quot;external&quot; href=&quot;https://maplibre.org/martin/run-with-docker.html&quot;&gt;Docker installation&lt;/a&gt;, or simply using binaries.&lt;/p&gt;
&lt;p&gt;As said earlier, Martin is build in rust, and it’s accessible as a crate using cargo. You can first &lt;a rel=&quot;external&quot; href=&quot;https://www.rust-lang.org/tools/install&quot;&gt;install rust&lt;/a&gt;:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;curl&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; --proto &amp;#39;=https&amp;#39; --tlsv1.2 -sSf https://sh.rustup.rs&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt; |&lt;/span&gt;&lt;span class=&quot;z-3 z-i&quot;&gt; sh&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then install Martin:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;cargo&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; install martin&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;martin&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; --help&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And that’s it! Martin’s here.&lt;/p&gt;
&lt;h2 id=&quot;can-t-be-that-simple-right&quot;&gt;Can’t be that simple right?&lt;/h2&gt;
&lt;p&gt;Finally, you can run your new server:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;martin&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; &amp;quot;postgresql://martin_usr:my_password@localhost:5432/martin_db&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Martin can discover geometric tables in the database from the given url, so by default everything is served. So yes it can be that simple! Obviously environment variables need to be set, passwords hidden etc. But you have an idea of the process.&lt;/p&gt;
&lt;p&gt;You can try by yourself reading the catalog:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;curl&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; http://0.0.0.0:3000/catalog&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt; |&lt;/span&gt;&lt;span class=&quot;z-3 z-i&quot;&gt; json_pp&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;json&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;   &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;fonts&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;&amp;quot; : {},&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;   &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;sprites&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;&amp;quot; : {},&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;   &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;tiles&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;&amp;quot; : {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;      &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;planet_osm_line&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;&amp;quot; : {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;         &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;content_type&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;&amp;quot; :&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; &amp;quot;application/x-protobuf&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;         &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;&amp;quot; :&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; &amp;quot;public.planet_osm_line.way&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;      },&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;      &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;planet_osm_point&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;&amp;quot; : {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;         &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;content_type&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;&amp;quot; :&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; &amp;quot;application/x-protobuf&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;         &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;&amp;quot; :&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; &amp;quot;public.planet_osm_point.way&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;      },&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;      &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;planet_osm_polygon&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;&amp;quot; : {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;         &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;content_type&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;&amp;quot; :&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; &amp;quot;application/x-protobuf&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;         &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;&amp;quot; :&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; &amp;quot;public.planet_osm_polygon.way&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;      },&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;      &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;planet_osm_roads&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;&amp;quot; : {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;         &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;content_type&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;&amp;quot; :&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; &amp;quot;application/x-protobuf&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;         &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;&amp;quot; :&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; &amp;quot;public.planet_osm_roads.way&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;      }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;   }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&quot;visualize-data-using-qgis&quot;&gt;Visualize data using QGIS&lt;/h2&gt;
&lt;p&gt;Once the server is running we can easily visualize our data in a client. Starting QGIS 3.14,&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Layer&lt;/em&gt; &amp;gt; &lt;em&gt;Add Layer&lt;/em&gt; &amp;gt; &lt;em&gt;Add Vector Tile Layer&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;And enter the url then &lt;em&gt;OK&lt;/em&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;http://localhost:3000/planet_osm_line,planet_osm_point,planet_osm_polygon/{z}/{x}/{y}&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.geothings.ch/blog/vector-tiles-with-martin/add-vector-tiles.png&quot; alt=&quot;add-vector-tiles&quot; /&gt;&lt;/p&gt;
&lt;p&gt;You should see a rather absurd amount of data.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.geothings.ch/blog/vector-tiles-with-martin/visualization.png&quot; alt=&quot;visualization&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;to-conclude&quot;&gt;To conclude&lt;/h2&gt;
&lt;p&gt;Here is how to get started with Martin, a rust vector tile server. It’s just the start, we don’t cover here the creation of symbology and more in depth configurations and optimization, but it gives an idea of how easy and powerful such a tool can be.&lt;/p&gt;
</content>
        <summary type="html">Vector tiles seems nice, let&#39;s see who&#39;s Martin.</summary>
        </entry>
</feed>
