EDIT After three days of little interest, I am adding a fully reproducible example... The code below makes 1400 locations. The first 700 points are centered around the first area, the 2nd 700 points are centered around a 2nd area to the northwest.
datOne <- data.frame(
Long = runif(700, -111.180000, -110.950000 ),
Lat = runif(700, 43.180000, 43.440000),
Area = "First")
datTwo <- data.frame(
Long = runif(700, -111.850000, -110.900000),
Lat = runif(700, 43.910000, 44.000000),
Area = "Second")
dat <- rbind(datOne, datTwo)
dat$LatLong <- paste(dat$Lat, dat$Long, sep = ":")
head(dat)
Long Lat Area LatLong
1 -110.9701 43.19509 First 43.1950901590148:-110.970063584852
2 -111.0258 43.25338 First 43.2533758980362:-111.025837010061
3 -111.1737 43.18016 First 43.180157370572:-111.173737878765
4 -111.1130 43.41193 First 43.4119294773275:-111.112970910808
5 -110.9909 43.34044 First 43.3404393909033:-110.990947539737
6 -110.9800 43.33428 First 43.3342766285082:-110.979969937215
If I try to plot the points with gvisMap
then only the locations centered around the first area apear in the map as is reproduced with the following code
library(googleVis)
M2 <- gvisMap(dat, "LatLong",
options=list(showLine=TRUE, enableScrollWheel=TRUE,
mapType='satlite', useMapTypeControl=TRUE,
width="800", height="800",
colors = "['#0000ff']",
icons=paste0("{","'default': {'normal':
'http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png',\n",
"'selected':'http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png'",
"}}")
))
plot(M2)
To confirm that all the locations are formatted correctly I can subset the dataframe to plot points 500:1000 which includes locations in both areas. Changing the first line of code to
M2 <- gvisMap(dat[500:1000, ], "LatLong",
will correctly display locations in both areas. So, the issue does not seem to be formatting, but maybe there is a maximum number of points that can be plotted..?
Is it possible to plot all locations in the reproducible data included herein?
Any suggestions or code to plot all of the points in the dat
dataframe above would be greatly appreciated. I am happy to take suggested code from other packages such as leaflet
mentioned in the comments.
Check out the example below. This uses the R leaflet package and binds a popup to the markers from the area column.
library(leaflet)
datOne <- data.frame(
lng = runif(700, -111.180000, -110.950000 ),
lat = runif(700, 43.180000, 43.440000),
Area = "First")
datTwo <- data.frame(
lng = runif(700, -111.850000, -110.900000),
lat = runif(700, 43.910000, 44.000000),
Area = "Second")
dat <- rbind(datOne, datTwo)
dat$latLng <- paste(dat$lat, dat$lng, sep = ":")
map<-leaflet(dat)
map<-addTiles(map)
map<-addMarkers(map,~lng,~lat,popup = ~as.character(Area))
map