如何绘制两个具有不同扩展名的栅格

How to plot two rasters with different extensions

我正在尝试绘制两个具有不同扩展名(来自两个不同区域)的栅格,并且它们正在叠加。

第一个光栅 TN:

class: RasterLayer

dimensions : 1785, 2363, 4217955 (nrow, ncol, ncell)

resolution : 0.11766, 0.11766 (x, y)

extent : 474953.5, 475231.5, 6539165, 6539375 (xmin, xmax, ymin, ymax)

coord. ref. : +proj=lcc +lat_1=58 +lat_2=59.33333333333335 +lat_0=57.51755393055556 +lon_0=24 +x_0=500000 +y_0=6375000 +ellps=GRS80 +towgs84=0,0,0,-0,-0,-0,0 +units=m +no_defs

data source : C:\Users\Usuario\AppData\Local\Temp\RtmpSYhw1w\raster\r_tmp_2018-11-29_153551_4484_16660.grd

names : layer

values : 1, 3 (min, max)

第二个栅格 TS:

class : RasterLayer

dimensions : 7266, 5237, 38052042 (nrow, ncol, ncell)

resolution : 0.1141, 0.1141 (x, y)

extent : 474817, 475414.5, 6537431, 6538260 (xmin, xmax, ymin, ymax)

coord. ref. : +proj=lcc +lat_1=58 +lat_2=59.33333333333335 +lat_0=57.51755393055556 +lon_0=24 +x_0=500000 +y_0=6375000 +ellps=GRS80 +towgs84=0,0,0,-0,-0,-0,0 +units=m +no_defs

data source : C:\Users\Usuario\AppData\Local\Temp\RtmpSYhw1w\raster\r_tmp_2018-11-29_154600_4484_99649.grd

names : layer

values : 1, 2 (min, max)

library(raster)
ext1 <- extent(6600000, 7000000, 66000000, 70000000) #total area extent

extent(TN) <- ext1
extent(TS) <- ext1 #rasters with the same extent (total area)

em = merge(extent(TN),extent(TS))
plot(em, type="n")
plot(TN,add=TRUE, legend=FALSE)
plot(TS, add=TRUE, legend=FALSE)

maps superimposed

这些图重叠只是因为每个栅格的范围相同。给他们不同的程度。这是一个可重现的例子:

library(raster)
logo <- raster(system.file("external/rlogo.grd", package="raster")) 
logo1 <- logo
logo2 <- logo

分配正确的范围并合并:

ext1 <- extent(0, 45, 0, 45)
ext2 <- extent(55, 100, 55, 100)
extent(logo1) <- ext1
extent(logo2) <- ext2
em <- merge(ext1, ext2)

将数据添加到图中:

plot(em, type = "n")
plot(logo1, add = T, legend = F)
plot(logo2, add = T, legend = F)