Created
July 12, 2020 16:32
-
-
Save paleolimbot/38e7442a4f97126491e2520a163f6bc3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(sf) | |
library(geos) | |
states <- readRDS(url("https://biogeo.ucdavis.edu/data/gadm3.6/Rsf/gadm36_USA_1_sf.rds")) | |
counties <- readRDS(url("https://biogeo.ucdavis.edu/data/gadm3.6/Rsf/gadm36_USA_2_sf.rds")) | |
states_sfc <- states$geometry %>% st_set_crs(NA) | |
states_wkb <- st_as_binary(states_sfc) | |
states_geos <- geos_read_wkb(states_wkb) | |
counties_sfc <- counties$geometry %>% st_set_crs(NA) | |
counties_wkb <- st_as_binary(counties_sfc) | |
counties_geos <- geos_read_wkb(counties_wkb) | |
vt_sfc <- states_sfc[states$NAME_1 == "Vermont"] | |
vt_wkb <- states_wkb[states$NAME_1 == "Vermont"] | |
vt_geos <- states_geos[states$NAME_1 == "Vermont"] | |
add_sfc <- counties_sfc[counties$NAME_1 == "Vermont" & counties$NAME_2 == "Addison"] | |
add_wkb <- st_as_binary(add_sfc) | |
add_geos <- geos_read_wkb(add_wkb) | |
bench::mark( | |
st_intersects(states_sfc, vt_sfc), | |
geos_intersects(states_geos, vt_geos), | |
min_time = 10, | |
check = FALSE | |
) | |
bench::mark( | |
st_intersects(counties_sfc, add_sfc), | |
geos_intersects(counties_geos, add_geos), | |
min_time = 10, | |
check = FALSE | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Created on 2020-07-12 by the reprex package (v0.3.0)