I have access to a password protected WMS service (https://wms.swisstopo.admin.ch/) and I would like to download tiles for a bounding box with R. Then I would like to use them as background for a map created with tmap. The layer name is
ch.swisstopo.pixelkarte-farbe-pk25.noscale. I don't know where to give the authentication information.
I saw this question https://stackoverflow.com/questions/49983053/extracting-data-from-a-wms-layer but using
sf::st_read() gives the following error:
The file doesn't seem to exist.
I would like to have the WMS data of this extent (CRS is CH1903+):
xmin : 2581809 xmax : 2583643 ymin : 1181706 ymax : 1182825
Then, I would like to plot the map with
tmap::tm_rgb() (https://www.rdocumentation.org/packages/tmap/versions/3.2/topics/tm_raster). How can I do this?