Leaflet in R – West Nile Virus Map

Recently I finished working on a demonstration for a West Nile Virus map. I found myself referring back to my example often, so I thought that if it’s useful for me, maybe it will be useful for someone else!

Most of the data I was using was already in the public domain, but it only took a few edits to rely 100% on public data. Now I have a nice shareable example.

I’m not going to try an embed it into this post, here’s a link to the map, and here’s the source code for reference.

Also, I’ve started a github project to store some of my most often used map examples, hopefully that stay updated: https://github.com/geneorama/wnv_map_demo/

This is what the map looks like:

I did normal leaflet things, like used the values to control the circle size, customized opacity to make it easier to see the map below, and I made the red circle plot on top of the blue circle to give a sense of the proportion of mosquitoes affected.

However I learned some new tricks in this map:

  • Of course, data.table provides a fast and flexible way to manipulate and reshape the data
  • I developed my own Mapbox template to mimic the look and feel of our Opengrid application
  • I developed my own HTML pop-ups using htmltools::HTML

please use the Rmd file to adopt for your own purposes!

Happy mapping, and remember to use your DEET based bug repellent.

Leave a Reply

Your email address will not be published. Required fields are marked *