mapcomm / common-ground_map

An enhanced leaflet map made for re-use (highly commented, built openly) used to show community groups and find "common ground"
http://mapping.community
1 stars 3 forks source link

Feature: Create integration of demographic data sets as Choropleth layers #12

Open kidwellj opened 7 years ago

kidwellj commented 7 years ago

I'm thinking here of the 2011 UK Census, Scottish Index of Multiple Deprivation, and UR 6 fold scale. Once these are integrated then we can start to fill in data in the pane/D3 viz.

kidwellj commented 7 years ago

See good (if slightly more full featured that we would aim for) example here: http://climate.globalforestwatch.org/map/3/15.00/27.00/ALL/dark/biomass_loss?begin=2001-11-10&end=2015-01-01&threshold=30 with code deposited here: or this one, with code here: https://github.com/Vizzuality/gfw-climate

danhillcode commented 7 years ago

progress

kidwellj commented 7 years ago

So here's what needs to be done, I think:

(1) Calculate bounding box for current leaflet map instance displayed onscreen using map.getBounds(); see here: https://stackoverflow.com/questions/22948096/get-the-bounding-box-of-the-visible-leaflet-map#22949388

(1b) Set variables to pass to postgis query based on above bounds (?)

(1c) Set max/min zoom to prevent map from loading too much data at high zoom levels. Basically, > zoom level 4 we should not display any data; between zoom levels 4-8 display a simplified set of polygons

...there are UX considerations here as zoom level will impact the size of data in the query. Options: we could (i) auto-set zoom to minimum if user clicks on an analysis layer or (ii) display light-touch error message to warn them that polygons won't display until zoom level is close enough or (iii) simplify geometries for high zoom levels (see here http://strk.kbt.io/blog/2013/03/08/on-the-fly-simplification-of-topologically-defined-geometries/) or (iv) use alternative data set for high zoom levels.

(2) Query 'demographics' PostGIS database for any objects inside/intersected by this bounding box, something like this I think:

SELECT *
FROM 2011_OAC
WHERE 
  mytable.geom && ST_MakeEnvelope(minLon, minLat, maxLon, maxLat);

see here: https://gis.stackexchange.com/questions/25797/select-bounding-box-using-postgis?rq=1

(3) Display these objects as polygons in a new layer on the leaflet map

An alternative for (1-2) would be to pre-cache all the images using a tileserver like mapnik. I'm pretty sure what these guys here are doing: http://simd.scot/2016/#/simd2016. I think this option may be overly server-heavy and not the most programmatically elegant solution...

danhillcode commented 7 years ago

Just checked DVF library works on its own with the map but struggles with the marker cluster need to look into this more would it be an option to have a separate map with these layers?