我有 2 个列表,每个列表都包含 lat lon 数据,我如何找到最近的点并提取关于该点的数据?转换为栅格不是一种选择,因为网格是不规则的。非常感谢您提供简短的解决方案!(更多解释我在这篇文章底部尝试的内容。
这是我的位置的一个子集,创建于dput
structure(list(loc = c("X3205", "X3207", "X3505", "X3703", "X3900",
"X3904", "X3908", "X5702", "X6300"), lon = c(4.53499, 4.666667,
4.866667, 5.18683, 5.433333, 5.09513, 5.26176, 5.5, 5.233333),
lat = c(50.54652, 50.516667, 50.566667, 50.50415, 50.583333,
50.48941, 50.52974, 50.5, 50.5)), row.names = c(67L, 68L,
76L, 79L, 84L, 85L, 87L, 118L, 125L), class = "data.frame")
为此,我想从以下测量数据集中提取数据。
这是我的数据集,由 3 个子集组成,我将其中的一个子集呈现为dput
:
structure(list(lon = c(3.882, 3.9527, 4.0234, 4.0941, 4.1648,
4.2355, 4.3062, 4.3769, 4.4476, 4.5183, 4.589, 4.6597, 4.7303,
4.801, 4.8717, 4.9424, 5.0131, 5.0838, 5.1545, 5.2252, 5.2959,
5.3666, 5.4372, 5.5079, 5.5786, 5.6493, 5.72, 5.7906, 5.8613,
5.932, 6.0027, 6.0733, 6.144, 6.2146, 6.2853, 6.356, 3.2447,
3.3154, 3.3862, 3.4569, 3.5276, 3.5984, 3.6691, 3.7399, 3.8106,
3.8814, 3.9522, 4.0229, 4.0937, 4.1644, 4.2352, 4.306, 4.3767,
4.4475, 4.5182, 4.589, 4.6598, 4.7305, 4.8013, 4.872, 4.9428,
5.0136, 5.0843, 5.1551, 5.2258, 5.2966, 5.3673, 5.4381, 5.5088,
5.5796, 5.6503, 5.7211, 5.7918, 5.8626, 5.9333, 6.004, 6.0748,
6.1455, 6.2162, 3.2434, 3.3142, 3.385, 3.4558, 3.5267, 3.5975,
3.6683, 3.7391, 3.8099, 3.8808, 3.9516, 4.0224, 4.0932, 4.1641,
4.2349, 4.3057, 4.3765, 4.4474, 4.5182, 4.589, 4.6599, 4.7307
), lat = c(50.5005, 50.5009, 50.5012, 50.5015, 50.5018, 50.502,
50.5022, 50.5023, 50.5024, 50.5024, 50.5024, 50.5024, 50.5023,
50.5022, 50.502, 50.5018, 50.5015, 50.5012, 50.5009, 50.5005,
50.5001, 50.4996, 50.4991, 50.4985, 50.4979, 50.4973, 50.4966,
50.4959, 50.4951, 50.4943, 50.4934, 50.4925, 50.4916, 50.4906,
50.4896, 50.4885, 50.5401, 50.5408, 50.5416, 50.5423, 50.5429,
50.5435, 50.5441, 50.5446, 50.5451, 50.5455, 50.5459, 50.5462,
50.5465, 50.5468, 50.547, 50.5472, 50.5473, 50.5474, 50.5474,
50.5474, 50.5474, 50.5473, 50.5472, 50.547, 50.5468, 50.5465,
50.5462, 50.5459, 50.5455, 50.5451, 50.5446, 50.5441, 50.5435,
50.5429, 50.5423, 50.5416, 50.5408, 50.5401, 50.5393, 50.5384,
50.5375, 50.5366, 50.5356, 50.585, 50.5858, 50.5865, 50.5872,
50.5879, 50.5885, 50.589, 50.5895, 50.59, 50.5904, 50.5908, 50.5912,
50.5915, 50.5917, 50.5919, 50.5921, 50.5922, 50.5923, 50.5924,
50.5924, 50.5923, 50.5922), max = c(69.8, 89.87, 81.8, 83.24,
101.53, 129.56, 98.86, 94.85, 50.97, 87.48, 73.62, 74.68, 79.74,
73, 75.79, 77.54, 74.63, 77.67, 60.16, 53.93, 57.81, 54.35, 62.99,
75.25, 85.87, 90.97, 90.42, 84.59, 81.37, 91.79, 102.27, 112.65,
92.67, 83.83, 124.55, 127.97, 60.22, 59.97, 68.17, 74.03, 75.76,
55.08, 49.3, 56.24, 64.25, 72.38, 68.96, 69.79, 94.3, 97.99,
98.1, 89.85, 52.02, 62.04, 94.79, 78.62, 78.54, 96.59, 89.78,
79.85, 77.48, 81.23, 57.89, 55.99, 56.85, 64.92, 57.27, 62.63,
78.71, 93.67, 155.67, 150.61, 137.39, 73.28, 74.25, 88.43, 114.97,
107.97, 113.11, 62.95, 61.92, 63.33, 77.69, 83.84, 62.18, 53.65,
55.48, 57.77, 60.2, 55.9, 49.97, 93.09, 93.27, 92.66, 91.19,
50.13, 99.42, 103.45, 96.35, 99.75, 103.76)), row.names = 500:600, class = "data.frame")
对于每个位置,我想在最近的位置提取测量值。
我尝试用 library(raster) 对测量值进行光栅化,但没有成功,因为我正在处理不规则的网格。随后我尝试了库(akima),它可以很好地创建栅格,但我被困在提取数据点上。我回到列表,这些是我在这篇文章中粘贴的数据集。
我希望有人可以帮助解决这个请求。谢谢你。