[英]plot 4 points on a raster grid in R
I have four points that represent the locations of four air quality monitoring stations.我有四个点代表四个空气质量监测站的位置。 These four stations have the following parameters.这四个站具有以下参数。
Station Lat Long
1 Toronto Downtown 43.7 -79.4
2 Toronto East 43.7 -79.3
3 Toronto North 43.8 -79.5
4 Toronto West 43.7 -79.5
I want to create a raster that has the following parameters:我想创建一个具有以下参数的栅格:
dimensions : 14, 26, 364 (nrow, ncol, ncell)
resolution : 0.02, 0.02 (x, y)
extent : -79.64, -79.12, 43.58, 43.86 (xmin, xmax, ymin, ymax)
crs : +proj=longlat +datum=WGS84 +no_defs
I want to create a raster where the four stations are plotted in the cell that best represents their location.我想创建一个栅格,其中四个站点绘制在最能代表其位置的单元格中。 But the raster has to match the format I have provided.但是栅格必须与我提供的格式相匹配。 How can I do this?我怎样才能做到这一点?
It is not clear what your question is, but I am guessing that you have trouble mapping this because your data is "lat/lon", rather than "lon/lat".目前尚不清楚您的问题是什么,但我猜您无法映射此问题,因为您的数据是“纬度/经度”,而不是“经度/纬度”。 You can solve that like this:你可以这样解决:
library(terra)
r <- rast(nrow=24, ncol=26, xmin=-79.64, xmax=-79.12, ymin=43.58, ymax=43.86)
values(r) <- 1:ncell(r)
d <- data.frame(Station=c("D", "E", "N", "W"), Lat=c(43.7,43.7,43.8,43.7), Lon=c(-79.4,-79.3,-79.5,-79.5))
plot(r)
points(d[, c("Lon", "Lat")])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.