The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
In this vignette, you will learn how to add new information to a map. Here, we retrieve a map of Manhattan, NYC.
First, we load the locations of crimes in Manhattan.
sf
To add the crime locations in the dataset to our map, we harness the
sf
(simple features) package, which includes a lot of
useful tools for working with geo data. To this end, we convert the
dataset into a sf
object using latitude and longitude.
This can be achieved with the function sf::st_as_sf()
using the coordinates from the dataset.
We have to provide longitude
, latitude
and
x_distance
(i.e., the width of the map in meters).
Furthermore, we define the extend of the OSM data in meters in
get_osmdata()
. y_distance
is calculated
automatically using the output size aspect ratio.
plot_map()
generates a ggplot2
object using
the color theme set as parameter. That means that we can easily adjust
the plot using ggplot2
commands and also add new
information to the map.
p <- osm |>
crop(soho_boundary) |>
plot_map(palette = "alphabet") +
theme_infomap_barlow() +
# Add geom with crimes
geom_point(data = crime,
aes(x = longitude, y = latitude, shape = type), color="#A72424", size=2) +
# Set labels
labs(title = "CRIME IN SOHO",
shape = "TYPE")
Now we can plot the map by simply calling its print method implicity:
save_map()
can be used to store the print-ready plot
object to the disk as a drawn object in pdf
format.
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.