简体   繁体   English

将轮廓核密度估计图导出为栅格或 shapefile 格式

[英]Exporting a contoured Kernel density estimation plot to raster or shapefile format

I'm trying to perform Kernel density estimation in R using some GPS data that I have.我正在尝试使用我拥有的一些 GPS 数据在 R 中执行内核密度估计。 My aim is to create a contoured output with each line representing 10% of the KDE.我的目标是创建一个轮廓输出,每行代表 KDE 的 10%。 From here i want to import the output (as a shapefile or raster) into either QGIS or arcmap so I can overlay the output on top of existing environmental layers.从这里我想将输出(作为 shapefile 或栅格)导入 QGIS 或 arcmap,以便我可以将输出覆盖在现有环境图层的顶部。

So far i have used AdehabitatHR to create the following output using the below code:到目前为止,我已经使用 AdehabitatHR 使用以下代码创建了以下输出:

kud<-kernelUD(locs1[,1], h="href")
vud<-getvolumeUD(kud)
vud <- estUDm2spixdf(vud)
xyzv <- as.image.SpatialGridDataFrame(vud)
contoured<-contour(xyzv, add=TRUE)

在此处输入图片说明

Aside from being able to remove the colour, this is how i wish the output to appear (or near to).除了能够去除颜色之外,这就是我希望输出出现(或接近)的方式。 However i am struggling to figure out how i can export this as either a shapefile or raster?但是,我正在努力弄清楚如何将其导出为 shapefile 或栅格? Any suggestions would be gratefully received.任何建议将不胜感激。

With the amt package this should be relatively straightforward:使用amt包,这应该相对简单:

library(adehabitatHR)
library(sf)
library(amt)

data("puechabonsp")
relocs <- puechabonsp$relocs


hr <- as.data.frame(relocs) %>% make_track(X, Y, name = Name) %>% 
  hr_kde(trast = raster(amt::bbox(., buffer = 2000), res = 50)) %>% 
  hr_isopleths(level = seq(0.05, 0.95, 0.1))

# Use the sf package to write a shape file, or any other supported format

st_write(hr, "~/tmp/home_ranges.shp")

Note, it is also relatively easy to plot注意,它也相对容易绘制

library(ggplot2)
ggplot(hr) + geom_sf(fill = NA, aes(col = level))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM