How to Make Maps Using Leaflet.js, PostGIS and Chicago Open Data
samc1213.github.io
How to Make Maps Using Leaflet.js, PostGIS and Chicago Open Data
1–10 of 23 posts
Re: How to Make Maps Using Leaflet.js, PostGIS and Chicago Open Data
#2It looks like the city of Chicago might be sitting on top of the Socrata API, which allows you to run a distinct - if you are visualizing counts for each tract (or averages and other types of calculations) it would save you the Digital Ocean resources to grab the API counts either on-the-fly or as static files for the tracts in Chicago and render them that way via Leaflet, but obviously this does not allow for quite as novel an analysis as PostGIS offers! (here's the API page that the City of Chicago links to from their page https://dev.socrata.com/docs/functions/#2.1,)
Re: How to Make Maps Using Leaflet.js, PostGIS and Chicago Open Data
#3and if you're running a version of PostGIS with protobuffers enabled (Not AWS RDS) you can generate vector tiles on the fly with https://postgis.net/docs/ST_AsMVT.html which are great for displaying large datasets.
Re: How to Make Maps Using Leaflet.js, PostGIS and Chicago Open Data
#4A fun tip, if you're using PostGIS you can actually generate the Geojson directly in the SQL query with http://www.postgis.org/docs/ST_AsGeoJSON.html and if you're running a version of PostGIS with protobuffers enabled (Not AWS RDS) you can generate vector tiles on the fly with https://postgis.net/docs/ST_AsMVT.html which are great for displaying large datasets.
Re: How to Make Maps Using Leaflet.js, PostGIS and Chicago Open Data
#5Kudos on writing a solid comprehensive article on mapping, the tooling available, and how to do it step by step. (GDAL and everything!) Not an easy task, and I found the format engaging. Great stuff. It looks like the city of Chicago might be sitting on top of the Socrata API, which allows you to run a distinct - if you are visualizing counts for each tract (or averages and other types of calculations) it would save…
Re: How to Make Maps Using Leaflet.js, PostGIS and Chicago Open Data
#6A fun tip, if you're using PostGIS you can actually generate the Geojson directly in the SQL query with http://www.postgis.org/docs/ST_AsGeoJSON.html and if you're running a version of PostGIS with protobuffers enabled (Not AWS RDS) you can generate vector tiles on the fly with https://postgis.net/docs/ST_AsMVT.html which are great for displaying large datasets.
The vector file seems really useful. I ran a query that resulted in a 1.5 GB geojson file... much too big for Leaflet. Maybe the Vector tile would be compact enough? Thanks!
You'll need the MapboxVectorTiles plugin for leaflet but you can definitely improve the sizes by a fair bit.
Re: How to Make Maps Using Leaflet.js, PostGIS and Chicago Open Data
#7A fun tip, if you're using PostGIS you can actually generate the Geojson directly in the SQL query with http://www.postgis.org/docs/ST_AsGeoJSON.html and if you're running a version of PostGIS with protobuffers enabled (Not AWS RDS) you can generate vector tiles on the fly with https://postgis.net/docs/ST_AsMVT.html which are great for displaying large datasets.
Re: How to Make Maps Using Leaflet.js, PostGIS and Chicago Open Data
#8Kudos on writing a solid comprehensive article on mapping, the tooling available, and how to do it step by step. (GDAL and everything!) Not an easy task, and I found the format engaging. Great stuff. It looks like the city of Chicago might be sitting on top of the Socrata API, which allows you to run a distinct - if you are visualizing counts for each tract (or averages and other types of calculations) it would save…
Thanks for your feedback! I have 0 experience with mapping so it was fun to see all the tools out there. There's much more out there than I expected. I did notice they had the API, but figured I would learn something a little more universally applicable by learning PostGIS. I should try that out though for a more lightweight and cheaper option next time
One of my favorite primers is by Robert Simmon who I had the pleasure of seeing at OpenVis: https://youtu.be/N_dmiQI1s24
RE mapping tools - I've been working a lot lately with Vector Tiles and their embedded props and from a web-mapping perspective it's nice to download the geometry once and then style many times in terms of over-the-wire efficiency.
Happy hunting and thanks for your post.
Re: How to Make Maps Using Leaflet.js, PostGIS and Chicago Open Data
#9A fun tip, if you're using PostGIS you can actually generate the Geojson directly in the SQL query with http://www.postgis.org/docs/ST_AsGeoJSON.html and if you're running a version of PostGIS with protobuffers enabled (Not AWS RDS) you can generate vector tiles on the fly with https://postgis.net/docs/ST_AsMVT.html which are great for displaying large datasets.
RDS now supports libprotobuf-c, so AsMVT will work (at least on some postgres versions)
https://dba.stackexchange.com/questions/202049/support-for-l...
v10.5 of postgres by the looks of it, don't know how I missed that.
Re: How to Make Maps Using Leaflet.js, PostGIS and Chicago Open Data
#10Also, as others have mentioned you can generate the st_asmvt format directly from pg. This plus PostgREST binary output[1] can get you a way to query your table directly through a REST API.