In the process of working on a recent choropeth piece for work,
I discovered that it’s easy to stumble when moving spatial data out of R and
onto the web. It’s a poorly-documented reality that many web-based mapping
libraries (including both D3 and Leaflet) expect GeoJSON data to be in
EPSG:4326, and it is by no means a given that that your spatial data will
start off in this projection.
If you’re like me and do your spatial data pre-processing in R before exporting to GeoJSON, you may have to re-project your data before these libraries will handle them properly. Thankfully, this is fairly easy to do with the modern spatial packages.Continue Reading →