I'm using the query found here SQL query to have a complete geojson feature from PostGIS to get a geojson that I can display on a leaflet map.

However, the amount of data is kinda big and the performance on Firefox is crappy (okay on Chrome), so I'm wondering if there is a way to convert the result of the query in Postgis into a topojson, in order to get a better performance

  • are the performance issues because of transfer size of geojson from the server, or rendering in the browser?
    – toms
    Jun 5, 2015 at 15:11
  • It's a rendering issue in Firefox, it can't deal very well with a big vector polygon, that's why I'd like to minimize the amount of lines the browser has to draw
    – mlopez
    Jun 8, 2015 at 6:59
  • You can use the topojson package to convert geojson to topojson and in the client side use leaflet-omnivore to render it on the map directly on topojson
    – sigon
    Jun 10, 2015 at 9:57
  • I use the result of the query as a Geojson directly on the code, so I don't have any .geojson file stored.
    – mlopez
    Jun 10, 2015 at 10:32

1 Answer 1


I'm not sure TopoJSON is the answer here. Under the covers leaflet-omnivore is converting the TopoJSON to GeoJSON and feeding that to Leaflet. Using d3js-topojson does exactly the same thing. In the end the polygons being rendered are the same wether sourced as TopoJSON or GeoJSON. You might need to consider simplifying your polygons. The only way you can really help the browser is to ask it to do less work. In this case that means fewer vertices so the browser has to draw fewer lines. Simplification can be done dynamically when requesting the data, but that introduces more latency. I'd suggest creating a second geometry columnn in your source table for storing simplified geometries.

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.