MyNixOS website logo
Description

Crafting Print-Ready Maps and Layered Visualizations.

Simplifying the creation of print-ready maps, this package offers a user-friendly interface derived from 'ggplot2' for handling OpenStreetMap data. It streamlines the map-making process, allowing users to focus on the story their maps tell. Transforming raw geospatial data into informative visualizations is made easy with simple features 'sf' geometries. Whether for urban planning, environmental studies, or impactful public presentations, this tool facilitates straightforward and effective map creation. Enhance the dissemination of spatial information with high-quality, narrative-driven visualizations!

cartographr

R-CMD-check codecov testcoverage

Overview

Creating maps from OpenStreetMap data can be complex and time-consuming due to varying design syntax and the challenge of producing visually appealing, print-ready maps. Overlaying additional information layers while maintaining cartographic aesthetics also requires a deep understanding of spatial data. cartographr addresses these issues by providing a lightweight, user-friendly interface between osmdata and ggplot2, streamlining the map-making process and allowing users to focus on the narrative of their maps. It simplifies the transformation of geospatial data using simple features (sf) geometries into informative, high-quality visualizations, enhancing the dissemination of spatial information. Ideal for urban planning, environmental studies, or public presentations, cartographr aims to make map creation straightforward and effective.

Installation

Simply install from github.

# Install the latest version from github
devtools::install_github("da-wi/cartographr")

# Alternatively, install from CRAN
install.packages("cartographr")

Usage

Begin by determining the central point of your map using the WGS84 coordinates. For our example, we’ll use Vienna’s center with a latitude of 48.210 and a longitude of 16.370. You can easily find these coordinates online.

Decide on the size of the printed map, such as A4. This will help scale the text and lines on the map proportionally, no matter the print size.

set_output_size(c(300,300))

Use the get_osmdata() function to collect OpenStreetMap data. Set the width of your map area in meters using the x_distance parameter. If you leave out the height (y_distance), it will be calculated based on the width and the aspect ratio of your chosen output size.

osm <- get_osmdata(48.210, 16.370, x_distance = 1200)

The osm variable now contains all the geometric shapes (like buildings, rivers, parks) that will appear on your map. Generate the map with plot_map() and customize its look with themes and color palettes. For instance, create an infomap of Vienna using theme_infomap() and choose a color scheme (see get_palette()).

plot_vienna <- osm |> plot_map(palette = "serene") +
  theme_infomap() +
  ggplot2::labs(title = "VIENNA")

To view your map, simply call

plot_vienna

Finally, save your map as a PDF file, ready for printing.

save_map(plot = plot_vienna, filename="vienna.pdf")

Palette overview

Several color palettes are provided by the package, however, you can easily create and use your own palette (see get_palette()).

hamburg <- get_osmdata(lat = 53.545, lon = 10.000, x_distance = 1200)

df_pal <- tibble (palettes= c("alphabet", "arctic","autumn", "bw",
                        "evening", "gray", "iberia", "imhof","lines","midnight",
                        "minimal","metropolitan","serene","swiss","tropical"),
                  hamburg = list(hamburg)) |>
  rowwise() |>
  mutate(p = list(hamburg |> plot_map(palettes) + theme_infomap() + labs(title = palettes)))





Data licensing

All data that you access using cartographr and, in consequence, osmdata is licensed under OpenStreetMap’s license, the Open Database Licence. Any derived data and products must also carry the same licence. You should make sure you understand that licence before publishing any derived datasets.

Getting help

If you encounter a clear bug, please file an issue with a minimal reproducible example on GitHub.

Credits

The development of this project drew inspiration from the prettymaps project.

Metadata

Version

0.2.2

License

Unknown

Platforms (77)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows