How to convert KML, GPX and shapefiles to GeoJSON
If our extensive blueprints of the Projection, 3D and Marker map templates are not enough for your needs, you can easily upload your own GeoJSON and create your own map. What if your map regions are in shapefile (.shp) format, though? Fret not, as it is very easy to convert shapefiles into GeoJSON using the free an Mapshaper.org.
TIP: Struggling to find the right regions for your map? Check out our GeoJSON repository where we've sourced, checked, and resized various region files ready for you to download and use in Flourish.
In this article
Converting KML or shapefiles
To convert shapefiles to GeoJSON in order to use them in our map templates,
- Head over to your data source, if it lives online. For the purpose of this example, we will be making a map of Madagascar districts. We grabbed the zipped file containing various administrative regions.
TIP: If you're getting confused with all the different file options, look for SHP in the file name. Moreover, shapefiles often are offered zipped as they are complemented by various other files that contain additional optional information.
- Unzip your file. If you're using a Windows machine, you can use programs such as WinRAR, 7-Zip or WinZip. In this instance, we are unzipping only the files containing adm2, since this is the district level we want to visualize.
- Head over to mapshaper.org and import your data. They can either be loose files or a ZIP file. In this case, our ZIP file contains multiple shapefiles, so we opted for the former. You are able to upload only the .shp file or all of the additional ones for more information.
- If everything looks ok, choose the Export option in the top right corner and opt for GeoJSON.
TIP: The smaller file size, the better. If the exported file is over five megabytes, try simplifying it for quicker load times.
Import your GeoJSON file as described
here and voilà! You have a map of Madagascar districts.
TIP: In some cases, your map won't display even after exporting as a GeoJSON from Mapshaper. This is usually because your coordinate system isn't set to be WGS84. Head over to this help doc to learn how to make your coordinates WGS84.
Converting GPX files
A GPX file is a GPS data file saved in the GPS Exchange format, which is an open standard used by many GPS programs. It contains longitude and latitude location data that may include waypoints, routes, and tracks. You might want to use GPX data to visualize lines on a map. To bring your GPX data into Flourish, you'll need to transform it to GeoJSON using the following steps.