This post intends to demonstrate how to deploy point data in CSV format to create web maps using the leaflet R package.
Prepare your CSV data so that the location fields (Y) and (X) should be titled long and lat. This would make it easier for the leaflet R package to recognize them as location fields.
1. Launch RStudio and choose the Packages tab. Check the raster and leaflet package boxes.
2. Once the packages are activated in the window console, type in the read.csv command to load the CSV file from the local directory. Hit the Enter key to run the command.
3. The CSV file is added to the Environment window as seen in the screenshot example below.
4. Next we write out the codes to initialize the leaflet map, add base tiles and add the CSV data as markers on the base map.
leaflet( data = poi) %>% //load the data into leaflet map
addTiles() %>% //add base tiles
addMarkers(~long, ~lat) //add the data as markers on the base map using the values in their long and lat colums
5. Click on the viewer tab and preview the leaflet map.
6. Next we convert the markers from the default to circles form by using addcircleMarkers() instead of addMarkers()
7. Go to the viewer tab and preview the leaflet map.
Thank you for following the blog.