我在繪製某個光柵時會看到一些奇怪的行爲。 這是我從naturalearthdata.com獲得的陰影救濟柵格。 You can download it here.光柵分辨率不能正常顯示
我發現,儘管光柵的分辨率沒有改變,但根據我繪製柵格的空間範圍,繪製了不同的分辨率。
library(raster)
relief <- raster('GRAY_50M_SR_W.tif')
# let's use Mexico as an example:
library(maptools)
data(wrld_simpl)
mx <- wrld_simpl[which([email protected]$NAME == 'Mexico'),]
# Here I create a cropped version of the raster
reliefMX <- crop(relief, mx)
爲了說明這個問題,我積墨,以獲得地圖範圍,然後我繪製光柵的全部範圍,並在上面然後裁剪柵格。
您可以看到,柵格顯示的分辨率非常不同,但它們確實具有相同的分辨率。
plot(mx)
plot(relief, col = grey(0:100/100), legend = FALSE, axes = F, box = F, add=T)
plot(reliefMX, col = grey(0:100/100), legend = FALSE, axes = F, box = F, add=T)
> res(relief)
[1] 0.03333333 0.03333333
> res(reliefMX)
[1] 0.03333333 0.03333333
任何想法?我怎樣才能讓這些柵格正確顯示?
> sessionInfo()
R version 3.4.0 (2017-04-21)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.4
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] maptools_0.9-2 raster_2.5-8 sp_1.2-4
loaded via a namespace (and not attached):
[1] compiler_3.4.0 rgdal_1.2-7 tools_3.4.0 foreign_0.8-68 Rcpp_0.12.10
[6] grid_3.4.0 lattice_0.20-35