Hello, I am trying to query in a spatial data set where overlapping points
exist between two data sets, and then average between these two data sets in
R.

 

The problem is that my data sets have slightly difference spatial arrays -
therefore when I go to subtract them, I get an error.

 

The data sets are set up as follows, columns of - Lat, Long, 10, 11, 12, 1,
2, 3, 4, 5, 6, 7, 8, 9 (which represent months in the year)

 

Here is the portion of my script that does this. I've played around with
overlay and merge, but neither seems to do what I want to do - just extract
and then calculate on the common data points between these two files.

 

 

 

require(sp)

for (region in regions){

          #Create an empty holder

          monthly_variables = NULL

          

          #Clip regions (have to examine maptools package)

          clip_variance <- clip(cbind(variances, io =
point.in.polygon(variances$Long, variances$Lat,
shape$shp$shp[[region]]$points$X, shape$shp$shp[[region]]$points$Y)))

          clip_normal <- clip(cbind(normals, io =
point.in.polygon(normals$Long, normals$Lat,
shape$shp$shp[[region]]$points$X, shape$shp$shp[[region]]$points$Y)))

          #HERE IS WHERE I WANT TO SELECT AND CALCULATE DIFFERENCES ONLY ON
THE POINTS THAT MATCH in X, Y SPACE

      

          # calculate differences, sd (in the time domain) for the 

            for (month in 1:12){

             # generate anomalies

              

              monthly_anom <- clip_variance[, 3:ncol(clip_variance)] -
clip_normal[, 3:ncol(clip_normal)]

              

              monthly_variables <- rbind(monthly_variables, c(Lat = Lat,
Long = Long, monthly_anom = monthly_anom))

        

            }


	[[alternative HTML version deleted]]


