This post will show you how to build a shiny app to visualize spatial data (mainly in raster and vector format). Remember that you can also build other types of shiny apps, but I decided to focus this post on spatial data.
So the first thing is going to open RStudio, click on New Project -> New Project -> Shiny application and create new shiny app folder.
The first thing is to load the necessary packages
Then you are going to load the raster and vector data.
Additionally, you need to create a palette to show the DEM we loaded and set customized icons to show the vector data. Finally, you will create the legend entries for each of the customized icons.
Then, you need to set up the users interface. In this case, since we are interested in navigating spatial data, we are using a vertical layout.
Then create below that same script the server side script. Most of this part is setting up the leaflet visualization, adding a basemap (ESRI world imagery), adding the markers (point data), DEM (raster data) and other features (lines data), adding control layers buttons, as well as the legend for our customized icons and a scale bar. Finally, you need to create an observe event to watch for clicks over the markers, to show up their details when clicked.
Finally, run the app.
A snapshot of the result:
Shiny app to visualize and explore spatial data.
The real results hosted in shinyapps.io: https://jonathanvsv.shinyapps.io/cuilalaapp/