Search code examples
rgisraster

relief of Switzerland from a tiff-file


I would like an official source for drawing the relief over a map of Switzerland. On one of the pages of swisstopo I found following file: https://data.geo.admin.ch/ch.swisstopo.pixelkarte-farbe-pk1000.noscale/swiss-map-raster1000_2022_1000/swiss-map-raster1000_2022_1000_kgrel_50_2056.tif

Now, how is it possible to choose the different layers of this tiff-File escpacially the relief?

If I try

relief <- raster(swiss-map-raster1000_2022_1000_krel_50_2056.tif")
plot(relief)`

I only see a green map, while having a look to the original tiff-file shows a nice map of Switzerland.


Solution

  • This is a RGB (Red, Green, Blue) image, but because all channels have the same value, the colors are all grays

    You can open the file like this:

    library(terra)
    
    # using vsicurl to avoid downloading for this example; 
    # but if you are going to use you should download it first 
    f <- "/vsicurl/https://data.geo.admin.ch/ch.swisstopo.pixelkarte-farbe-pk1000.noscale/swiss-map-raster1000_2022_1000/swiss-map-raster1000_2022_1000_kgrel_50_2056.tif"
    
    x <- rast(f)
    x
    #class       : SpatRaster 
    #dimensions  : 10000, 14800, 3  (nrow, ncol, nlyr)
    #resolution  : 50, 50  (x, y)
    #extent      : 2317000, 3057000, 913000, 1413000  (xmin, xmax, ymin, ymax)
    #coord. ref. : CH1903+ / LV95 (EPSG:2056) 
    #source      : swiss-map-raster1000_2022_1000_kgrel_50_2056.tif 
    #colors RGB  : 1, 2, 3 
    #names       : swiss-map-~0_2056_1; , swiss-map-~0_2056_2; , swiss-map-~0_2056_3;  
    

    And plot it like this

    plot(f)
    

    enter image description here .

    You can zoom in with zoom(x) and clicking twice on the map to create a box. To get, e.g.,

    enter image description here