- This project takes coordinates (latitude, longitude) as inputs and shows the location on the map and displays the country to which it belongs.
- It makes use of the Leaflet package in R to plot the map and add the coordinates as the marker.
- Leaflet is one of the most popular open-source JavaScript libraries for interactive maps. The user can scroll and navigate through the map dispayed.
- The sidebar contains the inputs: Latitude value, latitude decimal,longitude value, longitude decimal via a slider input.
- The 'value' part of the coordinates denotes the numbers before the decimal and the 'decimal' value contains the numbers after the deecimal.
- Therefore, latitude value of 45 and latitude decimal of 12 will result in the latitude corordinate to be 45.12
- This project uses the decimal degrees system (DDD.DDDDD). The coordinates are stored internally in a floating point data type.
- Once the 'Find Location' button is pressesd, a reactive event is set to add the marker to the map and find the country to which it belongs to.
library(sp)
library(maps)
library(rgeos)
library(maptools)
library(rworldmap)
points=data.frame(lon=-1.2,lat=49.20)
countriesSP <- getMap(resolution='low')
pointsSP = SpatialPoints(points, proj4string=CRS(proj4string(countriesSP)))
indices = over(pointsSP, countriesSP)
indices$ADMIN
[1] France
244 Levels: Afghanistan Aland Albania Algeria American Samoa Andorra ... Zimbabwe