3

I have this geojson file(about 60mB) that contains the administrative area boundaries. I want to make a chloropleth and give color based on each geometry properties value and add it to the featureLayer. Problem is when I try to load the geojson file, it will take a considerable amount of time. I tried tileLayer but using this I can't find a way to change the filling color of the polygons. How can I solve this to make the geojson load faster?

3 Answers 3

1

You could simplify the file. For this you could use QGIS. One option would be simplifying the lines, but that would probably break topology. Another option, depending on your file, is limiting the number of decimal places. That would reduce file size, but not complexity.

Another option would be using TopoJSON. TopoJSON is perfect for administrative areas because it removes redundant lines (each border will only remain once, while it exists twice in GeoJSON).

3
  • But it won't be scalable enough just by simplifying the geojson. I was thinking about using github.com/glenrobertson/leaflet-tilelayer-geojson. But it require me to setup my own server to serve the geojson.
    – edmundpie
    Commented Aug 11, 2015 at 5:32
  • Is the slowness from downloading or from the browser struggling to render 60MB of GeoJSON? Do you absolutely need GeoJSON or could raster tiles with Tilemill be enough (you still get mouseover info). Commented Aug 11, 2015 at 9:02
  • The size of the geojson is more than 60 mb. So it will take time to download it at once. Also, this geojson is very likely to increase in the future to cover the whole world. I need the geojson instead of the rastered tiles because I want to make a dynamic chloropleth based on the data the server returned.
    – edmundpie
    Commented Aug 11, 2015 at 9:25
0

If the file size is too big, and you mentioned that it's going to increase more in the future, you need to use raster tiles.

Actually, you should use CartoDB, upload your dataset there, you can make the dynamic chloropleth maps based on your data the server returned to you (as you mentioned this requirement in a comment).

CartoDb gives a function setCartoCSS(), using this function you can style individual polygons whatever the way you want.

0

I have the same problem right now. So there are my steps: 1)create tiles in tileMill 2)create .png tiles in qgis using plagin MBTiles extract 3)create canvas mask on custom layer 4)right now I try to write piece of code that will extract hex color of images, and than convert hex color to dynamyc legend(cause there are about 150 types of color)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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