全球地理距离栅格

编程入门 行业动态 更新时间:2024-10-23 01:46:26
本文介绍了全球地理距离栅格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想知道是否有人建立了世界各大洲的栅格,其中每个像元等于该像元到最近海岸的距离.该地图将突出显示内陆最偏远的陆地区域.

Im wondering if someone has built a raster of the continents of the world where each cell equals the distance of that cell cell to the nearest shore. This map would highlight the land areas that are most isolated inland.

我想这会简单地 rasterize 全局边界的shapefile,然后计算距离.

I would imagine this would simply rasterize a shapefile of the global boundaries and then calculate the distances.

推荐答案

您可以使用 raster :: distance 进行此操作,该方法计算从每个 NA 单元格到最接近的非 NA 单元格.您只需创建一个栅格,该栅格的陆地像素具有 NA ,非陆地像素具有一些其他值.

You can do this with raster::distance, which calculates the distance from each NA cell to the closest non-NA cell. You just need to create a raster that has NA for land pixels, and some other value for non-land pixels.

方法如下:

library(raster) library(maptools) data(wrld_simpl) # Create a raster template for rasterizing the polys. # (set the desired grid resolution with res) r <- raster(xmn=-180, xmx=180, ymn=-90, ymx=90, res=1) # Rasterize and set land pixels to NA r2 <- rasterize(wrld_simpl, r, 1) r3 <- mask(is.na(r2), r2, maskvalue=1, updatevalue=NA) # Calculate distance to nearest non-NA pixel d <- distance(r3) # Optionally set non-land pixels to NA (otherwise values are "distance to non-land") d <- d*r2

要创建上面的绘图(我喜欢 rasterVis 进行绘图,但是您可以使用 plot(r)):

To create the plot above (I like rasterVis for plotting, but you could use plot(r)):

library(rasterVis) levelplot(d/1000, margin=FALSE, at=seq(0, maxValue(d)/1000, length=100), colorkey=list(height=0.6), main='Distance to coast')

更多推荐

全球地理距离栅格

本文发布于:2023-10-13 10:21:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1487685.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:栅格   地理   距离   全球

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!