Different ways to convert Shapefile to GeoJSON – Online or Offline or API



Different ways to convert Shapefile to GeoJSON - Online or Offline or API

Convert Shapefile to GeoJSON. Shapefile, ESRI made a standard vector file format which is largely adopted in the field of GIS by programmers and geographers . While GeoJSON is also an open standard format designed for Web which largely supported with GIS JavaScript API, other programming API and with GIS (Geographic Information System) software tools too, for easily rendering. GeoJSON is based on JavaScript Object Notation. Here we will explore different methods to convert the files online, or offline or with the help of API which programmers can make use of.

Convert shapefile to geojson

You may be interested to refer following articles:

Different ways to convert Shapefile to GeoJSON

I.) Online Method : Convert Shapefile to GeoJSON:

The simplest and fast way to access the internet is through the online method, as you don’t need to install and configure any tool on your PC. Just drag the Shapefile files, one click on button and convert to GeoJSON. There are many website which provides the tool to convert the files by browsing them to server side and convert and also some client side conversion too. Lets explore the list, which is only client side as client side conversion will secure your file and doesn’t take your data pack for uploading the file:

A.) MAPOG Converter Tool :

IGIS Map tool is one stop solution for all GIS data analysis and conversion.

 Shapefile to Geojson Conversion

  •  Go to the tool MapOG Converter Tool.
  •  If you are already registered then login otherwise sign up.
  • Once get register tap on Converter Button Shown in figure.

Convert shapefile to geojson

  • Upload the Shapefile from data set or Google Drive or Drop Box or already added in drive then choose the file. Lets we want to convert already uploaded file from My Drive then select the file.

Convert shapefile to geojson

  • Tap the file and new window will appear shown below.

Convert shapefile to geojson

  • Select the desired Output in our case choose Geojson. You can also change CRS. Now tap on Convert file button.

Convert shapefile to geojson

  • It will so the table in the next step. You can directly download the converted file or you can check it through clicking on publish button.

Convert shapefile to geojson

  • Below is the screen of published Geojson file.

Convert shapefile to geojson

Whole process is same from new uploaded file from data set or from google drive or from drop box. If you face any problem ping us at website.

You might be interested in Query on Geojson data file then try our tool IGIS Map tool.

This is presented by Engineer Philosophy pvt. ltd, working in GIS Sector an IT company. What you need to do is to just Register, login and upload only .shp and .dbf file and then export the uploaded layer to GeoJSON file by just selecting the option which appear at upper right corner in Navigation bar. You can also explore the attribute table from the website directly and filter the same which no other online tool provides.

different ways to convert Shapefile to Geojson - Online or Offline or API
different ways to convert Shapefile to Geojson – Online or Offline or API

Not only this, but you can classify the Map according to the shapefile dbf attributes and automatically classify and color it. The classified map can be exported as Scalable Vector Graphics i.e svg file.

Disclaimer: The above project is handled by me and my team and the project is in beta phase while you can definetly convert the shapefile to GeoJSON at client side securing your shapefile data. I would welcome your suggestion to improve the tool by commenting below or contacting me.

B.) Map Shapper : 

Map Shapper is the best tool which we should refer first. It is the best online tool which also handles large shapefiles and renders it quickly. Its an open source project and is licensed under MPL 2.0. Just drag the shapefile or zipped shapefile which will render the shapefile on map and can be further exported as geojson file with the option provided in tool itself.

different ways to convert Shapefile to Geojson - Online or Offline or API

With No doubt Map Shaper is much more better than any other tool for now, while the only reason why I placed this tool in second place just because the first tool was my own tool which provides more option for classifying the map, see all attributes in the data table and also exported as svg file.

2.) Offline Method – Convert Shapefile to GeoJSON in QGIS:

You must have installed QGIS  (Quantum GIS) before performing the provided steps. You may also look over other tutorial in QGIS.

1.) Open QGIS Desktop and Select Layer -> Add Layer -> Add Vector Layer or click on Add Vector layer icon appears at the upper left in the application.

different ways to convert Shapefile to Geojson - Online or Offline or API
different ways to convert Shapefile to Geojson – Online or Offline or API

2.) Select the zipped shapefile or any of file i.e .shp or .dbf or .shx by browing the folder. Note, that all the three files i.e .shp, .dbf and .shx file should be present in the same foder with same name.

3.) Once uploaded, the map will be rendered and showed in QGIS application. Now navigate to Layer menu and select Save As option or just from the layers panel select the layer and right click from it to select Save As option.

4.) A window pop up will opne up. From the window just select the GeoJSON format and provide the name of the file in the input box as shown in the image provided below. Save the file. It will export the file in GeoJSON format.

different ways to convert Shapefile to Geojson - Online or Offline or API

3.) Offline Method – Convert Shapefile to GeoJSON with command line ogr2ogr tool:

Firstly you need to install an ogr2ogr tool of GDAL which is a GIS utlitly command line tool so as to convert one file to another. Now if the ogr2ogr is installed globally check by simple tying the ogr2ogr in command line if it is working or not. Or if it residing in some file system you need to navigate to ogr2ogr file and type in the same in command line. Now Just type in the following:

  • “ogr2ogr -f GeoJSON -t_srs crs:84 [name].geojson [name].shp”

To get more option list and format you may see this gdal org link.

This tool will be helpful if you want to convert bulk files from shapefile to geojson. You can refer the .sh script found at github.

4.) Convert Shapefile to GeoJSON -API or library:

Shapefile is a binary file and cannot be viewed directly in notepad or textpad as like with GeoJSON file. So if you want to create your own API, to convert Shapefile to GeoJSON you should first have a knowledge of how to read the binary shapefile. You may refer to some of the articles which I have written some post which would help you to get the basic knowledge to know the format of files and read.

You may further refer to some of the best Shapefile to GeoJSON converter API which is open source project:

https://github.com/wavded/js-shapefile-to-geojson :  This is dedicated library to convert to GeoJSON, created by Marc Harter and Licensed with MIT.

https://github.com/gipong/shp2geojson.js : This library is also MIT Licensed and is inspired by the above wavded library which uploads zipped file of shapefile. The library provided an example to use with leaflet js.

https://github.com/mbloch/mapshaper : Map Shaper as desricbed above is licensed under MPL 2.0 and can be very useful if you want to convert to GeoJSON as well as TopoJSON.

Hope this article helped you. If are facing some problem in converting the shapefile to geojson do comment below with the problem statement. We will definitely look over that. Also you can provide your valuable comment below if you are using any other library or tool to cover the same.

Author: Akshay Upadhyay

Owner and Director of a Private Limited company which serves individual to large scale industries in the field of Maps and GIS. He is a Gold Medalist in M.Tech(Spatial Information Technology) and owns some famous Technology blogs and website... Know more

2 thoughts on “Different ways to convert Shapefile to GeoJSON – Online or Offline or API”

  1. How can we combine a Shape file + CSV information and produce GeoJason output? Appreciate your inputs on this.

    Thanks for very useful information and links given by you above.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.