简体   繁体   English

将点映射到网格以在地图上绘制密度

[英]Mapping points to grid to plot density on a map

I have a dataset of 900K randomly sampled coordinate points with a value associated with each point. 我有一个900K随机采样的坐标点的数据集,每个点都有一个关联的值。 I want to make a grid on the map and assign each cell the avg value of all the points that lie within the cell. 我想在地图上制作一个网格,并为每个单元格分配该单元格内所有点的平均值。 Finally I want to plot the grid as a heatmap. 最后,我想将网格绘制为热图。

The resolution of the grid could be 100 sq. km. 网格的分辨率可能是100平方公里。 cell upto 10000 sq km. 小区最大10000平方公里

Firstly, your syntax in calling autoKrige is not correct, it should be: 首先,您调用autoKrige的语法不正确,应为:

kr <- autoKrige(mean_week1~1,project_df)

The formula argument never contains a vector, it always contains column names from the attributes in project_df . formula参数从不包含向量,它始终包含来自project_df属性的列名。

autoKrige can predict on any Spatial* object, eg SpatialGrid or SpatialPoints , simply pass the object you want to predict on to the new_data argument of autoKrige . autoKrige可以在任何Spatial*对象(例如SpatialGridSpatialPoints上进行预测,只需将要预测的对象传递给autoKrigenew_data参数autoKrige So, if you want to predict on irregular points, simply create a SpatialPoints object with the locations and pass it to autoKrige . 因此,如果要预测不规则点,只需创建一个具有位置的SpatialPoints对象并将其传递给autoKrige

In regard to calculation time, 900.000 points is a large dataset. 关于计算时间,900.000点是一个大型数据集。 You can limit the amount of data that is used for predictions by using the nmax (max number of points used) or the maxdist (maximum distance up to which points are used) arguments. 您可以通过使用nmax (使用的最大点数)或maxdist (使用的最大点数的最大距离)参数来限制用于预测的数据量。 These are part of the ... , and are passed on to krige from the gstat package. 这是部分... ,并传递给krigegstat包。

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

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