微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

为什么在 R 中使用栅格包的地形函数时斜率值会这么高?

如何解决为什么在 R 中使用栅格包的地形函数时斜率值会这么高?

我正在尝试为冰川制作坡度图,但坡度值高得不切实际。我正在使用 terrain 包的 raster。这是使用该文件的谷歌驱动器的链接

https://drive.google.com/file/d/1uxd945IJRM4YbhmolXCHEQFKtRaA0GVE/view?usp=sharing

library(ggplot2)
library(tidyverse)
library(Metrics)
library(raster)
library(rgdal)
library(depmixS4)
library(plotly)


ice_14.15990 <- read.table("/Users/sayantanmandal/THESIS/Codes/bed/ice_14.15990")

colnames(ice_14.15990)[1] <- "Longitude"

colnames(ice_14.15990)[2] <- "Latitude"

colnames(ice_14.15990)[3] <- "surface_thickness"

ICE <- subset(ice_14.15990,surface_thickness!=0)

obs_ice <- rasterFromXYZ(ICE)

crs(obs_ice)<- CRS('+init=epsg:32643')

writeraster(obs_ice,'/Users/sayantanmandal/THESIS/Codes/obs_ice.tif',overwrite = TRUE)

obs_ice_slope <- terrain(x = obs_ice,opt = 'slope',unit = 'degrees',neighbors = 8,is.na = TRUE)


obs_ice_slope_df <- as.data.frame(rasterToPoints(obs_ice_slope))
colnames(obs_ice_slope_df)[1] <- "Longitude"
colnames(obs_ice_slope_df)[2] <- "Latitude"
colnames(obs_ice_slope_df)[3] <- "Slope_deg"
obs_ice_slope_df <- subset(obs_ice_slope_df,Slope_deg !=0 )
obs_ice_slope_df$Slope_val <- tan((obs_ice_slope_df$Slope_deg *pi)/180)

obs_ice_slope_cont <- ggplot(obs_ice_slope_df,aes(x = Longitude,y = Latitude,z = Slope_deg)) +
  geom_raster(aes(fill = Slope_deg)) +
  scale_fill_distiller(palette = "Spectral",direction = -1) +
  xlab("Longitude (epsg: 32643)") +
  ylab("Latitude (epsg: 32643)") +
  ggtitle("observed ice slope in deg.") +
  theme(
    
    panel.border = element_blank(),panel.grid.major = element_blank(),panel.grid.minor = element_blank(),panel.background = element_blank())+
  stat_contour()

print(obs_ice_slope_cont)

[

Of course these are unrealistic slope values1

。我似乎无法弄清楚我哪里出错了。可能是数据开始不流畅?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。