2

I have 2 dataset of points, each one measures a different variable, i need to "merge"(not sure if it is the correct term) these two into one dataset.

My first instinct is to take a purple point find k closets green points and assign the average as the green dataset value for the purple point.

Example image of the points.

enter image description here

Is there a recommend method for this kind of problem?

Edit:

I am using R, but if there is not package that solves the problem i will be fine with a theoretical reference.

Edit 2:

Added code to generate an example, i would like a to know which methods are available and which ones are recommended for a case like this.

library(sf)


N_points <-  100
X_range <- c(0, 20)
Y_range <- c(0, 20)

set.seed(123)
df_1 <- data.frame(
x = truncnorm::rtruncnorm(n = N_points,  a=X_range[1], b=X_range[2], mean=10, sd=5),
y = truncnorm::rtruncnorm(n = N_points,  a=Y_range[1], b=Y_range[2], mean=10, sd=5),
value = rnorm(n = N_points, mean=7, sd=2)
)  %>%  st_as_sf(coords=c("x", "y"))


set.seed(753)
df_2 <- data.frame(
x = truncnorm::rtruncnorm(n = N_points,  a=X_range[1], b=X_range[2], mean=10, sd=5),
y = truncnorm::rtruncnorm(n = N_points,  a=Y_range[1], b=Y_range[2], mean=10, sd=5),
value = rnorm(n = N_points, mean=10, sd=2)
)  %>%  st_as_sf(coords=c("x", "y"))



plot(st_geometry(df_1), col="purple", axes = TRUE)
plot(st_geometry(df_2), col="green", add=T)

enter image description here

Edit 3, my description of the problem was not clear enough:

Example:

Each purple point represent a measure of air pollution.

Each green point represent a measure of radiation.

I want as result a datasets that has both a measure of radiation and a measure of air pollution for each point.

8
  • What GIS software are you using? If your question is theoretical then please make that clear and tag it with the gis-principle tag.
    – PolyGeo
    Commented May 1, 2021 at 4:20
  • 1
    Are you looking for an implementation of that "k nearest neighbours + averaging" thing specifically, or do you want a more general discussion of how to relate two point data sets? It would help if you could supply some data or show some code to generate a simple test data set so we can all work on it.
    – Spacedman
    Commented May 1, 2021 at 6:21
  • I'm not sure what class of general problem you are trying to solve. Taking the k-nearest and averaging is one thing, it does what it does. Quite what it means in terms of your underlying problem I don't know. What's the big question? How do these two sets of points relate in the real world?
    – Spacedman
    Commented May 1, 2021 at 13:00
  • @Spacedman, i never had this problem before so i am not sure if that is a good idea or there is "recommended way" to do it.
    – carlos
    Commented May 2, 2021 at 5:09
  • What I don't understand is what your problem is. You have two measurements of different variables and want to combine them into a single set of measurements of something? What's that "something" going to be? Suppose the first measurement is percentage of gold in a soil sample, and the second is percentage of silver - how does it make sense to merge them?
    – Spacedman
    Commented May 2, 2021 at 9:12

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.