[GIS] JSONs made from shapefiles are not plotting (using folium or Leaflet alone)

foliumleafletogr2ogrshapefileweb-mapping

My goal is to plot two shapefiles as layers on an interactive map.
The files I'm using live at https://github.com/AnnaMag/maps.

I transformed shapefiles to .geojson using

ogr2ogr -f ...

e.g. ogr2ogr -f geoJSON Wards2011.geojson Wards2011.shp

Neither of the files is being plotted using folium or Leaflet alone.

Code example for 1 shapefile:

#center in SA:
lllon = 15
lllat = -35
urlon = 33
urlat = -22

state_geo = r'data/Wards2011.geojson'
map = folium.Map(location=[(lllat+urlat)/2, (lllon+urlon)/2], zoom_start=6, 
tiles='cartodbpositron')
map.geo_json(geo_path=state_geo)


map.create_map(path='test.html')

Replacing the geo_path with:

state_geo = r'data/sal_population.json'

is not working either.

Is there anything wrong with the json files or the approach?

UPDATE

As suggested I reduced the complexity:

  1. in Wards shapefile I left only 4 necessary features (incl. geometry, of course)

  2. Simplified the shapefiles

    ogr2ogr out.shp in.shp -simplify 0.000001

  3. transformed to geojson

    ogr2ogr -t_srs EPSG:4326 -f GeoJSON Wards2011.geojson out.shp

  4. transformed to topojson

    topojson –spherical –properties -s 0.001 -q 1E6 -o Wards2011.topojson Wards2011.geojson

Neither of the files is working. What should be fixed to make it work?

Best Answer

The geo_path you mentioned a path that is not valid! Your shapes are stored in the file Wards2011.geojson and not Wards2011.json

Furthermore your geojson has 143mb which is very much to handle. simplify the geometry of the shapefile! I have done something similar in QGIS and reduced 120mb to 4mb which works in a browser.