How to add a raster map background to ggplot?

I am looking for solution how one can add an underlying raster map background from a free source (= not from google, see ggmap).

This (ideal) solution should work seamlessly with the geom_sf() as I would like to show things on a map.
Another aspect would be that this underlying raster map solution should recognize (= be compatible with) the crs (coordinate reference system) embedded in the sf objects to be plotted on top of the map.

Thank you for your help.

Have you checked online resources to see what are available solutions, haven't you?

Thank you for your recommendations.
Yes, I assure you that I have already done in advance a quite wide search before asking.

Please note, that in my question I asked explicitly for free alternatives which rules out ggmap or any other solutions based on google API.
The third is an old article (5+ years), although the OpenStreetMap it looks promising this package was updated last time about 3 years ago, so it is questionable because the old java dependencies.

do you have an example raster map, or source for sum such map ?

I haven't done this work myself, but I would try to workthrough the examples at :
6 Maps | ggplot2 (ggplot2-book.org)

No, I don’t have the any raster map in advance, this is what I want to be fetched automatically and to be included as an underlying map layer in the plot.

I found a good solution: basemaps

ggmap can use OpenStreetMap and/or Stamen maps instead of google.

Regards,
Grzegorz

Sorry Grzegorz,
You are absolutely right.

A was too quickly dropping the ggmap when I have seen that the README.md starts with drawing the attention to changes in google API, and because this part of the documents is quite long (filling a complete screen in the browser) I never read the rest of this description.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.