简体   繁体   中英

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. 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. cell upto 10000 sq km.

Firstly, your syntax in calling autoKrige is not correct, it should be:

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 .

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 . So, if you want to predict on irregular points, simply create a SpatialPoints object with the locations and pass it to autoKrige .

In regard to calculation time, 900.000 points is a large dataset. 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. These are part of the ... , and are passed on to krige from the gstat package.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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