Package 'rosmosis'

Title: Helper Functions to Download and Run Osmosis
Description: Allows one to download and run Osmosis from R. Osmosis is a command line application for processing OpenStreetMap data which consists of several different pluggable components that can be chained to perform large operations. The package currently does not aim to offer functions that covers the entirety of Osmosis' API, and instead offers limited support to running Osmosis through a helper function.
Authors: Daniel Herszenhut [aut, cre]
Maintainer: Daniel Herszenhut <[email protected]>
License: MIT + file LICENSE
Version: 0.0.0.9000
Built: 2024-10-25 04:02:03 UTC
Source: https://github.com/dhersz/rosmosis

Help Index


Download Osmosis

Description

Downloads Osmosis, a command-line application for processing OpenStreetMap data.

Usage

download_osmosis(version = "0.48.3", force = FALSE, quiet = TRUE)

Arguments

version

A string. The version of Osmosis to be downloaded. Defaults to "0.48.3", the current latest version. Please check openstreetmap/osmosis releases for the full set of available versions.

force

A logical. Whether to overwrite previously downloaded and cached Osmosis. Defaults to FALSE.

quiet

A logical. Whether to hide informative messages or not. Defaults to TRUE.

Value

Invisibly returns the path to Osmosis.

Examples

download_osmosis()

Get Osmosis path

Description

Returns the path to previously downloaded and cached Osmosis. If it has not been downloaded yet, downloads it using download_osmosis().

Usage

osmosis_path(version = "0.48.3", force = FALSE, quiet = TRUE)

Arguments

version

A string. The version of Osmosis whose path should be returned. Defaults to "0.48.3", the current latest version. Please check openstreetmap/osmosis releases for the full set of available versions.

force

A logical. Passed to download_osmosis(), whether to overwrite previously downloaded and cached Osmosis. Defaults to FALSE.

quiet

A logical. Passed to download_osmosis(), whether to hide informative messages or not. Defaults to TRUE.

Value

A string, the path to Osmosis.

Examples

osmosis_path()

Run Osmosis

Description

Runs Osmosis, given the path to the application and the commands that should be sent to the command-line tool.

Usage

run_osmosis(osmosis_path, command, echo = TRUE, spinner = TRUE)

Arguments

osmosis_path

A string. The path to Osmosis.

command

A string. The command to run.

echo

A logical. Whether to print the standard output and error to the screen. Defaults to TRUE.

spinner

A logical. Whether to show a reassuring spinner while the process is running. Defaults to TRUE.

Value

Invisibly returns a list containing the exit status of the Osmosis process, the standard output of the command, the standard error of the command and whether the process was killed due to a timeout.

Examples

cur_osm <- system.file("extdata/cur.osm.pbf", package = "rosmosis")

fs::file_size(cur_osm)

# cropping the pbf using a bounding box

output_path <- tempfile("cropped_cur", fileext = ".osm.pbf")

osmosis_command <- paste0(
  "--read-pbf ", cur_osm, " ",
  "--bounding-box ",
  "top=-25.4290 left=-49.2792 bottom=-25.4394 right=-49.2629 ",
  "completeWays=yes ",
  "--write-pbf ", output_path
)

run_osmosis(osmosis_path(), osmosis_command, echo = FALSE, spinner = FALSE)
fs::file_size(output_path)