library(microbenchmark)
library(sf)
#> Linking to GEOS 3.11.0, GDAL 3.5.3, PROJ 9.1.0; sf_use_s2() is TRUE
# pak::pkg_install('geoarrow/geoarrow-r@v0.1.0')
# https://github.com/geoarrow/geoarrow-r/issues/28
library(geoarrow)
nc <- st_read(system.file("shape/nc.shp", package="sf"))
#> Reading layer `nc' from data source
This file contains hidden or 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
| # Generic helpers for keeping a hosted ArcGIS feature layer or table in sync | |
| # with a data frame or sf object, named and shaped like the editing functions | |
| # in arcgislayers (`x`, `.data`, `token`). Nothing here refers to Baltimore CIP | |
| # fields or layers, so the file can be copied to another pipeline or | |
| # contributed upstream; project-specific code is in R/location-arcgis.R. See | |
| # docs/guides/publishing-arcgis-locations.md. | |
| #' Check whether publishing to ArcGIS Online is turned on | |
| #' | |
| #' [sync_arcgis_service()] only edits the service when this is `TRUE`. Turn it |
This file contains hidden or 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
| tt_group <- function(x, ..., by = NULL, hide_group = TRUE) { | |
| x <- dplyr::group_by(x, {{ by }}) | |
| vars <- dplyr::group_vars(x) | |
| # Error if more than a single group is supplied | |
| stopifnot(rlang::has_length(vars, 1)) | |
| x <- dplyr::arrange( | |
| dplyr::ungroup(x), | |
| .data[[vars]] |
This file contains hidden or 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
| #' Create a GeocodeServer using the Baltimore City EGIS Composite Locator | |
| #' @noRd | |
| egis_geocode_server <- function( | |
| url = NULL, | |
| token = arcgisutils::arc_token()) { | |
| url <- url %||% | |
| "https://egis.baltimorecity.gov/egis/rest/services/Locator/EGISCompositeLocator/GeocodeServer" | |
| arcgisgeocode::geocode_server( | |
| url = url, |
This file contains hidden or 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
| # --- | |
| # repo: elipousson/baltimoreplanning | |
| # file: standalone-baltimore-gis.R | |
| # last-updated: 2025-05-28 | |
| # license: https://creativecommons.org/publicdomain/zero/1.0/ | |
| # imports: [arcgisutils, arcgisgeocode] | |
| # --- | |
| # ## Changelog | |
| # | |
| # 2025-05-28: |
This file contains hidden or 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
| st_join_list <- function( | |
| x, | |
| y, | |
| ..., | |
| join = sf::st_intersects, | |
| .id = "name" | |
| ) { | |
| if (!inherits(y, "list") && inherits(y, "sf")) { | |
| y <- list(y) | |
| } |
This file contains hidden or 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
| make_worksheet_questions <- function(range = c(0:25), | |
| ops = c("+", "+", "+", "-", "-", "x"), | |
| n = 30, | |
| allow_neg = FALSE) { | |
| lhs <- sample(range, n, replace = TRUE) | |
| rhs <- sample(range, n, replace = TRUE) | |
| ops <- sample(ops, n, replace = TRUE) | |
| if (!allow_neg) { | |
| for (i in seq(n)) { |
This file contains hidden or 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(tictoc) | |
| library(sf) | |
| # pak::pkg_install('geoarrow/geoarrow-r@v0.1.0') | |
| # https://github.com/geoarrow/geoarrow-r/issues/28 | |
| library(geoarrow) | |
| tf_parquet <- tempfile(fileext = ".parquet") | |
| tf_gpkg <- tempfile(fileext = ".gpkg") | |
| nc <- st_read(system.file("shape/nc.shp", package="sf")) |
This file contains hidden or 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
| #' Safely use spdep::poly2nb and spdep::n.comp.nb to get an index of neighboring | |
| #' features | |
| #' | |
| #' [spdep::poly2nb()] errors if no neighboring features exist. This wrapper | |
| #' function returns a vector of the same length as x with the integer 0 for any | |
| #' input object that typically errors. Adapted from code by Josiah Parry | |
| #' inspired by work from CGMossa. | |
| #' | |
| #' @source <https://github.com/r-spatial/sf/issues/2422#issue-2459271220> | |
| #' @inheritParams x A sf or sfc object |
This file contains hidden or 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
| test_list <- list( | |
| 1, | |
| c(1, 2), | |
| c(2, 3), | |
| c(3, 4), | |
| 4, | |
| 5 | |
| ) | |
| map( |
NewerOlder