我正在为科学手稿绘制地图。该地图应显示墨西哥的基本地图,并带有采样点并显示海拔高度颜色。为此,我在包tmap中使用了R。这是我的代码:
library(sf)
library(raster)
library(dplyr)
library(spData)
library(spDataLarge)
library(tmap) # for static and interactive maps
data(World)
data("metro")
data("land")
gpsdata <- read.csv('gps.csv')
gpsdata <- as.matrix(gpsdata)
gpspoints <- SpatialPoints(gpsdata)
plot(gpspoints)
gpsnames <- read.csv('gps_names.csv')
spdf = SpatialPointsDataFrame(gpsdata,gpsnames)
proj4string(gpspoints) <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
proj4string(spdf) <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
pdf('fig-sampling.pdf')
tm_shape(World[World$name=="Mexico", ]) +
tm_polygons() +
tm_shape(land) +
tm_raster("elevation", breaks=c(-Inf, 250, 500, 1000, 1500, 2000, 2500, 3000, 4000, Inf),
palette = terrain.colors(9), title="Elevation") +
tm_shape(World) +
tm_borders("black", lwd = 1) +
tm_text("name") +
tm_layout(legend.position = c("right","center"),
legend.bg.color = "lightblue", bg.color = 'lightblue') +
tm_shape(metro) +
tm_bubbles("pop2020", title.size = "Population") +
tm_text("name", size = "pop2010", legend.size.show = FALSE, root=8, size.lowerbound = 0.7, just = 'right', xmod = -0.5, ymod = 0)+
tm_grid(projection="longlat", labels.size = .5) +
tm_shape(spdf) +
tm_bubbles(col = 'blue', size = 0.3) +
tm_text("Location", size = 0.8, just = 'left', xmod = 0.3)
dev.off()
不幸的是,高程层是以非常大的像素绘制的:
是否有任何方法可以平滑(我已经尝试过将高程栅格图层设置为style ='cont'?)>]
我正在为科学手稿绘制地图。该地图应显示墨西哥的基本地图,并带有采样点并显示海拔高度颜色。为此,我在包tmap中使用了R。 ...
要做看起来平滑的事情的最简单方法是使用栅格数据包中的disaggregate
对其进行插值。