Maps are often used to show the distribution of a statistical variable. Here is a description on how to add shapes on maps with the leaflet R library.

Let’s start with basic circle (default propose by leaflet). Please note that since we use here the addCircleMarkers function, the size of the circle are set in pixels. It means that markers will keep always the same size, even when you zoom in or out!

It is possible to custom the circles. Really helpful since it permits to change it following the value of a statistical variable!

You can also add circles with the addCircle function. This time, the radius of the circle is defined in meters. It means that its size will change when you zoom on the map!

Lastly, how to add a rectangle with the addRectangles() function. You have to give the 2 coordinates of 2 opposites corners of the rectangle.




Leave a Reply

Notify of