2

This question already has an answer here:

I'm trying to convert a large Shapefile (120 MB) to GeoJSON.

OGR converter gives an error that says process time took over 15 seconds, so process was cancelled.

Mapshaper gives the following error: File size of .shp doesn't match size in header

What can I do now? I'd prefer not installing any desktop software to do a simple conversion.

marked as duplicate by Ian Turton Apr 24 '18 at 16:48

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    Your shapefile is corrupted. Contact whoever delivered the data for you and ask to send valid data. – user30184 Apr 15 '18 at 12:12
1

If a python script is an option for you, then this will do the trick fast:

import geopandas as gpd
file = gpd.read_file("file.shp")
file.to_file("file.json", driver="GeoJSON")
  • 2
    If ogr can't read the dataset, then geopandas probably won't be able to either as it's based on ogr. – user2856 Apr 15 '18 at 9:40
0

Converting shapefiles to GeoJSON is not that difficult, You can Use OGR2OGR converter to convert the shapefile into GeoJSOn files.

For using ogr2ogr, 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**

This will help you convert your files and If OGR and Mapshaper converters are not working you can go for the API converters for Converting Shapefile into GeoJSON. They are open source projects which can help you.

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.