【发布时间】:2021-09-17 17:09:13
【问题描述】:
我正在尝试绘制从 here 下载的网格人口计数 GeoTIFF 栅格。
library(raster)
#----------------------------#
# Set your working directory #
#----------------------------#
setwd(dirname(rstudioapi::getActiveDocumentContext()$path)) # RStudio IDE preferred
getwd() # Path to your working directory
# Import the GeoTIFF file into R workspace
WorldPop <- raster("nga_ppp_2020_1km_Aggregated_UNAdj.tif")
WorldPop
#---------------------------#
# Data plotted in log-scale #
#---------------------------#
tempcol <- colorRampPalette(c("lightblue", "skyblue", "blue", "yellow", "orange", "red", "darkred"))
plot(log(WorldPop), main = "2020 UN-Adjusted Population Count (log-scale) \n (each grid cell is 1 km x 1 km)", col=tempcol(100), legend.width=2, legend.shrink=1, legend.args=list(text='log(Persons)', side=4, font=2, line=2.5, cex=0.8), axes=T)
#--------------------------------#
# Data plotted in absolute-scale #
#--------------------------------#
plot(WorldPop, main = "2020 UN-Adjusted Population Count (absolute-scale) \n (each grid cell is 1 km x 1 km)", col=tempcol(100), legend.width=2, legend.shrink=1, legend.args=list(text='Persons', side=4, font=2, line=2.5, cex=0.8), axes=T)
图 1(对数尺度)
图 2(绝对比例)
我喜欢 Plot 1(对数比例的数据),但 Plot 2(绝对比例的数据)没有显示任何颜色变化。如何使绝对比例的数据图看起来与对数比例的数据图相似?
只要我的地块能够区分人口稠密地区和农村地区,我愿意使用其他软件包(ggplot2 等)或其他颜色。当我使用另一个名为 Panoply 的 GIS 工具时,我最喜欢的颜色是名为 seminf-haxby.cpt 的东西(找到 here)。它看起来像这样
我试图在 R 中复制它,但绝对比例的情节看起来并不好。在 R 中绘制 tif 栅格的任何提示或建议?
【问题讨论】:
标签: r ggplot2 raster geotiff color-palette