<?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 Jan Rozklad on Medium]]></title>
        <description><![CDATA[Stories by Jan Rozklad on Medium]]></description>
        <link>https://medium.com/@rozklad?source=rss-4ed68c9a1563------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*EsLQlDyVY0GqGgVp32Q4jg.jpeg</url>
            <title>Stories by Jan Rozklad on Medium</title>
            <link>https://medium.com/@rozklad?source=rss-4ed68c9a1563------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 21:33:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rozklad/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[Shapefile .shp to GeoJSON]]></title>
            <link>https://medium.com/bitterend/shapefile-shp-to-geojson-896b2b27f2d3?source=rss-4ed68c9a1563------2</link>
            <guid isPermaLink="false">https://medium.com/p/896b2b27f2d3</guid>
            <category><![CDATA[geojson]]></category>
            <category><![CDATA[shapefile]]></category>
            <category><![CDATA[mapbox]]></category>
            <category><![CDATA[google-maps]]></category>
            <category><![CDATA[geography]]></category>
            <dc:creator><![CDATA[Jan Rozklad]]></dc:creator>
            <pubDate>Sat, 21 Apr 2018 10:21:39 GMT</pubDate>
            <atom:updated>2018-04-21T10:21:39.597Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*UuknZRr_OrbNxGAoDSt3eQ.png" /><figcaption>Shapefile to GeoJSON</figcaption></figure><p>Let’s say you have data in <a href="https://en.wikipedia.org/wiki/Shapefile">Shapefile</a> format which typically comes in multiple files:</p><ul><li><strong>.shp </strong>— feature geometry</li><li><strong>.shx </strong>— shape index</li><li>.<strong>dbf </strong>— attribute data</li></ul><p>In our <a href="https://medium.com/bitterend/international-migrant-stock-map-75826d094ce0">latest case</a> we initially downloaded lot of map data from <a href="http://www.naturalearthdata.com/">Natural Earth</a> to build interactive layer of countries. Data we started with looked like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*Cf2y6WSSqUtCScR6LeQODQ.png" /><figcaption>Shapefile Explorer view of Natural Earth</figcaption></figure><p>Now, you need to convert the data to <a href="http://geojson.org/">GeoJSON</a> in order to use them with libraries/services such as <a href="https://www.mapbox.com/">Mapbox</a> or <a href="https://developers.google.com/maps/documentation/javascript/datalayer">Google Maps</a>.</p><p>We will use ogr2ogr to convert Shapefile to GeoJSON. It is part of <a href="http://www.gdal.org/">GDAL</a> package, install that using from the site’s download or using homebrew brew install gdal</p><p>Now to finally convert data, run following command:</p><pre>ogr2ogr -f GeoJSON -t_srs EPSG:4326 -lco COORDINATE_PRECISION=3 output.geojson input.shp</pre><p>Where</p><ul><li>f — GeoJSON — stands for output file format GeoJSON</li><li>t_srs EPSG:4326— reproject to <a href="http://spatialreference.org/ref/epsg/wgs-84/">EPSG:4326</a></li><li>lco COORDINATE_PRECISION=3 — define precision of geometry</li></ul><p>For more information about different options and params see the <a href="http://www.gdal.org/ogr2ogr.html">official documentation</a>.</p><p>And that’s it. The newly created file now contains GeoJSON representation of our Shapefile.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*APnjpbYjUFCkGwPaQHM-cA.png" /><figcaption>Gist preview of GeoJSON</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=896b2b27f2d3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/bitterend/shapefile-shp-to-geojson-896b2b27f2d3">Shapefile .shp to GeoJSON</a> was originally published in <a href="https://medium.com/bitterend">bitterend</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[International migrant stock map]]></title>
            <link>https://medium.com/bitterend/international-migrant-stock-map-75826d094ce0?source=rss-4ed68c9a1563------2</link>
            <guid isPermaLink="false">https://medium.com/p/75826d094ce0</guid>
            <category><![CDATA[mapbox]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[migration]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Jan Rozklad]]></dc:creator>
            <pubDate>Fri, 06 Apr 2018 11:01:34 GMT</pubDate>
            <atom:updated>2018-04-06T11:45:40.946Z</atom:updated>
            <content:encoded><![CDATA[<p>Since late 2015 i’ve been working with non-profit organizations to provide relevant data on the international migration topic. Since then projects like <a href="http://encyklopedie.org/">encyklopedie.org</a> were created.</p><p>We’ve tried approaching data visualization on map through multiple services/libraries and in the end we’ve ended up loving <a href="http://mapbox.com/">Mapbox</a>. So here started the journey for #mapmadness18 submission.</p><p>Live demo of the map is found on <a href="https://codepen.io/rozklad/full/xWyaxO/">Codepen</a>.</p><h3>Goal</h3><ul><li>Provide unbiased, objective and comprehensive information about global migration of people.</li><li>Allow comparison of data in available time periods and eras</li><li>Show data in simple and interactive way</li></ul><h3>Data</h3><p>To start with the obvious choice of source was UN and it’s <a href="http://www.un.org/en/development/desa/population/migration/data/estimates2/estimates17.shtml">International migrant stock estimates by destination and origin</a>. Then, the project needed reliable geographical data about countries and their capitals (if available), that’s what can be found on <a href="http://www.naturalearthdata.com/">Natural Earth</a>.</p><p>UN dataset contains estimates of the international migrant stock by age, sex and origin for mid-point (1 July) of each year: 1990, 1995, 2000, 2005, 2010, 2015 and 2017. Detailed information about the dataset is found in <a href="http://www.un.org/en/development/desa/population/migration/data/estimates2/docs/MigrationStockDocumentation_2017.pdf">it’s documentation</a>.</p><p>For the purpose of this project, the dataset was enhanced with geographical information by pairing names of the countries with their geographical counterparts. That, amongst other things, involves transforming official names of countries to their simple names (e.g. Venezuela (Bolivarian Republic of) to Venezuela or Holy See to Vatican). The full result is geojson found on <a href="https://gist.github.com/rozklad/49d5ca8a7fbd0173e191820994448690">gist.github.com</a>.</p><h3>Technologies</h3><ul><li>Javascript (ECMA6)</li><li>Mapbox (using <a href="https://www.mapbox.com/mapbox-gl-js/api/">Mapbox GL JS</a>)</li><li><a href="http://turfjs.org/">Turf.js</a> (for scaling and manipulating geographical data)</li><li><a href="https://github.com/axios/axios">Axios</a> (HTTP client)</li><li><a href="https://github.com/gka/chroma.js/">Chroma.js</a> (color manipulations)</li></ul><h3>Map</h3><p>As a platform for visualization, there is a blank instance of Mapbox map.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cfa8cfc450dd810a3fbe481c40783c25/href">https://medium.com/media/cfa8cfc450dd810a3fbe481c40783c25/href</a></iframe><p>After map is loaded, project asks for data from gist through GET request using Axios library and creates two separate layers — one with countries themselves and another one (filtered) for hovering over countries.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7095a86cfa0d09714a1e8dd7261ecc8b/href">https://medium.com/media/7095a86cfa0d09714a1e8dd7261ecc8b/href</a></iframe><h3>Interactivity</h3><p>When user clicks, map should show origins of migration to selected country. It listens for click event and uses <a href="https://www.mapbox.com/mapbox-gl-js/example/queryrenderedfeatures/">queryRenderedFeatures</a> to find out which features was selected.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/de4bf1b0514a2fbca7334e508e2b76ea/href">https://medium.com/media/de4bf1b0514a2fbca7334e508e2b76ea/href</a></iframe><p>Separate functions loadCountry() and unloadCountry() handle logic behind showing the data. Basically they sort all origins of migration to selected country, limit that to Top 10, show list of them and draw lines between destination country and the origin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-kFleVK_lb1OmBJ3lQ7Tvg.png" /><figcaption>Monochromatic map showing migration Top 10 sources of Germany in 2017</figcaption></figure><p>Since UN provides historical data, it was natural to allow user to pick time period. For that purpose, there is a simple list of available periods at the very top of the map which uses selectYear() function to change displayed data.</p><h3>Colorization</h3><p>To give the map some colors and visually distinguish popularity of migration destination project uses <a href="https://www.mapbox.com/mapbox-gl-js/api/#map#setpaintproperty">setPaintProperty</a> set to categorical type of stops.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/47cad1e7ec244b78fee18110f846c0ae/href">https://medium.com/media/47cad1e7ec244b78fee18110f846c0ae/href</a></iframe><p>Color stops are defined by getColorStops() function which takes all migration data to individual countries and using Chroma.js applies quantile logic to create color scale.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f17c9d6d8b20c1b3338552381ccdddb7/href">https://medium.com/media/f17c9d6d8b20c1b3338552381ccdddb7/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KVBZalBnzwHhGScyaApX-g.png" /><figcaption>Colored map showing Top 10 migration sources of United Kingdom in 2005</figcaption></figure><h3>Conclusion</h3><p>For additional flavour, the map uses monospace font family and basic CSS animations. The whole project and it’s source code can be found on <a href="https://codepen.io/rozklad/full/xWyaxO/">Codepen</a>.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2Frozklad%2Fembed%2Fpreview%2FxWyaxO%3Fheight%3D600%26slug-hash%3DxWyaxO%26default-tabs%3Djs%2Cresult%26host%3Dhttps%3A%2F%2Fcodepen.io%26embed-version%3D2&amp;url=https%3A%2F%2Fcodepen.io%2Frozklad%2Fpen%2FxWyaxO&amp;image=https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fi.cdpn.io%2F168527.xWyaxO.small.1b349e42-dbae-40cc-ad82-b6afdfc09e9b.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/2bf8002b7226eef7a1a406d2018bf942/href">https://medium.com/media/2bf8002b7226eef7a1a406d2018bf942/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=75826d094ce0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/bitterend/international-migrant-stock-map-75826d094ce0">International migrant stock map</a> was originally published in <a href="https://medium.com/bitterend">bitterend</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>