Skip to content

Repository files navigation

spatialops

Lifecycle: experimental R-CMD-check

Spatialops: spatial operations that come in handy

Built mainly upon the {sf} and {tidyverse} frameworks, the functions in this package range from simple reading/tidying wrappers to specific spatial operations and random utilities I have used along my journey. Some use cases:

  • read shapefiles directly from a .zip whithout creating a mess in your folders with shp_extract_read
  • calculate the distance between the closest y feature from an x set of features with dist_nearest
  • need to manually tidy your shapefiles (e.g. nudge a geometry)? No problem, load them into MapHub and then convert the description into useful columns using maphub_to_sf
  • ggplot quantile regression coefficients with coef_rqs

Installation

You can install the development version of spatialops with remotes:

remotes::install_github("https://github.com/baarthur/spatialops")

Example

Find the distance to the closest subway station in each neighborhood in Fortaleza (Brazil). Very useful in hedonic models and other (spatial) econometric analysis.

library(spatialops)
data("fortaleza")
data("metrofor")

# select only stations
metrofor <- dplyr::filter(metrofor, railway == "station")

fortaleza <- fortaleza %>% 
  dist_nearest(metrofor, name = dist_metro)

About

My functions used in the dissertation and elsewhere

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages