# 博文

library(RgoogleMaps)
load("D:/R/statistics/NumericalEcologywR-2ed_code_data/NEwR-2ed_code_data/NEwR2-Data/Doubs.RData")

nom <- latlong$Site latlong2 <- paste(latlong$LatitudeN, latlong$LongitudeE, sep = ":") df <- data.frame(latlong2, nom, stringsAsFactors = FALSE) mymap1 <- gvisMap(df, locationvar = "latlong2", tipvar = "nom", options = list(showTip = TRUE) ) plot(mymap1) gvisMap函数画出来的图虽然好看，但是不仅有打码，还不能保存，这在写论文的时候就非常不适用了。所以，在书的源代码中还有另外一种画图的方法。 # This method provides a static image that is viewed in R. # Map background is fetched from the Internet. The map limits # are defined by the latitude and longitude of the site # coordinates. # Several types of maps are available. Here we use "terrain". MapBackground(lat = latlong$LatitudeN,
lon = latlong$LongitudeE, destfile = "bckg", maptype = "terrain" ) # Map is loaded into an R object doubs.map <- ReadMapTile(destfile = "bckg") # Site latitude-longitude coordinates are added PlotOnStaticMap(doubs.map, lat = latlong$LatitudeN,
lon = latlong$LongitudeE, cex = 0.7, col = "black", pch = 19 ) # Plot of labels TextOnStaticMap(doubs.map, latlong$LatitudeN - 0.0008 * abs(latlong$LatitudeN), latlong$LongitudeE,
labels = latlong\$Site,
cex = 0.5
)

# The size of the points and labels is adjusted by the argument
# cex. The location of the labels has been offset from the
# points by subtraction of small fractions of the latitude.

http://wap.sciencenet.cn/blog-3412381-1197146.html

## 相关博文

GMT+8, 2021-11-28 15:47