简体   繁体   English

R:从 dataframe 创建 RasterLayer object 与经纬度和高度值

[英]R: Create RasterLayer object from a dataframe with long & lat & altitude values

I have a data.frame list with 3 columns (Col 1: Long, col 2: Lat, col 3: Altitude) and 1095 rows.我有一个包含 3 列(Col 1:Long,col 2:Lat,col 3:Altitude)和 1095 行的 data.frame 列表。 I want to change this data.frame to the RasterLayer formula.我想将此 data.frame 更改为 RasterLayer 公式。 What should I do next?接下来我该怎么办? Anything which help will be greatly appreciate!!任何有帮助的东西都将不胜感激!!

It is a grid cell (1 * 1 degree,Long & Lat) of China with elevation values, Thank you for your time and help!它是中国的网格单元(1 * 1 度,经纬度),具有高程值,感谢您的时间和帮助!

Tao Liang陶亮

You can probably use rasterFromXYZ您可能可以使用rasterFromXYZ

Example data示例数据

library(raster)
r <- raster(nrow=5, ncol=5, xmn=0, xmx=10, ymn=0, ymx=10, crs="")
set.seed(1)
values(r) <- sample(1:25)
r[r < 15] <- NA
xyz <- rasterToPoints(r)

Solution解决方案

rst <- rasterFromXYZ(xyz)

Or with terra或与terra

library(terra)
x <- rast(xyz, type="xyz")

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

相关问题 在 R 中编码以打破经度、纬度、高度和时区 - Coding in R to break long, lat, altitude and timezone 在R中堆叠Raster:无法从该文件创建RasterLayer对象。 (文件不存在) - Stacking Raster in R: Cannot create a RasterLayer object from this file. (file does not exist) R 光栅错误:无法从此文件创建光栅层 object。 (文件不存在) - R Raster error: Cannot create a RasterLayer object from this file. (file does not exist) r 中数据帧中所有位置与 lat long 的距离(以公里为单位) - distance in kms from lat long for all locations in the dataframe in r 从状态组创建区域 lat、long dataframe - Create regional lat, long dataframe from group of states .rasterObjectFromFile(x, band = band, objecttype = "RasterLayer",: 无法从此文件创建 RasterLayer object - Error in .rasterObjectFromFile(x, band = band, objecttype = "RasterLayer",: Cannot create a RasterLayer object from this file 按条件重写 R 中栅格图层中的值 - Rewriting values in a rasterlayer in R by condition 从 R 中的 RasterLayer 中提取 ncell - Extract ncell from RasterLayer in R 使用 R 创建分类栅格值的直方图? (或者,使用经纬度值创建 data.table) - Use R to create a historgram of categorical raster values? (or, create data table with lat/long values) R中的lat长点簇的多边形 - polygon from cluster of lat long points in R
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM