<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Vitor Sapucaia Fortunato on Medium]]></title>
        <description><![CDATA[Stories by Vitor Sapucaia Fortunato on Medium]]></description>
        <link>https://medium.com/@vsapucaia?source=rss-10fb014899a8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*mqeSdniUzEtDBp-l.</url>
            <title>Stories by Vitor Sapucaia Fortunato on Medium</title>
            <link>https://medium.com/@vsapucaia?source=rss-10fb014899a8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 20:44:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vsapucaia/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Mapbox challenge final round: from mapnik (raster) to mapbox studio (vector)]]></title>
            <link>https://medium.com/@vsapucaia/mapbox-challenge-final-round-from-mapnik-raster-to-mapbox-studio-vector-1390fc0af809?source=rss-10fb014899a8------2</link>
            <guid isPermaLink="false">https://medium.com/p/1390fc0af809</guid>
            <category><![CDATA[mapnik]]></category>
            <category><![CDATA[mapmadness18]]></category>
            <category><![CDATA[mapbox]]></category>
            <category><![CDATA[gis]]></category>
            <category><![CDATA[vector-tiles]]></category>
            <dc:creator><![CDATA[Vitor Sapucaia Fortunato]]></dc:creator>
            <pubDate>Fri, 06 Apr 2018 16:51:08 GMT</pubDate>
            <atom:updated>2018-04-06T16:51:08.683Z</atom:updated>
            <content:encoded><![CDATA[<p>The #mapmadness18 is a challenge made by <a href="https://medium.com/u/5691029a1e6a">Mapbox</a> so we can easily empower our maps with their tools. I’m taking this opportunity to do a proof of concept working with vector tiles because, at <a href="http://www.homeday.de/">Homeday</a> (the company I’m working for right now), we’re still using mapnik stack, which is super fast and reliable, to provide a huge amount of GIS data but it still is raster tiles.</p><h3>Homeday’s PreisAtlas</h3><p><a href="http://www.homeday.de/">Homeday</a>’s new and interactive <a href="http://www.homeday.de/preisatlas/de-DE">Preisatlas</a> provides a more transparent way to check prices for renting and buying properties. Try it now and compare prices all over Germany with just a few clicks:</p><p><a href="https://www.homeday.de/preisatlas/de-DE/berlin/friedrichstrasse+84,+10117?map_layer=standard&amp;marketing_type=rent&amp;property_type=apartment">Mitte, Berlin - Immobilienpreise | HOMEDAY-PREISATLAS</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1WGJd0KJ5DmqjHJCFQfLrA.png" /></figure><p>To end up with this beautiful product and proper price estimations, everything started by acquiring millions and millions of real estate properties to be sold and rented, trying to gather as many attributes as we can for each of these properties, not only internal attributes like number of rooms, square meters, and floor, but also external aspects that influence a lot on the price like proximity to restaurants, public transportation, gyms and so on. Everyone knows that location matters a lot to estimate prices, and this is why we are heavily using OSM data too.</p><p>We’ve spent months gathering, cleaning, merging, organizing and preparing the data to feed our machine learning models. To go in details about the machine learning process, refer to <a href="https://www.homeday.de/de/blog/funktion-preisatlas/">this article</a>, published by our Data Scientist, Artiom Kovnatsky. My job was to generate geo analysis and reports to be consumed by the machine earning models.</p><p>Then, we decided to go with the mapnik GIS stack to actually display the final results in terms of location:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/1*VC5oAk2xOFp84t3NI8wYMg.png" /></figure><p>This is working really well and fast. However, we know that vector tiles can deliver some great benefits to the user experience.</p><h3>Path to convert to Mapbox stack</h3><p>As a proof of concept to use Mapbox, I’ll be working only with a set of our geometries, containing blocks and buildings of Berlin with their final living quality value to be displayed on the map.</p><p>The first step to start using Mapbox Studio, and eventually Mapbox GL JS, is to convert the data from a PostGIS geo enabled table to a supported format that can be uploaded directly to the Studio. To do that:</p><ol><li>With ogr2gr, export the tables from PostGIS to a geojson file;</li><li>With Tippecanoe, convert the geojson file into a *.mbtiles file</li><li>upload the *.mbtiles to Mapbox Studio</li></ol><p>Everything gets harder when you have a large amount of data. This is why I’ve chosen to use <a href="https://www.mapbox.com/help/large-data-tippecanoe/">Tippecanoe</a>, which transforms and simplifies geo data into vector tiles tilesets, drastically reducing the storage space consumed. As we’re dealing with millions of buildings and blocks of buildings all over Germany, this is extremely important.</p><h4>1. ogr2ogr: from PostGIS to geojson file</h4><p>Tippecanoe will read a geojson to convert it into a .mbtiles format, which can be later uploaded directly to Mapbox Studio. I’ve used <a href="http://www.gdal.org/ogr2ogr.html">ogr2ogr</a> to do this:</p><pre>ogr2ogr -f GeoJSON blocks.json “PG:host=localhost dbname=x user=x password=x port=xxxx”</pre><h4>2. Tippecanoe: from geojson to mbtiles</h4><p>There are plenty options to create a mbtiles file with Tippecanoe, depending on how much you want to simplify, how many zoom levels you want to cover and so on. To learn more, check out Tippecanoe repository <a href="https://github.com/mapbox/tippecanoe">here</a>. In my case, I’m using these options:</p><pre>tippecanoe -o blocks.mbtiles --minimum-zoom=15 --maximum-zoom=18 --drop-densest-as-needed blocks.json</pre><h4>3. Mapbox Studio: creating new Tilesets</h4><p>With the .mbtiles file it is super easy to upload it through Mapbox Studio and create a Tileset. While logged on the Studio, inside the Tilesets tab there is a button “New tileset” which will let upload it.</p><h3>Mapbox Studio setup</h3><ol><li>I’ve chosen the “Bright” style to start customizing my own map:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*anFN5Go88SB-e-_N99_QfA.png" /></figure><p>2. Then, I added my fresh new vector tiles blocks layer. If you have an uploaded Tileset available, it will be displayed here:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*WQMQxbs-LY_Mhhc63ig5Ew.png" /></figure><p>3. And finally, I’ve defined some rules to give color to my new layer, considering the living quality level of each block:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*dF5YDLqHU0Ti_XjLbKSEBQ.png" /></figure><p>4. Yayyyyyy! Vector Tiles!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.useloom.com%2Fembed%2Fc9c8c920fe144b83bef77554c690d175&amp;url=https%3A%2F%2Fwww.useloom.com%2Fshare%2Fc9c8c920fe144b83bef77554c690d175&amp;image=https%3A%2F%2Fcdn.useloom.com%2Fsessions%2Fthumbnails%2Fc9c8c920fe144b83bef77554c690d175-00001.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=useloom" width="1280" height="800" frameborder="0" scrolling="no"><a href="https://medium.com/media/a71ad8277b24a61d63536f26d6a4afec/href">https://medium.com/media/a71ad8277b24a61d63536f26d6a4afec/href</a></iframe><h3>Mapbox GL JS: consuming the service</h3><p>I’ve started with a simple service:</p><pre>&lt;script&gt;<br>  mapboxgl.accessToken = &quot;XXXX&quot;;<br><br>  <strong>var </strong>map = <strong>new </strong>mapboxgl.Map({<br>    container: &quot;map&quot;,<br>    style: &quot;mapbox://styles/homeday-maps/xxx&quot;,<br>    zoom:11,<br>    center: [13.397640, 52.520637]<br>  });<br>&lt;/script&gt;</pre><p>Then, I thought it would be nice to have a heatmap of some current properties available for rent in Berlin. So once again I’ve created a geojson of the properties to load them by on-the-fly and used the mapbox GL JS heatmap layer:</p><pre>// ...</pre><pre>map.on(&#39;load&#39;, <strong>function</strong>() {<br>  // Add a geojson point source.<br>  // Heatmap layers also work with a vector tile source.<br>  map.addSource(&#39;properties&#39;, {<br>    &quot;type&quot;: &quot;geojson&quot;,<br>    &quot;data&quot;: &quot;props.geojson&quot;<br>  });<br><br>  map.addLayer({<br>    &quot;id&quot;: &quot;properties-heat&quot;,<br>    &quot;type&quot;: &quot;heatmap&quot;,<br>    &quot;source&quot;: &quot;properties&quot;,<br>    &quot;maxzoom&quot;: 14,<br>    &quot;paint&quot;: {</pre><pre>// ...</pre><p>The code above is just a sample. <a href="https://www.mapbox.com/mapbox-gl-js/example/heatmap-layer/">Here’s the complete tutorial to use the heatmap function.</a></p><p>And this is the final result:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.useloom.com%2Fembed%2F29b70c5770744ebc8a39daa0dc855e11&amp;url=https%3A%2F%2Fwww.useloom.com%2Fshare%2F29b70c5770744ebc8a39daa0dc855e11&amp;image=https%3A%2F%2Fcdn.useloom.com%2Fsessions%2Fthumbnails%2F29b70c5770744ebc8a39daa0dc855e11-00001.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=useloom" width="1280" height="800" frameborder="0" scrolling="no"><a href="https://medium.com/media/0fbe2781212db9c55d7ef417fef9ffc1/href">https://medium.com/media/0fbe2781212db9c55d7ef417fef9ffc1/href</a></iframe><p><a href="https://github.com/vsapucaia/basic_mapbox_gl_viewer/">You can check the project GitHub repository here.</a></p><h3>Mapbox Vector Tiles benefits</h3><p>The benefits of Vector Tiles are gigantic. They load faster, zoom levels are seemless, and it’s possible to change their style on-the-fly, which is awesome.</p><h3>To be continued…</h3><p>The next challenge would be converting everything into a compatible vector tiles structure. As we’re dealing with a large data set, maybe it makes sense to split everything into smaller pieces, separating the data into regions (cities?) and having many .mbtiles to be uploaded to Mapbox Studio. It’s very promising and I’m excited to continue the challenge, even after the end of the #mapmadness18.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1390fc0af809" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>