From c716adcc5e301381968d5f1f6e30393b53f1e075 Mon Sep 17 00:00:00 2001 From: ischlo Date: Thu, 31 Oct 2024 18:50:30 +0000 Subject: [PATCH] latest updates of website --- R/osmium_installed.R | 2 +- docs/articles/road_networks.html | 8 +++----- docs/index.html | 25 ++++++++++++++----------- docs/pkgdown.yml | 2 +- docs/search.json | 2 +- vignettes/road_networks.Rmd | 3 ++- 6 files changed, 22 insertions(+), 20 deletions(-) diff --git a/R/osmium_installed.R b/R/osmium_installed.R index f8cbc11..3d70d6f 100644 --- a/R/osmium_installed.R +++ b/R/osmium_installed.R @@ -17,7 +17,7 @@ assert_tool_is_installed <- function(tool) { cli::cli_abort( glue::glue("Could not find `{tool}` in system." - ,"Please make sure it has been installed and added to PATH."), + ,"Make sure it has been installed and added to PATH."), ) } diff --git a/docs/articles/road_networks.html b/docs/articles/road_networks.html index dbb8630..597487a 100644 --- a/docs/articles/road_networks.html +++ b/docs/articles/road_networks.html @@ -81,8 +81,6 @@ -
## [1] TRUE
-
## [1] TRUE

Description

@@ -162,7 +160,7 @@

Example workflow

Once the package and dependencies are installed, the workflow is the following:

-
+
 library(cppRosm)
 ## basic example code
 
@@ -171,7 +169,7 @@ 

Example workflowcppRosm::extract_graph(file)

## Files will be written to:  /Users/cenv1069/Documents/packages/cppRosm/vignettes
## [1] 1
-
+
 # .... 
 
 nodes <- data.table::fread('nodes.csv')
@@ -294,7 +292,7 @@ 

Source of failure
+
 rosmium::extract(
   input_path = ".../map.osm"
   ,extent = sf::st_bbox() # a bbox
diff --git a/docs/index.html b/docs/index.html
index 4e843bb..485e2a5 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -67,9 +67,7 @@
   
-

Ivann Schlosser

- - +

Introduction @@ -79,7 +77,9 @@

Introduction

Setup dependencies

-

This section is under development, it will be a quick setup guide for the compiled dependencies.

+

The usage of cppRosm relies on the libosmium library. The necessary compiled code dependencies come with the package, facilitating it’s use.

+ + @@ -89,24 +89,27 @@

Setup dependencies

Installation

-

The usage of cppRosm relies on the libosmium library, which needs to be installed on the machine. For more details on installation refer to the official website. On mac, it is recommended to install using brew with the following terminal command:

-
brew install libosmium
-

Next, install the package itself from github:

-
+
+
+
+
+

Install the package from github:

+
 # remotes::install_github('ischlo/cppRosm')
 # devtools::install_github('ischlo/cppRosm')
 # pak::pak("ischlo/cppRosm")
-

The package will detect the presence of the library and notify you if it doesn’t see it. Once the library is installed, you will need a OSM extract file, you can get one by manually exporting a selected area from OSM, or for bigger areas, the best approach is to download a geofabrick extract.

+ +

Once the library is installed, you will need a OSM extract file, you can get one by manually exporting a selected area from OSM, or for bigger areas, the best approach is to download a geofabrick extract.

Notes

-

This is a early stage development package that could develop more functionalities for integrating the extremely performant osmium library with a user friendly R workflow. The choice has been made for graph data, to first export it to .csv files and only after reading it into R. This is to avoid potentially creating files that are to big to be handled by the R environment, while still extracting the data. However, this process can fail sometimes, resulting in loss of unsaved data in the active R environment. Best practices and the optimal workflows are covered in a separate vignette.

+

This is a early stage development package that could develop more functionalities for integrating the extremely performant osmium library with a user friendly R workflow. The choice has been made for graph data to first export it to .csv files and only after reading it into R. This is to avoid potentially creating files that are to big to be handled by the R environment, while still extracting the data. However, this process can fail sometimes, resulting in loss of unsaved data in the active R environment. Best practices and the optimal workflows are covered in a separate vignette.

References

-

There are a few great packages for working with OSM data, they all provide a wide set of functionalities. If the size of your data is not excessive, like small city-village scale, osmdata might be your tool of choice in R. If the data gets bigger, osmextract could be the right choice. This package aims to be both user friendly and flexible, but also high performing.

+

There are a few great packages for working with OSM data, they all provide a wide set of functionalities. If the size of your data is not excessive, like small city/village scale, osmdata might be your tool of choice in R. If the data gets bigger, osmextract could be the right choice. This package aims to be both user friendly and flexible, but also high performing.

diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 7fdff7a..df2ded1 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -4,7 +4,7 @@ pkgdown_sha: ~ articles: data_schema: data_schema.html road_networks: road_networks.html -last_built: 2024-10-02T17:21Z +last_built: 2024-10-31T18:48Z urls: reference: https://ischlo.github.io/cppRosm/reference article: https://ischlo.github.io/cppRosm/articles diff --git a/docs/search.json b/docs/search.json index 5d9cd17..dfc322c 100644 --- a/docs/search.json +++ b/docs/search.json @@ -1 +1 @@ -[{"path":"https://ischlo.github.io/cppRosm/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2024 cppRosm authors Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://ischlo.github.io/cppRosm/articles/data_schema.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"An opinionated way of working with OSM data","text":"Anyone used OpenStreetMap (OSM) data R python might agree tagging system, provides great flexibility extensive classification options, sometimes bit challenging work . vignettes explain approach tagging system aims make easy interact features, associated tags geometries. main ambition providing easy access large OSM data sets.","code":""},{"path":"https://ischlo.github.io/cppRosm/articles/data_schema.html","id":"osm-tags","dir":"Articles","previous_headings":"","what":"OSM tags","title":"An opinionated way of working with OSM data","text":"tag tuple values, first element called \\(key\\), second corresponding \\(value\\). Together, form tag written \\(key=value\\) form. key corresponds broad classification, value specific. example \\(amenity=restaurant\\). \\(key\\) \\(amenity\\), \\(value\\) \\(restaurant\\). Generally, values corresponding key. - Every OSM feature consists set nodes set tags. nodes geographically referenced, means associated coordinates, allowing reconstruct geometry feature. detailed list possible values recommendations available following article : OSM map features.","code":""},{"path":"https://ischlo.github.io/cppRosm/articles/data_schema.html","id":"different-data-types","dir":"Articles","previous_headings":"","what":"Different data types","title":"An opinionated way of working with OSM data","text":"develop appropriate tools work OSM data, important look kind data actually format useful. Mainly two types data can divided:","code":""},{"path":"https://ischlo.github.io/cppRosm/articles/data_schema.html","id":"network","dir":"Articles","previous_headings":"Different data types","what":"Network","title":"An opinionated way of working with OSM data","text":"First, one main use OSM data obtain connected routable road networks, easy use function called extrat_graph . See corresponding vignette details. road network data grouped \\(highway\\) key. categories roads (residential,motorway,pedestrian etc…) values key.","code":""},{"path":"https://ischlo.github.io/cppRosm/articles/data_schema.html","id":"non-network","dir":"Articles","previous_headings":"Different data types","what":"Non network","title":"An opinionated way of working with OSM data","text":"rest data OSM usually represented either point polygon set associated tags. can multiple tags associated feature, one might interested values specific one. , however, intrinsic hierarchy tags, can useful extracting data user friendly exploitable way.","code":""},{"path":"https://ischlo.github.io/cppRosm/articles/data_schema.html","id":"tagging-hierarchy","dir":"Articles","previous_headings":"","what":"Tagging hierarchy","title":"An opinionated way of working with OSM data","text":"package proposes 2 level hierarchy tags, helps extract data large data.tables data.frames high level tags added column variables, secondary tags grouped named lists added separate column called attrs. main consideration tags add information , complimentary sense feature, grouped 2nd level schema. also tags mutually exclusive, example tag \\(amenity\\) key generally \\(healthcare\\) key since different types features. can 2nd level keys address, name, phone number specific information.","code":""},{"path":"https://ischlo.github.io/cppRosm/articles/data_schema.html","id":"st-level","dir":"Articles","previous_headings":"Tagging hierarchy","what":"1st level","title":"An opinionated way of working with OSM data","text":"first level corresponds main tags. taken following list:","code":"main_first_level <- c( \"amenity\" ,\"craft\" ,\"healthcare\" ,\"historic\" ,\"sport\" ,\"natural\" ,\"shop\" ,\"tourism\" )"},{"path":"https://ischlo.github.io/cppRosm/articles/data_schema.html","id":"nd-level","dir":"Articles","previous_headings":"Tagging hierarchy","what":"2nd level","title":"An opinionated way of working with OSM data","text":"Everything else left second level tags, example: \\(addr:street\\) specific key address feature. generally scarce. \\(leisure\\) key overlaps lot \\(sport\\) key. generally contains specific information type sport.","code":""},{"path":"https://ischlo.github.io/cppRosm/articles/data_schema.html","id":"explanation","dir":"Articles","previous_headings":"Tagging hierarchy","what":"Explanation","title":"An opinionated way of working with OSM data","text":"Accounting fact OSM data crowd sourced therefore somewhere exception kind rules can imposed data, one can still observe certain patterns generally true, 2 level hierearchy tags aims capture. observations : Tend mutually exclusive Provide certain amount information, remain sufficiently broad. lot specific complement Arguably, tags don’t fall categories, can still export export_data function, tag can \\(building\\) key. qualifies layer data, much like road network.","code":""},{"path":"https://ischlo.github.io/cppRosm/articles/data_schema.html","id":"example","dir":"Articles","previous_headings":"","what":"Example","title":"An opinionated way of working with OSM data","text":"default, tags keys \\(amenity,shop,tourism\\) extracted. geometry simplified centroid, coordinates provided lon,lat columns data table. function allowing reconstruct full geometry provided, since necessarily always usefull , ommited first extraction. nodes constitute full geometry, complex point, added attrs column data.frame. geometries always closed, meaning polygons. meant save memory especially large data sets. data format, can now easily manipulate POIs, select specific keys, specific values, .","code":"library(cppRosm) library(sf) ## Linking to GEOS 3.11.0, GDAL 3.5.3, PROJ 9.1.0; sf_use_s2() is TRUE test_file <- system.file(package = 'cppRosm','extdata','map.osm') data <- cppRosm::extract_data(test_file) ## → Using main keys `amenity`,`shop`,`tourism`. head(data) |> knitr::kable(digits = 3) # filer by key data[key==\"amenity\",] |> head() |> knitr::kable(digits = 3) # filter by value data[value==\"restaurant\",] |> head() |> knitr::kable(digits = 3) # both: use or to include specific values of different keys and keys data[key==\"shop\" | value==\"restaurant\",] |> head() |> knitr::kable(digits = 3)"},{"path":"https://ischlo.github.io/cppRosm/articles/data_schema.html","id":"filtering-2nd-level-tags","dir":"Articles","previous_headings":"","what":"Filtering 2nd level tags","title":"An opinionated way of working with OSM data","text":"function efficiently filter secondary tags returns data frame, searched key added column feature non-NA match. hood, values matched using regular expressions, maximises chance finding desired values sometimes complicated OSM values.","code":"data |> cppRosm::filter_sec(keys=c(\"cuisine\",\"takeaway\") ,cores=1) |> head() |> knitr::kable(digits = 3) data |> cppRosm::filter_sec(keys=list(\"cuisine\"=c(\"japanese\",\"pizza\") ,\"takeaway\"=c(\"yes\")) ,cores = 1) |> head() |> knitr::kable(digits = 3) ## ℹ Searching for exact key~value matches."},{"path":"https://ischlo.github.io/cppRosm/articles/data_schema.html","id":"geometries","dir":"Articles","previous_headings":"","what":"Geometries","title":"An opinionated way of working with OSM data","text":"lot cases, knowing centroids POIs enough: times original geometry might interest, case use construct_geom function:","code":"data |> sf::st_as_sf(coords=c(\"lon\",\"lat\"),crs=4326) |> sf::st_geometry() |> plot(pch=19) # or same result, keeping the original data a `data.table` # data |> # cppRosm::construct_geom() |> # sf::st_as_sf() |> # sf::st_geometry() |> # plot() data_geom <- data |> cppRosm::construct_geom(complete = TRUE,cores = 1) |> sf::st_as_sf() data_geom |> sf::st_geometry() |> plot(pch=19)"},{"path":"https://ischlo.github.io/cppRosm/articles/data_schema.html","id":"buildings","dir":"Articles","previous_headings":"","what":"Buildings","title":"An opinionated way of working with OSM data","text":"discussed earlier, tags withe \\(building\\) key arguably fall neither categories, sense constitute data layer, just like road network. can still queried extracted extract_data function. function run fraction seconds extract buildings file. provide centroid direct access: can reconstruct geometries data hidden attrs follows: can filter specific tags: observe mutually exclusive nature \\(amenity\\) \\(shop\\) keys, justifying earlier discussion differentiation \\(building\\) key. intersection two keys famous french bar-tabac, bar place buy tobacco/cigarettes. specific filtering: searching specific \\(key=value\\) one tag values another tag, consider trick . ’s generally recommended extract building layer together main keys.","code":"buildings <- cppRosm::extract_data(test_file,main_keys = \"building\") buildings |> cppRosm::construct_geom() |> sf::st_set_geometry(\"geometry\") |> sf::st_geometry() |> plot(pch=19) buildings |> cppRosm::construct_geom(complete = TRUE,cores=1) |> sf::st_as_sf() |> sf::st_geometry() |> plot(pch=19) buildings |> cppRosm::filter_sec(keys=c(\"shop\",\"amenity\")) |> dplyr::select(!attrs) |> head() |> knitr::kable(digits = 3) buildings |> cppRosm::filter_sec(keys = list(\"tourism\" = c(\"\") ,\"abandoned\" = c(\"yes\"))) |> dplyr::select(!attrs) |> head() |> knitr::kable(digits = 3) ## ℹ Searching for exact key~value matches."},{"path":"https://ischlo.github.io/cppRosm/articles/data_schema.html","id":"alternatives","dir":"Articles","previous_headings":"","what":"Alternatives","title":"An opinionated way of working with OSM data","text":"osmdata: great package used lot, found frustrating different geometries gathered separate tables, table containing huge numbers NA columns. attrs column cppRosm table provides alternative way store secondary tags. Additionally, geometries simplified centroid, possibility reconstruct original ones provided construct_geom function. osmextract: great working large OSM files. filtering features remains bit obscure opinion, although seems provide great flexibility, requires good knowledge OSM internals.","code":""},{"path":"https://ischlo.github.io/cppRosm/articles/data_schema.html","id":"conclusion","dir":"Articles","previous_headings":"","what":"Conclusion","title":"An opinionated way of working with OSM data","text":"vignette aimed explain approach taken manipulating OSM data scale flexibility specific data table format supporting functions. Please reach recommendations, feature additions etc… another vignette, recommended workflow covered, package developed others mind (rosmium,cppRouting mainly) , network POI analysis done scale local setup.","code":""},{"path":"https://ischlo.github.io/cppRosm/articles/road_networks.html","id":"description","dir":"Articles","previous_headings":"","what":"Description","title":"Extracting road networks","text":"mini-package provides fast, yet user-friendly way exporting large road network data graph-like format. uses libosmium library background proposes simple R function extract road graph .osm, .osm.pbf extract file OSM data.","code":""},{"path":"https://ischlo.github.io/cppRosm/articles/road_networks.html","id":"background","dir":"Articles","previous_headings":"Description","what":"Background","title":"Extracting road networks","text":"already great packages working OSM data, found struggling networks getting big (region, country scale…). Usually, one use command line tools export data database actually able use . Additionally, certain use cases, geometry tags associated OSM feature essential, therefore including files ultimately comes great cost. package solves one specific use case building graph OSM road network data almost size limit. graph files produced can used workflow, intended use case cppRouting package, outstanding working large scale road networks right R environment. Additionally, pre-processing raw extract files can done rosmium package. example select specific bounding box data. One condition required, export features complete way. Missing nodes can cause problems current version package.","code":""},{"path":"https://ischlo.github.io/cppRosm/articles/road_networks.html","id":"cpprosm","dir":"Articles","previous_headings":"","what":"cppRosm","title":"Extracting road networks","text":"function extract_graph accepts path raw OSM extract file, writes working directory project 2 data sets: nodes.csv, road_segments.csv.","code":""},{"path":"https://ischlo.github.io/cppRosm/articles/road_networks.html","id":"output","dir":"Articles","previous_headings":"cppRosm","what":"Output","title":"Extracting road networks","text":"nodes.csv - contains 3 columns: id, lon, lat respectively OSM id node, longitude latitude. road_segments.csv - contains least 3 columns, can contain . minimum expected columns , , length. first 2 columns contain node ids. cases, node ids can cast long integers, recommended.","code":""},{"path":"https://ischlo.github.io/cppRosm/articles/road_networks.html","id":"example-workflow","dir":"Articles","previous_headings":"cppRosm","what":"Example workflow","title":"Extracting road networks","text":"package dependencies installed, workflow following: Nodes Segments end execution code, find two files working directory (don’t know one , run getwd()).","code":"library(cppRosm) ## basic example code file <- system.file(package = 'cppRosm','extdata',\"map.osm\") # path to a local file cppRosm::extract_graph(file) ## Files will be written to: /Users/cenv1069/Documents/packages/cppRosm/vignettes ## [1] 1 # .... nodes <- data.table::fread('nodes.csv') segments <- data.table::fread('road_segments.csv')"},{"path":"https://ischlo.github.io/cppRosm/articles/road_networks.html","id":"exceptions","dir":"Articles","previous_headings":"cppRosm","what":"Exceptions","title":"Extracting road networks","text":"package qualify CRAN due fact low level code writes files mentioned . CRAN specs recommend kind actions failure low level execution crashes R session resulting potential loss unsaved data. However, due performance gain executing low level provides, seemed worth risk.","code":""},{"path":"https://ischlo.github.io/cppRosm/articles/road_networks.html","id":"source-of-failure","dir":"Articles","previous_headings":"cppRosm > Exceptions","what":"Source of failure","title":"Extracting road networks","text":"main source failure low level code presence incomplete ways data. avoid , make sure include complete ways whenevver possible, avoid using sources mention specification data. usual exporting tools OSM website, GEOFABRICK use full data complete ways. using command line tools, libosmium osmosis, parameter generally available. recommended tool use, filtering wider area rosmium package following way: parameter strategy=\"complete_ways\" ensures ways exported without missing bits.","code":"rosmium::extract( input_path = \".../map.osm\" ,extent = sf::st_bbox() # a bbox ,output_path = \".../smaller_map.osm\" ,strategy = \"complete_ways\" # !!! important )"},{"path":"https://ischlo.github.io/cppRosm/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Ivann Schlosser. Author, maintainer.","code":""},{"path":"https://ischlo.github.io/cppRosm/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Schlosser (2024). cppRosm: Fast en Efficient OSM Data R. R package version 1.0.0, https://ischlo.github.io/cppRosm/, https://github.com/ischlo/cppRosm.","code":"@Manual{, title = {cppRosm: Fast en Efficient OSM Data in R}, author = {Ivann Schlosser}, year = {2024}, note = {R package version 1.0.0, https://ischlo.github.io/cppRosm/}, url = {https://github.com/ischlo/cppRosm}, }"},{"path":"https://ischlo.github.io/cppRosm/index.html","id":"introduction","dir":"","previous_headings":"","what":"Introduction","title":"Fast en Efficient OSM Data in R","text":"package uses libosmium library background proposes opinionated way interacting raw OSM data. opinionated, number assumptions made, based long sometimes frustrating experience working OSM data R python projects. assumptions proposed data schema covered separate vignette. part mainly cover setup package.","code":""},{"path":"https://ischlo.github.io/cppRosm/index.html","id":"setup-dependencies","dir":"","previous_headings":"","what":"Setup dependencies","title":"Fast en Efficient OSM Data in R","text":"section development, quick setup guide compiled dependencies.","code":""},{"path":"https://ischlo.github.io/cppRosm/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Fast en Efficient OSM Data in R","text":"usage cppRosm relies libosmium library, needs installed machine. details installation refer official website. mac, recommended install using brew following terminal command: Next, install package github: package detect presence library notify doesn’t see . library installed, need OSM extract file, can get one manually exporting selected area OSM, bigger areas, best approach download geofabrick extract.","code":"brew install libosmium # remotes::install_github('ischlo/cppRosm') # devtools::install_github('ischlo/cppRosm') # pak::pak(\"ischlo/cppRosm\")"},{"path":"https://ischlo.github.io/cppRosm/index.html","id":"notes","dir":"","previous_headings":"","what":"Notes","title":"Fast en Efficient OSM Data in R","text":"early stage development package develop functionalities integrating extremely performant osmium library user friendly R workflow. choice made graph data, first export .csv files reading R. avoid potentially creating files big handled R environment, still extracting data. However, process can fail sometimes, resulting loss unsaved data active R environment. Best practices optimal workflows covered separate vignette.","code":""},{"path":"https://ischlo.github.io/cppRosm/index.html","id":"references","dir":"","previous_headings":"","what":"References","title":"Fast en Efficient OSM Data in R","text":"great packages working OSM data, provide wide set functionalities. size data excessive, like small city-village scale, osmdata might tool choice R. data gets bigger, osmextract right choice. package aims user friendly flexible, also high performing.","code":""},{"path":"https://ischlo.github.io/cppRosm/reference/construct_geom.html","id":null,"dir":"Reference","previous_headings":"","what":"construct_geom — construct_geom","title":"construct_geom — construct_geom","text":"cppRosm data table, make geometries.","code":""},{"path":"https://ischlo.github.io/cppRosm/reference/construct_geom.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"construct_geom — construct_geom","text":"","code":"construct_geom(cpprnet_dt, complete = FALSE, cores = 1)"},{"path":"https://ischlo.github.io/cppRosm/reference/construct_geom.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"construct_geom — construct_geom","text":"cpprnet_dt data table obtained cppRosm extract_data() complete bool. TRUE reconstruct Polygons, else use just points. cores integer. Run computation multiple cores using parallel.","code":""},{"path":"https://ischlo.github.io/cppRosm/reference/construct_geom.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"construct_geom — construct_geom","text":"Modifies provided cpprnet_dt object adds sf geometry column , either full geometries just centroids. Full geometries typically contain polygons points.","code":""},{"path":"https://ischlo.github.io/cppRosm/reference/construct_geom.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"construct_geom — construct_geom","text":"","code":"cpprnet_filepath <- system.file(package = 'cppRosm','extdata','map.osm') cpprnet_dt <- cppRosm::extract_data(filename = cpprnet_filepath) #> → Using main keys `amenity`,`shop`,`tourism`. cppRosm::construct_geom(cpprnet_dt,complete=TRUE) #> id key value lon lat attrs #> #> 1: 227734022 amenity fuel 10.51265 43.84976 #> 2: 227808627 amenity fuel 10.49478 43.84065 #> 3: 227817156 amenity fuel 10.49499 43.84476 #> 4: 227817516 amenity fuel 10.51571 43.84797 #> 5: 227821623 amenity fuel 10.51632 43.84604 #> --- #> 1023: 1156050023 amenity parking 10.51492 43.84978 #> 1024: 1160398321 amenity parking 10.50511 43.83832 #> 1025: 1160426516 amenity parking 10.50510 43.83842 #> 1026: 1160426517 amenity parking 10.50406 43.83837 #> 1027: 1188795305 shop ticket 10.49671 43.84190 #> geometry #> #> 1: POINT (10.51265 43.84976) #> 2: POINT (10.49478 43.84065) #> 3: POINT (10.49499 43.84476) #> 4: POINT (10.51571 43.84797) #> 5: POINT (10.51632 43.84604) #> --- #> 1023: POLYGON ((10.51491 43.84965... #> 1024: POLYGON ((10.50466 43.83833... #> 1025: POLYGON ((10.50576 43.83838... #> 1026: POLYGON ((10.50375 43.83837... #> 1027: POLYGON ((10.49665 43.84195... head(cpprnet_dt$geometry) #> NULL"},{"path":"https://ischlo.github.io/cppRosm/reference/cppRnet-package.html","id":null,"dir":"Reference","previous_headings":"","what":"cppRosm: Fast en Efficient OSM Data in R — cppRosm-package","title":"cppRosm: Fast en Efficient OSM Data in R — cppRosm-package","text":"set fast user friendly functions working large OpenStreetMap extract data. Developed top C++ libosmium library.","code":""},{"path":[]},{"path":"https://ischlo.github.io/cppRosm/reference/cppRnet-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"cppRosm: Fast en Efficient OSM Data in R — cppRosm-package","text":"Maintainer: Ivann Schlosser schlosserivann@gmail.com (ORCID)","code":""},{"path":"https://ischlo.github.io/cppRosm/reference/cppRosm-package.html","id":null,"dir":"Reference","previous_headings":"","what":"cppRosm: Fast en Efficient OSM Data in R — cppRosm-package","title":"cppRosm: Fast en Efficient OSM Data in R — cppRosm-package","text":"set fast user friendly functions working large OpenStreetMap extract data. Developed top C++ libosmium library.","code":""},{"path":[]},{"path":"https://ischlo.github.io/cppRosm/reference/cppRosm-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"cppRosm: Fast en Efficient OSM Data in R — cppRosm-package","text":"Maintainer: Ivann Schlosser schlosserivann@gmail.com (ORCID)","code":""},{"path":"https://ischlo.github.io/cppRosm/reference/extract_data.html","id":null,"dir":"Reference","previous_headings":"","what":"Extracting data from raw osm. — extract_data","title":"Extracting data from raw osm. — extract_data","text":"Getting non-network data raw osm files.","code":""},{"path":"https://ischlo.github.io/cppRosm/reference/extract_data.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Extracting data from raw osm. — extract_data","text":"","code":"extract_data(filename, main_keys = NULL)"},{"path":"https://ischlo.github.io/cppRosm/reference/extract_data.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Extracting data from raw osm. — extract_data","text":"filename local osm extract file .osm .osm.pbf extension. main_keys vector containing main keys extract values . Check osm map features vignette full detail.","code":""},{"path":"https://ischlo.github.io/cppRosm/reference/extract_data.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Extracting data from raw osm. — extract_data","text":"data table several main columns, including one called attrs contains lists named key=value pairs secondary osm tags.","code":""},{"path":"https://ischlo.github.io/cppRosm/reference/extract_data.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Extracting data from raw osm. — extract_data","text":"","code":"local_osm_filename <- system.file(\"extdata\",'map.osm', package = \"cppRosm\") data <- cppRosm::extract_data(local_osm_filename) #> → Using main keys `amenity`,`shop`,`tourism`. head(data) #> id key value lon lat attrs #> #> 1: 227734022 amenity fuel 10.51265 43.84976 #> 2: 227808627 amenity fuel 10.49478 43.84065 #> 3: 227817156 amenity fuel 10.49499 43.84476 #> 4: 227817516 amenity fuel 10.51571 43.84797 #> 5: 227821623 amenity fuel 10.51632 43.84604 #> 6: 227821625 amenity fuel 10.51595 43.84711 head(data$attrs) #> [[1]] #> [[1]]$brand #> [1] \"Api-Ip\" #> #> [[1]]$`brand:wikidata` #> [1] \"Q646807\" #> #> [[1]]$`brand:wikipedia` #> [1] \"en:Anonima Petroli Italiana\" #> #> [[1]]$`fuel:diesel` #> [1] \"yes\" #> #> [[1]]$`fuel:octane_95` #> [1] \"yes\" #> #> [[1]]$`fuel:octane_98` #> [1] \"yes\" #> #> [[1]]$name #> [1] \"IP\" #> #> [[1]]$operator #> [1] \"Netti Santo Nicola\" #> #> [[1]]$`ref:mise` #> [1] \"28234\" #> #> [[1]]$source #> [1] \"MISE - Ministero Sviluppo Economico\" #> #> #> [[2]] #> [[2]]$brand #> [1] \"Esso\" #> #> [[2]]$`brand:wikidata` #> [1] \"Q867662\" #> #> [[2]]$`fuel:diesel` #> [1] \"yes\" #> #> [[2]]$`fuel:octane_95` #> [1] \"yes\" #> #> [[2]]$name #> [1] \"Esso\" #> #> [[2]]$operator #> [1] \"Ciervo Giovanni\" #> #> [[2]]$`ref:mise` #> [1] \"37277\" #> #> #> [[3]] #> [[3]]$brand #> [1] \"Api-Ip\" #> #> [[3]]$`fuel:diesel` #> [1] \"yes\" #> #> [[3]]$`fuel:octane_95` #> [1] \"yes\" #> #> [[3]]$operator #> [1] \"Cobel - Commercio Benzina Lubrificanti - S.R.L. o Cobel - S.R.L.\" #> #> [[3]]$`ref:mise` #> [1] \"31551\" #> #> [[3]]$`toilets:wheelchair` #> [1] \"no\" #> #> [[3]]$wheelchair #> [1] \"yes\" #> #> #> [[4]] #> [[4]]$brand #> [1] \"Api-Ip\" #> #> [[4]]$check_date #> [1] \"2022-09-04\" #> #> [[4]]$`fuel:diesel` #> [1] \"yes\" #> #> [[4]]$`fuel:octane_95` #> [1] \"yes\" #> #> [[4]]$name #> [1] \"Giop\" #> #> [[4]]$operator #> [1] \"Cobel - Commercio Benzina Lubrificanti - S.R.L. o Cobel - S.R.L.\" #> #> [[4]]$`payment:bancomat` #> [1] \"yes\" #> #> [[4]]$`payment:mastercard` #> [1] \"yes\" #> #> [[4]]$`payment:visa` #> [1] \"yes\" #> #> [[4]]$`ref:mise` #> [1] \"22498\" #> #> [[4]]$`toilets:wheelchair` #> [1] \"no\" #> #> [[4]]$wheelchair #> [1] \"yes\" #> #> #> [[5]] #> [[5]]$brand #> [1] \"Agip\" #> #> [[5]]$`brand:wikidata` #> [1] \"Q377915\" #> #> [[5]]$`brand:wikipedia` #> [1] \"en:Agip\" #> #> [[5]]$`fuel:diesel` #> [1] \"yes\" #> #> [[5]]$`fuel:octane_95` #> [1] \"yes\" #> #> [[5]]$name #> [1] \"Agip\" #> #> [[5]]$operator #> [1] \"Fratelli Checchi - S.N.C.\" #> #> [[5]]$`ref:mise` #> [1] \"39092\" #> #> #> [[6]] #> [[6]]$brand #> [1] \"Api-Ip\" #> #> [[6]]$`fuel:diesel` #> [1] \"yes\" #> #> [[6]]$`fuel:octane_95` #> [1] \"yes\" #> #> [[6]]$operator #> [1] \"Minghi Marco\" #> #> [[6]]$`ref:mise` #> [1] \"8149\" #> #> [[6]]$`toilets:wheelchair` #> [1] \"no\" #> #> [[6]]$wheelchair #> [1] \"yes\" #> #>"},{"path":"https://ischlo.github.io/cppRosm/reference/extract_graph.html","id":null,"dir":"Reference","previous_headings":"","what":"Extracting road graphs from OSM — extract_graph","title":"Extracting road graphs from OSM — extract_graph","text":"function helps extract road network graph simple light weight format. background, uses power osmium library C++, copies data graph format locally 2 .csv files, one nodes coordinates, segments optional values.","code":""},{"path":"https://ischlo.github.io/cppRosm/reference/extract_graph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Extracting road graphs from OSM — extract_graph","text":"","code":"extract_graph(filename)"},{"path":"https://ischlo.github.io/cppRosm/reference/extract_graph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Extracting road graphs from OSM — extract_graph","text":"filename local osm extract file .osm .osm.pbf extension.","code":""},{"path":"https://ischlo.github.io/cppRosm/reference/extract_graph.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Extracting road graphs from OSM — extract_graph","text":"function returns value 1 R environment completed. writes 2 files containing nodes segments. files written current directory called: nodes.csv,road_segments.csv.","code":""},{"path":"https://ischlo.github.io/cppRosm/reference/filter_sec.html","id":null,"dir":"Reference","previous_headings":"","what":"Filtering secondary tags — filter_sec","title":"Filtering secondary tags — filter_sec","text":"function provides handy way filtering cppRosm data set specific secondary tags. return data set added new columns based specific secondary keys values looked .","code":""},{"path":"https://ischlo.github.io/cppRosm/reference/filter_sec.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Filtering secondary tags — filter_sec","text":"","code":"filter_sec(data, keys, cores = 1)"},{"path":"https://ischlo.github.io/cppRosm/reference/filter_sec.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Filtering secondary tags — filter_sec","text":"data cppRosm data set, attrs column. keys either vector valid key parameters, named list names correspond keys attributes vectors matching values. cores number cores parallelise computation","code":""},{"path":"https://ischlo.github.io/cppRosm/reference/filter_sec.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Filtering secondary tags — filter_sec","text":"","code":"test_file <- system.file(package = 'cppRosm','extdata','map.osm') data <- cppRosm::extract_data(test_file) #> → Using main keys `amenity`,`shop`,`tourism`. keys <- list(\"cuisine\"=c(\"pizza\",\"japanese\") ,\"takeaway\"=c(\"yes\")) data_filtered <- cppRosm::filter_sec(data,keys) #> ℹ Searching for exact key~value matches."},{"path":"https://ischlo.github.io/cppRosm/news/index.html","id":"cpprosm-100","dir":"Changelog","previous_headings":"","what":"cppRosm 1.0.0","title":"cppRosm 1.0.0","text":"Big update since package longer depends local installation protozero libosmium, imported built package, making mostly self sufficient.","code":""},{"path":"https://ischlo.github.io/cppRosm/news/index.html","id":"cpprosm-009000","dir":"Changelog","previous_headings":"","what":"cppRosm 0.0.9000","title":"cppRosm 0.0.9000","text":"Added NEWS.md file track changes package.","code":""}] +[{"path":"https://ischlo.github.io/cppRosm/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2024 cppRosm authors Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://ischlo.github.io/cppRosm/articles/data_schema.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"An opinionated way of working with OSM data","text":"Anyone used OpenStreetMap (OSM) data R python might agree tagging system, provides great flexibility extensive classification options, sometimes bit challenging work . vignettes explain approach tagging system aims make easy interact features, associated tags geometries. main ambition providing easy access large OSM data sets.","code":""},{"path":"https://ischlo.github.io/cppRosm/articles/data_schema.html","id":"osm-tags","dir":"Articles","previous_headings":"","what":"OSM tags","title":"An opinionated way of working with OSM data","text":"tag tuple values, first element called \\(key\\), second corresponding \\(value\\). Together, form tag written \\(key=value\\) form. key corresponds broad classification, value specific. example \\(amenity=restaurant\\). \\(key\\) \\(amenity\\), \\(value\\) \\(restaurant\\). Generally, values corresponding key. - Every OSM feature consists set nodes set tags. nodes geographically referenced, means associated coordinates, allowing reconstruct geometry feature. detailed list possible values recommendations available following article : OSM map features.","code":""},{"path":"https://ischlo.github.io/cppRosm/articles/data_schema.html","id":"different-data-types","dir":"Articles","previous_headings":"","what":"Different data types","title":"An opinionated way of working with OSM data","text":"develop appropriate tools work OSM data, important look kind data actually format useful. Mainly two types data can divided:","code":""},{"path":"https://ischlo.github.io/cppRosm/articles/data_schema.html","id":"network","dir":"Articles","previous_headings":"Different data types","what":"Network","title":"An opinionated way of working with OSM data","text":"First, one main use OSM data obtain connected routable road networks, easy use function called extrat_graph . See corresponding vignette details. road network data grouped \\(highway\\) key. categories roads (residential,motorway,pedestrian etc…) values key.","code":""},{"path":"https://ischlo.github.io/cppRosm/articles/data_schema.html","id":"non-network","dir":"Articles","previous_headings":"Different data types","what":"Non network","title":"An opinionated way of working with OSM data","text":"rest data OSM usually represented either point polygon set associated tags. can multiple tags associated feature, one might interested values specific one. , however, intrinsic hierarchy tags, can useful extracting data user friendly exploitable way.","code":""},{"path":"https://ischlo.github.io/cppRosm/articles/data_schema.html","id":"tagging-hierarchy","dir":"Articles","previous_headings":"","what":"Tagging hierarchy","title":"An opinionated way of working with OSM data","text":"package proposes 2 level hierarchy tags, helps extract data large data.tables data.frames high level tags added column variables, secondary tags grouped named lists added separate column called attrs. main consideration tags add information , complimentary sense feature, grouped 2nd level schema. also tags mutually exclusive, example tag \\(amenity\\) key generally \\(healthcare\\) key since different types features. can 2nd level keys address, name, phone number specific information.","code":""},{"path":"https://ischlo.github.io/cppRosm/articles/data_schema.html","id":"st-level","dir":"Articles","previous_headings":"Tagging hierarchy","what":"1st level","title":"An opinionated way of working with OSM data","text":"first level corresponds main tags. taken following list:","code":"main_first_level <- c( \"amenity\" ,\"craft\" ,\"healthcare\" ,\"historic\" ,\"sport\" ,\"natural\" ,\"shop\" ,\"tourism\" )"},{"path":"https://ischlo.github.io/cppRosm/articles/data_schema.html","id":"nd-level","dir":"Articles","previous_headings":"Tagging hierarchy","what":"2nd level","title":"An opinionated way of working with OSM data","text":"Everything else left second level tags, example: \\(addr:street\\) specific key address feature. generally scarce. \\(leisure\\) key overlaps lot \\(sport\\) key. generally contains specific information type sport.","code":""},{"path":"https://ischlo.github.io/cppRosm/articles/data_schema.html","id":"explanation","dir":"Articles","previous_headings":"Tagging hierarchy","what":"Explanation","title":"An opinionated way of working with OSM data","text":"Accounting fact OSM data crowd sourced therefore somewhere exception kind rules can imposed data, one can still observe certain patterns generally true, 2 level hierearchy tags aims capture. observations : Tend mutually exclusive Provide certain amount information, remain sufficiently broad. lot specific complement Arguably, tags don’t fall categories, can still export export_data function, tag can \\(building\\) key. qualifies layer data, much like road network.","code":""},{"path":"https://ischlo.github.io/cppRosm/articles/data_schema.html","id":"example","dir":"Articles","previous_headings":"","what":"Example","title":"An opinionated way of working with OSM data","text":"default, tags keys \\(amenity,shop,tourism\\) extracted. geometry simplified centroid, coordinates provided lon,lat columns data table. function allowing reconstruct full geometry provided, since necessarily always usefull , ommited first extraction. nodes constitute full geometry, complex point, added attrs column data.frame. geometries always closed, meaning polygons. meant save memory especially large data sets. data format, can now easily manipulate POIs, select specific keys, specific values, .","code":"library(cppRosm) library(sf) ## Linking to GEOS 3.11.0, GDAL 3.5.3, PROJ 9.1.0; sf_use_s2() is TRUE test_file <- system.file(package = 'cppRosm','extdata','map.osm') data <- cppRosm::extract_data(test_file) ## → Using main keys `amenity`,`shop`,`tourism`. head(data) |> knitr::kable(digits = 3) # filer by key data[key==\"amenity\",] |> head() |> knitr::kable(digits = 3) # filter by value data[value==\"restaurant\",] |> head() |> knitr::kable(digits = 3) # both: use or to include specific values of different keys and keys data[key==\"shop\" | value==\"restaurant\",] |> head() |> knitr::kable(digits = 3)"},{"path":"https://ischlo.github.io/cppRosm/articles/data_schema.html","id":"filtering-2nd-level-tags","dir":"Articles","previous_headings":"","what":"Filtering 2nd level tags","title":"An opinionated way of working with OSM data","text":"function efficiently filter secondary tags returns data frame, searched key added column feature non-NA match. hood, values matched using regular expressions, maximises chance finding desired values sometimes complicated OSM values.","code":"data |> cppRosm::filter_sec(keys=c(\"cuisine\",\"takeaway\") ,cores=1) |> head() |> knitr::kable(digits = 3) data |> cppRosm::filter_sec(keys=list(\"cuisine\"=c(\"japanese\",\"pizza\") ,\"takeaway\"=c(\"yes\")) ,cores = 1) |> head() |> knitr::kable(digits = 3) ## ℹ Searching for exact key~value matches."},{"path":"https://ischlo.github.io/cppRosm/articles/data_schema.html","id":"geometries","dir":"Articles","previous_headings":"","what":"Geometries","title":"An opinionated way of working with OSM data","text":"lot cases, knowing centroids POIs enough: times original geometry might interest, case use construct_geom function:","code":"data |> sf::st_as_sf(coords=c(\"lon\",\"lat\"),crs=4326) |> sf::st_geometry() |> plot(pch=19) # or same result, keeping the original data a `data.table` # data |> # cppRosm::construct_geom() |> # sf::st_as_sf() |> # sf::st_geometry() |> # plot() data_geom <- data |> cppRosm::construct_geom(complete = TRUE,cores = 1) |> sf::st_as_sf() data_geom |> sf::st_geometry() |> plot(pch=19)"},{"path":"https://ischlo.github.io/cppRosm/articles/data_schema.html","id":"buildings","dir":"Articles","previous_headings":"","what":"Buildings","title":"An opinionated way of working with OSM data","text":"discussed earlier, tags withe \\(building\\) key arguably fall neither categories, sense constitute data layer, just like road network. can still queried extracted extract_data function. function run fraction seconds extract buildings file. provide centroid direct access: can reconstruct geometries data hidden attrs follows: can filter specific tags: observe mutually exclusive nature \\(amenity\\) \\(shop\\) keys, justifying earlier discussion differentiation \\(building\\) key. intersection two keys famous french bar-tabac, bar place buy tobacco/cigarettes. specific filtering: searching specific \\(key=value\\) one tag values another tag, consider trick . ’s generally recommended extract building layer together main keys.","code":"buildings <- cppRosm::extract_data(test_file,main_keys = \"building\") buildings |> cppRosm::construct_geom() |> sf::st_set_geometry(\"geometry\") |> sf::st_geometry() |> plot(pch=19) buildings |> cppRosm::construct_geom(complete = TRUE,cores=1) |> sf::st_as_sf() |> sf::st_geometry() |> plot(pch=19) buildings |> cppRosm::filter_sec(keys=c(\"shop\",\"amenity\")) |> dplyr::select(!attrs) |> head() |> knitr::kable(digits = 3) buildings |> cppRosm::filter_sec(keys = list(\"tourism\" = c(\"\") ,\"abandoned\" = c(\"yes\"))) |> dplyr::select(!attrs) |> head() |> knitr::kable(digits = 3) ## ℹ Searching for exact key~value matches."},{"path":"https://ischlo.github.io/cppRosm/articles/data_schema.html","id":"alternatives","dir":"Articles","previous_headings":"","what":"Alternatives","title":"An opinionated way of working with OSM data","text":"osmdata: great package used lot, found frustrating different geometries gathered separate tables, table containing huge numbers NA columns. attrs column cppRosm table provides alternative way store secondary tags. Additionally, geometries simplified centroid, possibility reconstruct original ones provided construct_geom function. osmextract: great working large OSM files. filtering features remains bit obscure opinion, although seems provide great flexibility, requires good knowledge OSM internals.","code":""},{"path":"https://ischlo.github.io/cppRosm/articles/data_schema.html","id":"conclusion","dir":"Articles","previous_headings":"","what":"Conclusion","title":"An opinionated way of working with OSM data","text":"vignette aimed explain approach taken manipulating OSM data scale flexibility specific data table format supporting functions. Please reach recommendations, feature additions etc… another vignette, recommended workflow covered, package developed others mind (rosmium,cppRouting mainly) , network POI analysis done scale local setup.","code":""},{"path":"https://ischlo.github.io/cppRosm/articles/road_networks.html","id":"description","dir":"Articles","previous_headings":"","what":"Description","title":"Extracting road networks","text":"mini-package provides fast, yet user-friendly way exporting large road network data graph-like format. uses libosmium library background proposes simple R function extract road graph .osm, .osm.pbf extract file OSM data.","code":""},{"path":"https://ischlo.github.io/cppRosm/articles/road_networks.html","id":"background","dir":"Articles","previous_headings":"Description","what":"Background","title":"Extracting road networks","text":"already great packages working OSM data, found struggling networks getting big (region, country scale…). Usually, one use command line tools export data database actually able use . Additionally, certain use cases, geometry tags associated OSM feature essential, therefore including files ultimately comes great cost. package solves one specific use case building graph OSM road network data almost size limit. graph files produced can used workflow, intended use case cppRouting package, outstanding working large scale road networks right R environment. Additionally, pre-processing raw extract files can done rosmium package. example select specific bounding box data. One condition required, export features complete way. Missing nodes can cause problems current version package.","code":""},{"path":"https://ischlo.github.io/cppRosm/articles/road_networks.html","id":"cpprosm","dir":"Articles","previous_headings":"","what":"cppRosm","title":"Extracting road networks","text":"function extract_graph accepts path raw OSM extract file, writes working directory project 2 data sets: nodes.csv, road_segments.csv.","code":""},{"path":"https://ischlo.github.io/cppRosm/articles/road_networks.html","id":"output","dir":"Articles","previous_headings":"cppRosm","what":"Output","title":"Extracting road networks","text":"nodes.csv - contains 3 columns: id, lon, lat respectively OSM id node, longitude latitude. road_segments.csv - contains least 3 columns, can contain . minimum expected columns , , length. first 2 columns contain node ids. cases, node ids can cast long integers, recommended.","code":""},{"path":"https://ischlo.github.io/cppRosm/articles/road_networks.html","id":"example-workflow","dir":"Articles","previous_headings":"cppRosm","what":"Example workflow","title":"Extracting road networks","text":"package dependencies installed, workflow following: Nodes Segments end execution code, find two files working directory (don’t know one , run getwd()).","code":"library(cppRosm) ## basic example code file <- system.file(package = 'cppRosm','extdata',\"map.osm\") # path to a local file cppRosm::extract_graph(file) ## Files will be written to: /Users/cenv1069/Documents/packages/cppRosm/vignettes ## [1] 1 # .... nodes <- data.table::fread('nodes.csv') segments <- data.table::fread('road_segments.csv')"},{"path":"https://ischlo.github.io/cppRosm/articles/road_networks.html","id":"exceptions","dir":"Articles","previous_headings":"cppRosm","what":"Exceptions","title":"Extracting road networks","text":"package qualify CRAN due fact low level code writes files mentioned . CRAN specs recommend kind actions failure low level execution crashes R session resulting potential loss unsaved data. However, due performance gain executing low level provides, seemed worth risk.","code":""},{"path":"https://ischlo.github.io/cppRosm/articles/road_networks.html","id":"source-of-failure","dir":"Articles","previous_headings":"cppRosm > Exceptions","what":"Source of failure","title":"Extracting road networks","text":"main source failure low level code presence incomplete ways data. avoid , make sure include complete ways whenevver possible, avoid using sources mention specification data. usual exporting tools OSM website, GEOFABRICK use full data complete ways. using command line tools, libosmium osmosis, parameter generally available. recommended tool use, filtering wider area rosmium package following way: parameter strategy=\"complete_ways\" ensures ways exported without missing bits.","code":"rosmium::extract( input_path = \".../map.osm\" ,extent = sf::st_bbox() # a bbox ,output_path = \".../smaller_map.osm\" ,strategy = \"complete_ways\" # !!! important )"},{"path":"https://ischlo.github.io/cppRosm/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Ivann Schlosser. Author, maintainer.","code":""},{"path":"https://ischlo.github.io/cppRosm/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Schlosser (2024). cppRosm: Fast en Efficient OSM Data R. R package version 1.0.0, https://ischlo.github.io/cppRosm/, https://github.com/ischlo/cppRosm.","code":"@Manual{, title = {cppRosm: Fast en Efficient OSM Data in R}, author = {Ivann Schlosser}, year = {2024}, note = {R package version 1.0.0, https://ischlo.github.io/cppRosm/}, url = {https://github.com/ischlo/cppRosm}, }"},{"path":"https://ischlo.github.io/cppRosm/index.html","id":"introduction","dir":"","previous_headings":"","what":"Introduction","title":"Fast en Efficient OSM Data in R","text":"package uses libosmium library background proposes opinionated way interacting raw OSM data. opinionated, number assumptions made, based long sometimes frustrating experience working OSM data R python projects. assumptions proposed data schema covered separate vignette. part mainly cover setup package.","code":""},{"path":"https://ischlo.github.io/cppRosm/index.html","id":"setup-dependencies","dir":"","previous_headings":"","what":"Setup dependencies","title":"Fast en Efficient OSM Data in R","text":"usage cppRosm relies libosmium library. necessary compiled code dependencies come package, facilitating ’s use.","code":""},{"path":"https://ischlo.github.io/cppRosm/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Fast en Efficient OSM Data in R","text":"Install package github: library installed, need OSM extract file, can get one manually exporting selected area OSM, bigger areas, best approach download geofabrick extract.","code":"# remotes::install_github('ischlo/cppRosm') # devtools::install_github('ischlo/cppRosm') # pak::pak(\"ischlo/cppRosm\")"},{"path":"https://ischlo.github.io/cppRosm/index.html","id":"notes","dir":"","previous_headings":"","what":"Notes","title":"Fast en Efficient OSM Data in R","text":"early stage development package develop functionalities integrating extremely performant osmium library user friendly R workflow. choice made graph data first export .csv files reading R. avoid potentially creating files big handled R environment, still extracting data. However, process can fail sometimes, resulting loss unsaved data active R environment. Best practices optimal workflows covered separate vignette.","code":""},{"path":"https://ischlo.github.io/cppRosm/index.html","id":"references","dir":"","previous_headings":"","what":"References","title":"Fast en Efficient OSM Data in R","text":"great packages working OSM data, provide wide set functionalities. size data excessive, like small city/village scale, osmdata might tool choice R. data gets bigger, osmextract right choice. package aims user friendly flexible, also high performing.","code":""},{"path":"https://ischlo.github.io/cppRosm/reference/construct_geom.html","id":null,"dir":"Reference","previous_headings":"","what":"construct_geom — construct_geom","title":"construct_geom — construct_geom","text":"cppRosm data table, make geometries.","code":""},{"path":"https://ischlo.github.io/cppRosm/reference/construct_geom.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"construct_geom — construct_geom","text":"","code":"construct_geom(cpprnet_dt, complete = FALSE, cores = 1)"},{"path":"https://ischlo.github.io/cppRosm/reference/construct_geom.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"construct_geom — construct_geom","text":"cpprnet_dt data table obtained cppRosm extract_data() complete bool. TRUE reconstruct Polygons, else use just points. cores integer. Run computation multiple cores using parallel.","code":""},{"path":"https://ischlo.github.io/cppRosm/reference/construct_geom.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"construct_geom — construct_geom","text":"Modifies provided cpprnet_dt object adds sf geometry column , either full geometries just centroids. Full geometries typically contain polygons points.","code":""},{"path":"https://ischlo.github.io/cppRosm/reference/construct_geom.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"construct_geom — construct_geom","text":"","code":"cpprnet_filepath <- system.file(package = 'cppRosm','extdata','map.osm') cpprnet_dt <- cppRosm::extract_data(filename = cpprnet_filepath) #> → Using main keys `amenity`,`shop`,`tourism`. cppRosm::construct_geom(cpprnet_dt,complete=TRUE) #> id key value lon lat attrs #> #> 1: 227734022 amenity fuel 10.51265 43.84976 #> 2: 227808627 amenity fuel 10.49478 43.84065 #> 3: 227817156 amenity fuel 10.49499 43.84476 #> 4: 227817516 amenity fuel 10.51571 43.84797 #> 5: 227821623 amenity fuel 10.51632 43.84604 #> --- #> 1023: 1156050023 amenity parking 10.51492 43.84978 #> 1024: 1160398321 amenity parking 10.50511 43.83832 #> 1025: 1160426516 amenity parking 10.50510 43.83842 #> 1026: 1160426517 amenity parking 10.50406 43.83837 #> 1027: 1188795305 shop ticket 10.49671 43.84190 #> geometry #> #> 1: POINT (10.51265 43.84976) #> 2: POINT (10.49478 43.84065) #> 3: POINT (10.49499 43.84476) #> 4: POINT (10.51571 43.84797) #> 5: POINT (10.51632 43.84604) #> --- #> 1023: POLYGON ((10.51491 43.84965... #> 1024: POLYGON ((10.50466 43.83833... #> 1025: POLYGON ((10.50576 43.83838... #> 1026: POLYGON ((10.50375 43.83837... #> 1027: POLYGON ((10.49665 43.84195... head(cpprnet_dt$geometry) #> NULL"},{"path":"https://ischlo.github.io/cppRosm/reference/cppRnet-package.html","id":null,"dir":"Reference","previous_headings":"","what":"cppRosm: Fast en Efficient OSM Data in R — cppRosm-package","title":"cppRosm: Fast en Efficient OSM Data in R — cppRosm-package","text":"set fast user friendly functions working large OpenStreetMap extract data. Developed top C++ libosmium library.","code":""},{"path":[]},{"path":"https://ischlo.github.io/cppRosm/reference/cppRnet-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"cppRosm: Fast en Efficient OSM Data in R — cppRosm-package","text":"Maintainer: Ivann Schlosser schlosserivann@gmail.com (ORCID)","code":""},{"path":"https://ischlo.github.io/cppRosm/reference/cppRosm-package.html","id":null,"dir":"Reference","previous_headings":"","what":"cppRosm: Fast en Efficient OSM Data in R — cppRosm-package","title":"cppRosm: Fast en Efficient OSM Data in R — cppRosm-package","text":"set fast user friendly functions working large OpenStreetMap extract data. Developed top C++ libosmium library.","code":""},{"path":[]},{"path":"https://ischlo.github.io/cppRosm/reference/cppRosm-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"cppRosm: Fast en Efficient OSM Data in R — cppRosm-package","text":"Maintainer: Ivann Schlosser schlosserivann@gmail.com (ORCID)","code":""},{"path":"https://ischlo.github.io/cppRosm/reference/extract_data.html","id":null,"dir":"Reference","previous_headings":"","what":"Extracting data from raw osm. — extract_data","title":"Extracting data from raw osm. — extract_data","text":"Getting non-network data raw osm files.","code":""},{"path":"https://ischlo.github.io/cppRosm/reference/extract_data.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Extracting data from raw osm. — extract_data","text":"","code":"extract_data(filename, main_keys = NULL)"},{"path":"https://ischlo.github.io/cppRosm/reference/extract_data.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Extracting data from raw osm. — extract_data","text":"filename local osm extract file .osm .osm.pbf extension. main_keys vector containing main keys extract values . Check osm map features vignette full detail.","code":""},{"path":"https://ischlo.github.io/cppRosm/reference/extract_data.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Extracting data from raw osm. — extract_data","text":"data table several main columns, including one called attrs contains lists named key=value pairs secondary osm tags.","code":""},{"path":"https://ischlo.github.io/cppRosm/reference/extract_data.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Extracting data from raw osm. — extract_data","text":"","code":"local_osm_filename <- system.file(\"extdata\",'map.osm', package = \"cppRosm\") data <- cppRosm::extract_data(local_osm_filename) #> → Using main keys `amenity`,`shop`,`tourism`. head(data) #> id key value lon lat attrs #> #> 1: 227734022 amenity fuel 10.51265 43.84976 #> 2: 227808627 amenity fuel 10.49478 43.84065 #> 3: 227817156 amenity fuel 10.49499 43.84476 #> 4: 227817516 amenity fuel 10.51571 43.84797 #> 5: 227821623 amenity fuel 10.51632 43.84604 #> 6: 227821625 amenity fuel 10.51595 43.84711 head(data$attrs) #> [[1]] #> [[1]]$brand #> [1] \"Api-Ip\" #> #> [[1]]$`brand:wikidata` #> [1] \"Q646807\" #> #> [[1]]$`brand:wikipedia` #> [1] \"en:Anonima Petroli Italiana\" #> #> [[1]]$`fuel:diesel` #> [1] \"yes\" #> #> [[1]]$`fuel:octane_95` #> [1] \"yes\" #> #> [[1]]$`fuel:octane_98` #> [1] \"yes\" #> #> [[1]]$name #> [1] \"IP\" #> #> [[1]]$operator #> [1] \"Netti Santo Nicola\" #> #> [[1]]$`ref:mise` #> [1] \"28234\" #> #> [[1]]$source #> [1] \"MISE - Ministero Sviluppo Economico\" #> #> #> [[2]] #> [[2]]$brand #> [1] \"Esso\" #> #> [[2]]$`brand:wikidata` #> [1] \"Q867662\" #> #> [[2]]$`fuel:diesel` #> [1] \"yes\" #> #> [[2]]$`fuel:octane_95` #> [1] \"yes\" #> #> [[2]]$name #> [1] \"Esso\" #> #> [[2]]$operator #> [1] \"Ciervo Giovanni\" #> #> [[2]]$`ref:mise` #> [1] \"37277\" #> #> #> [[3]] #> [[3]]$brand #> [1] \"Api-Ip\" #> #> [[3]]$`fuel:diesel` #> [1] \"yes\" #> #> [[3]]$`fuel:octane_95` #> [1] \"yes\" #> #> [[3]]$operator #> [1] \"Cobel - Commercio Benzina Lubrificanti - S.R.L. o Cobel - S.R.L.\" #> #> [[3]]$`ref:mise` #> [1] \"31551\" #> #> [[3]]$`toilets:wheelchair` #> [1] \"no\" #> #> [[3]]$wheelchair #> [1] \"yes\" #> #> #> [[4]] #> [[4]]$brand #> [1] \"Api-Ip\" #> #> [[4]]$check_date #> [1] \"2022-09-04\" #> #> [[4]]$`fuel:diesel` #> [1] \"yes\" #> #> [[4]]$`fuel:octane_95` #> [1] \"yes\" #> #> [[4]]$name #> [1] \"Giop\" #> #> [[4]]$operator #> [1] \"Cobel - Commercio Benzina Lubrificanti - S.R.L. o Cobel - S.R.L.\" #> #> [[4]]$`payment:bancomat` #> [1] \"yes\" #> #> [[4]]$`payment:mastercard` #> [1] \"yes\" #> #> [[4]]$`payment:visa` #> [1] \"yes\" #> #> [[4]]$`ref:mise` #> [1] \"22498\" #> #> [[4]]$`toilets:wheelchair` #> [1] \"no\" #> #> [[4]]$wheelchair #> [1] \"yes\" #> #> #> [[5]] #> [[5]]$brand #> [1] \"Agip\" #> #> [[5]]$`brand:wikidata` #> [1] \"Q377915\" #> #> [[5]]$`brand:wikipedia` #> [1] \"en:Agip\" #> #> [[5]]$`fuel:diesel` #> [1] \"yes\" #> #> [[5]]$`fuel:octane_95` #> [1] \"yes\" #> #> [[5]]$name #> [1] \"Agip\" #> #> [[5]]$operator #> [1] \"Fratelli Checchi - S.N.C.\" #> #> [[5]]$`ref:mise` #> [1] \"39092\" #> #> #> [[6]] #> [[6]]$brand #> [1] \"Api-Ip\" #> #> [[6]]$`fuel:diesel` #> [1] \"yes\" #> #> [[6]]$`fuel:octane_95` #> [1] \"yes\" #> #> [[6]]$operator #> [1] \"Minghi Marco\" #> #> [[6]]$`ref:mise` #> [1] \"8149\" #> #> [[6]]$`toilets:wheelchair` #> [1] \"no\" #> #> [[6]]$wheelchair #> [1] \"yes\" #> #>"},{"path":"https://ischlo.github.io/cppRosm/reference/extract_graph.html","id":null,"dir":"Reference","previous_headings":"","what":"Extracting road graphs from OSM — extract_graph","title":"Extracting road graphs from OSM — extract_graph","text":"function helps extract road network graph simple light weight format. background, uses power osmium library C++, copies data graph format locally 2 .csv files, one nodes coordinates, segments optional values.","code":""},{"path":"https://ischlo.github.io/cppRosm/reference/extract_graph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Extracting road graphs from OSM — extract_graph","text":"","code":"extract_graph(filename)"},{"path":"https://ischlo.github.io/cppRosm/reference/extract_graph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Extracting road graphs from OSM — extract_graph","text":"filename local osm extract file .osm .osm.pbf extension.","code":""},{"path":"https://ischlo.github.io/cppRosm/reference/extract_graph.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Extracting road graphs from OSM — extract_graph","text":"function returns value 1 R environment completed. writes 2 files containing nodes segments. files written current directory called: nodes.csv,road_segments.csv.","code":""},{"path":"https://ischlo.github.io/cppRosm/reference/filter_sec.html","id":null,"dir":"Reference","previous_headings":"","what":"Filtering secondary tags — filter_sec","title":"Filtering secondary tags — filter_sec","text":"function provides handy way filtering cppRosm data set specific secondary tags. return data set added new columns based specific secondary keys values looked .","code":""},{"path":"https://ischlo.github.io/cppRosm/reference/filter_sec.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Filtering secondary tags — filter_sec","text":"","code":"filter_sec(data, keys, cores = 1)"},{"path":"https://ischlo.github.io/cppRosm/reference/filter_sec.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Filtering secondary tags — filter_sec","text":"data cppRosm data set, attrs column. keys either vector valid key parameters, named list names correspond keys attributes vectors matching values. cores number cores parallelise computation","code":""},{"path":"https://ischlo.github.io/cppRosm/reference/filter_sec.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Filtering secondary tags — filter_sec","text":"","code":"test_file <- system.file(package = 'cppRosm','extdata','map.osm') data <- cppRosm::extract_data(test_file) #> → Using main keys `amenity`,`shop`,`tourism`. keys <- list(\"cuisine\"=c(\"pizza\",\"japanese\") ,\"takeaway\"=c(\"yes\")) data_filtered <- cppRosm::filter_sec(data,keys) #> ℹ Searching for exact key~value matches."},{"path":"https://ischlo.github.io/cppRosm/news/index.html","id":"cpprosm-100","dir":"Changelog","previous_headings":"","what":"cppRosm 1.0.0","title":"cppRosm 1.0.0","text":"Big update since package longer depends local installation protozero libosmium, imported built package, making mostly self sufficient.","code":""},{"path":"https://ischlo.github.io/cppRosm/news/index.html","id":"cpprosm-009000","dir":"Changelog","previous_headings":"","what":"cppRosm 0.0.9000","title":"cppRosm 0.0.9000","text":"Added NEWS.md file track changes package.","code":""}] diff --git a/vignettes/road_networks.Rmd b/vignettes/road_networks.Rmd index a7e3355..0b0be75 100644 --- a/vignettes/road_networks.Rmd +++ b/vignettes/road_networks.Rmd @@ -7,7 +7,7 @@ vignette: > %\VignetteEncoding{UTF-8} --- -```{r echo=FALSE, eval=TRUE} +```{r echo=FALSE, eval=TRUE,include=FALSE} knitr::opts_chunk$set(eval = TRUE ,echo = TRUE @@ -64,6 +64,7 @@ cppRosm::extract_graph(file) nodes <- data.table::fread('nodes.csv') segments <- data.table::fread('road_segments.csv') + ```