{"id":21425278,"url":"https://github.com/sodascience/osmenrich","last_synced_at":"2025-04-12T08:13:24.968Z","repository":{"id":45314402,"uuid":"337555188","full_name":"sodascience/osmenrich","owner":"sodascience","description":"Enrich sf data with geographic features from OpenStreetMaps.","archived":false,"fork":false,"pushed_at":"2021-12-21T22:35:18.000Z","size":14466,"stargazers_count":15,"open_issues_count":4,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-12T08:13:18.044Z","etag":null,"topics":["geospatial","geospatial-data","odissei","osm","sf","utrecht-university"],"latest_commit_sha":null,"homepage":"https://sodascience.github.io/osmenrich/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sodascience.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null}},"created_at":"2021-02-09T22:36:44.000Z","updated_at":"2024-10-06T11:04:07.000Z","dependencies_parsed_at":"2022-09-01T22:20:58.400Z","dependency_job_id":null,"html_url":"https://github.com/sodascience/osmenrich","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sodascience%2Fosmenrich","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sodascience%2Fosmenrich/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sodascience%2Fosmenrich/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sodascience%2Fosmenrich/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sodascience","download_url":"https://codeload.github.com/sodascience/osmenrich/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248537144,"owners_count":21120711,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["geospatial","geospatial-data","odissei","osm","sf","utrecht-university"],"created_at":"2024-11-22T21:27:39.185Z","updated_at":"2025-04-12T08:13:24.943Z","avatar_url":"https://github.com/sodascience.png","language":"R","funding_links":[],"categories":["Projects"],"sub_categories":["Research software"],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd--\u003e\n\n```{r, echo = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/\"\n)\n```\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/sodascience/osmenrich\"\u003e\n    \u003cimg width=\"30%\" height=\"30%\" src=\"man/figures/logo.png\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n# osmenrich: enrich geocoded data using OpenStreetMap\n\n\u003c!-- badges: start --\u003e\n[![Github Action test](https://github.com/sodascience/osmenrich/workflows/R-CMD-check/badge.svg)](https://github.com/sodascience/osmenrich/actions)\n[![DOI](https://zenodo.org/badge/337555188.svg)](https://zenodo.org/badge/latestdoi/337555188)\n[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)\n\u003c!-- badges: end --\u003e\n\nThe goal of `osmenrich` is to easily enrich geocoded data\n(`latitude`/`longitude`) with geographic features from OpenStreetMap (OSM).\nThe main language of the package is `R` and this package is designed to work\nwith the [`sf`](https://r-spatial.github.io/sf/) and [`osmdata`](\nhttps://cran.r-project.org/web/packages/osmdata/vignettes/osmdata.html)\npackages for collecting and manipulating geodata.\n\n## Installation\n\nTo install the package, you first need to have the `remotes` package installed.\nIf you do not have this package yet, please install it first with:\n\n```r\ninstall.packages(\"remotes\")\n```\n\nIf you do have this package, due to recent changes in GitHub's naming of branches,\nplease make sure you have the latest version of `remotes` or at least version\n`2.2`.\n\nOnce you did this, to continue the installation of the `osmenrich` package, run:\n\n```r\nremotes::install_github(\"sodascience/osmenrich@main\")\n```\n\nor, for the development version, run:\n\n```r\nremotes::install_github(\"sodascience/osmenrich@develop\")\n```\n\nThis will use the default public APIs for OSM data and routing (for computing\ndriving/walking distances and durations). __Do not use `osmenrich` with\ndefault APIs for large datasets!__ If you want to learn how to use `osmenrich`\nfor large queries follow the instructions in section\n[Local API Setup](#local-api-setup) below.\n\n## Usage\n\n### Simple enrichment example\n\nLet's enrich a spatial (`sf`) dataset (`sf_example`) with the number of waste\nbaskets in a radius of 500 meters from each of the point specified in a\ndataset:\n\n```r\n# Import libraries\nlibrary(tidyverse)\nlibrary(sf)\nlibrary(osmenrich)\n\n# Create an example dataset to enrich\nsf_example \u003c-\n  tribble(\n    ~person,  ~lat,   ~lon,\n    \"Alice\",  52.12,  5.09,\n    \"Bob\",    52.13,  5.08,\n  ) %\u003e%\n  sf::st_as_sf(\n    coords = c(\"lon\", \"lat\"),\n    crs = 4326\n  )\n\n# Print it\nsf_example\n#\u003e Simple feature collection with 2 features and 1 field\n#\u003e geometry type:  POINT\n#\u003e dimension:      XY\n#\u003e bbox:           xmin: 5.08 ymin: 52.12 xmax: 5.09 ymax: 52.13\n#\u003e CRS:            EPSG:4326\n#\u003e # A tibble: 2 x 2\n#\u003e   person     geometry\n#\u003e * \u003cchr\u003e   \u003cPOINT [°]\u003e\n#\u003e 1 Alice  (5.09 52.12)\n#\u003e 2 Bob    (5.08 52.13)\n```\n\nTo enrich the `sf_example` dataset with \"waste baskets\" in a 500m radius, you\ncan create a query using the `enrich_osm()` function. This function uses the\nbounding box created by the points present in the example dataset and searches\nfor the specified `key = \"amenity\"` and `value = \"waste_basket`. You can also add a\ncustom `name` for the newly created column and specify the radius (`r`) used\nin the search. See\n[Map Features on the website of OSM](https://wiki.openstreetmap.org/wiki/Map_features)\nfor a complete list of `key` and `value` combinations.\n\n```r\n# Simple OSMEnrich query\nsf_example_enriched \u003c- sf_example %\u003e%\n  enrich_osm(\n    name = \"n_waste_baskets\",\n    key = \"amenity\",\n    value = \"waste_basket\",\n    r = 500\n  )\n#\u003e Downloading data for waste_baskets... Done.\n#\u003e Downloaded 147 points, 0 lines, 0 polygons, 0 mlines, 0 mpolygons.\n#\u003e Computing distance matrix for n_waste_baskets...Done.\n```\n\nThe resulting enriched dataset `sf_example_enriched` is a `sf` object and can be printed as usual\nto inspect the newly added column `n_waste_baskets`.\n\n```r\nsf_example_enriched\n#\u003e Simple feature collection with 2 features and 2 fields\n#\u003e geometry type:  POINT\n#\u003e dimension:      XY\n#\u003e bbox:           xmin: 5.08 ymin: 52.12 xmax: 5.09 ymax: 52.13\n#\u003e geographic CRS: WGS 84\n#\u003e # A tibble: 2 x 3\n#\u003e   person     geometry n_waste_baskets\n#\u003e * \u003cchr\u003e   \u003cPOINT [°]\u003e         \u003cint\u003e\n#\u003e 1 Alice  (5.09 52.12)            75\n#\u003e 2 Bob    (5.08 52.13)             1\n```\n\nThe waste baskets column is now the result of summing all the wastebaskets in a 500 meter radius for Alice and Bob:\n\n![](man/figures/example_wastebaskets_r500.png)\n\n## Local API setup\n\nOSM enrichment can ask for a lot of data, which can overload public APIs. If\nyou intend to enrich large amounts of data or compute routing distances (e.g.,\ndriving duration) between many points, you should set up a local API endpoint.\n\nMultiple `docker-compose` workflows for doing this are avaialble in the separate\n[osmenrich_docker\nrepository](https://github.com/sodascience/osmenrich_docker). Use the `README`\nin the repository to select the workflow that fits your desired outcome.\n\n\u003cimg src=\"man/figures/docker.png\" alt=\"Docker logo\" width=\"250px\"/\u003e\n\n\u003c!-- CONTRIBUTING --\u003e\n## Contributing\n\nContributions are what make the open source community an amazing place to\nlearn, inspire, and create. Any contributions you make are **greatly\nappreciated**.\n\nPlease refer to the [CONTRIBUTING](https://github.com/sodascience/osmenrich/blob/main/CONTRIBUTING.md) \nfile for more information on issues and pull requests.\n\n## License and citation\n\nThe `osmenrich` package is published under the MIT license. When using\n`osmenrich` for academic work, please cite:\n\n```\nvan Kesteren, Erik-Jan, Vida, Leonardo, de Bruin, Jonathan, \u0026 Oberski, Daniel. (2021, February 11).\nEnrich sf Data with Geographic Features from OpenStreetMaps (Version v1.0). Zenodo. http://doi.org/10.5281/zenodo.4534188\n```\n\n\u003c!-- CONTACT --\u003e\n## Contact\n\nThis package is developed and maintained by the [ODISSEI Social Data Science\n(SoDa)](https://odissei-data.nl/nl/soda/) team.\n\nDo you have questions, suggestions, or remarks? File an issue in the issue\ntracker or feel free to contact [Erik-Jan van\nKesteren](https://github.com/vankesteren)\n([@ejvankesteren](https://twitter.com/ejvankesteren)) or [Leonardo\nVida](https://github.com/leonardovida)\n([@leonardojvida](https://twitter.com/leonardojvida))\n\n\u003cimg src=\"man/figures/word_colour-l.png\" alt=\"SoDa logo\" width=\"250px\"/\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsodascience%2Fosmenrich","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsodascience%2Fosmenrich","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsodascience%2Fosmenrich/lists"}