0

I have an issue where I'm spatially joining points to grid squares, but sometimes they're just barely out of range. To address this, I want to identify which points become incorporated into these original grid cells, when applying a buffer of 15km.

What is the best way to go about this using the sf package? How do I create a new buffered-square join I can directly compare to the original squares? Particularly since this new buffered join will overlap several other grid cells, such that many points will be double or quadruple counted?

At the end of the day, I'd like to examine an object or dataframe that identifies every original square and the points that are 'missed' just outside it, within that 15km border.

enter image description here

enter image description here

enter image description here

library(tidyverse)
library(sf)
gridpolygons <- read_rds('Data/gridpolys.rds') %>% st_as_sf
gridpolygons.metersproj <- st_transform(gridpolygons, 32119)

# create 15 km buffer and transform back to wgs84
buffer15km <- st_buffer(
  gridpolygons.metersproj, dist = 15000) %>% st_transform(4326)

points <- st_as_sf(getPoints()) # Pulls shapefile of points into sf object
                                # (custom fn; then conversion to sf object)

# Original join
cell_points <- st_join(gridpolygons, points)

# Buffer object join? e.g.,
  # buffer_points <- st_join(buffer15km, points)#?
# Or alternate method to avoid double-counting, that I can compare
  # compare easily to first spatial join?
# Method that cuts a hole out of the buffered polygon 
  # to make a polygon that's just border, and then joins points with replacement?

The objective is to identify the points that are 'near misses' from being joined to each cell, or within 15km of the grid cell.

  • Could you compute all the distances of points to grid cell centres and assign points to the nearest grid cell centre? Apply a threshold if you dont want points far from the study area (two or three cell widths) to be assigned anywhere. – Spacedman Aug 13 '18 at 21:43
  • In theory I would use that method, but I'm looking for the points that aren't joined by a grid cell. I think method your would identify points located at the extremes of each cell internally, but wouldn't tell me about the near-miss points that weren't joined just outside the cell. Also, I'm not sure what you meant by study area, since I'm applying the grid across the entire continent and looking at each individual box's points. – ddheart Aug 21 '18 at 21:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.