2

I'm trying to develop a web map with a clickable chloropleth layer of streets in a large city. There are approximately 40k polylines in this layer, producing a 21MB GeoJSON. This is too much data to send to the client at once and an unnecessary amount to map at the city scale. Our data is in PostGIS and we'd like to Leaflet for the front-end. I have investigated the more common Python web-servers but I haven't easily found documentation/tutorials/Q&A about solving something similar with geoDjango/geoAlchemy2.

The answer to Adding/Removing Leaflet GeoJSON layers shows how to load different layers at different zoom levels (and caching them), but doesn't cover a bounding-box filter on data coming from the server. This answer has the rather unhelpful solution of "just load all the data client-side first". The answer to How to add a bounding box filter to this leaflet WFS request? shows how to load data within the bounding box on every map move, but, unlike the first answer, appears to discard and re-draw the layer every time the map is moved.

geojson-vt by Mourner solves the client-side rendering problem (106MB of zipcodes, wow!) but doesn't seem to solve the data-transfer issue. The post does hint that this has traditionally been done server-side.

The best way to optimize the data for all zoom levels and screens is to cut it into vector tiles. Traditionally, this is done on the server, using tools like Mapnik and PostGIS.

What python web-server framework can load and display slices of a large number of polylines within different zoom levels & bounding boxes?

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
raphael
  • 3,407
  • 23
  • 61
  • I think this would be fine to ask in the GIS Chat Room but as-is is too broad and discussion seeking for focused Q&A. – PolyGeo Jun 22 '17 at 19:45
  • @PolyGeo suggestions for narrowing? – raphael Jun 22 '17 at 19:50
  • You have a"preference for a Python web-server and a Leaflet front-end" so you could choose a stack and ask precisely about a requirement that your product of choice in either tier does not meet from your testing or appears unable to meet from your investigation. – PolyGeo Jun 22 '17 at 19:59
  • why not use a WMS possibly with a tile cache? – Ian Turton Jun 23 '17 at 07:16
  • It's not clear to me why you don't want to go down the vector tile route you describe. Mapnik has a python API. – RoperMaps Jun 23 '17 at 09:26
  • @RoperMaps I want to be able to pull extra data from the database to display a graph for a street once the user clicks on it. It's not clear whether that is compatible or incompatible with your suggestion. Can Mapnik create a layer with data that would enable interactivity? – raphael Jun 26 '17 at 16:41
  • @raphael I may be miss udnerstanding your requirements, but it sounds like you have some spatial data (the streets) you want to display, and use as an interface for interactivity and displaying additional attribute data - i.e. if a user clicks on a street you display a graph that has been generated from data in your PostGIS database. You can do that with ajax. This can be done with a GeoDjango framework, or just with your own script. Here is one implementation using leaflet - php - postgis. – RoperMaps Jun 27 '17 at 07:34
  • The above example is not doing exactly what you wan but is a clear example of using ajax without the additional complication of a framework. Geodjango or similar will just keep this stuff more organised, maintainable and testable if your app grows. – RoperMaps Jun 27 '17 at 07:35
  • @RoperMaps you got most of them. The concern is the volume of data for the city's streets. The standard leaflet GeoJSON approach assumes transferring all the data to the client at the start. After a lot of searching I've discovered that the common term for the more data-efficient serving of slices of data is the vector-tile – raphael Jun 27 '17 at 17:22
  • Ah ha, I think that is described in the Morner article you link, so assumed you were on that! Glad you got it sorted. I think describing these larger 'system designs' is valuable especially in an area like web mapping where the possibilities are endless. Maybe you could document what your final stack/framework looks like if you get a chance? – RoperMaps Jun 27 '17 at 19:51

0 Answers0