class: center, middle, inverse, title-slide # Swiss Geodata 4 R ## Simplifying Access to Raster and Vector data from within R ### Nils Ratnaweera ### 2018-12-05 --- ## What's this about? -- I would like to simplify access to swisstopo geodata from within `R`. Currently, using swisstopo maps in `R` is easy if: -- - the map only incldes _one single_ file<sup>1</sup> -- - you know exactly where to find that file -- .footnote[[1] Smaller scale maps are split into multiple tiles. For exmple, the 1:25'000 map consists of 260 Tiles] --- ## Current workflow To create a map with one of these tiles, we have to follow the following steps: -- 1. first decide on a scale -- 2. look for the relevant map numbers based on the division (“Blatteinteilung”) -- 3. find the appropriate raster maps based on the map numbers from the previous step -- 4. import raster into R -- 5. check raster resolutions and possibly resample all rasters to same resolution -- 6. merge all the relevant raster maps into a single file -- 7. possibly reassign CRS and colormap -- -- 8. finally: plot data -- --- ## Current workflow To create a map with one of these tiles, we have to follow the following steps: 1. first decide on a scale 2. ~~look for the relevant map numbers based on the division (“Blatteinteilung”)~~ 3. ~~find the appropriate raster maps based on the map numbers from the previous step~~ 4. ~~import raster into R~~ 5. ~~check raster resolutions and possibly resample all rasters to same resolution~~ 6. ~~merge all the relevant raster maps into a single file~~ 7. ~~possibly reassign CRS and colormap~~ 8. finally: plot data → This is where `swissrastermaps4r` comes in. → It is a package that automates steps 2 - 7 --- ## swissrastermaps4r ```r *library(swissrastermaps4r) ``` -- ```r init_fdir("C:/Users/rata/Geodata/01_Switzerland/01_Maps") ``` ``` ## [1] "Done. 372 Files saved in fdir. Use show_extents() to show their extents." ``` -- ```r *zuerich_raster <- get_raster(zuerich,scale_level = 100,method = "bbox") ``` --- ## swissrastermaps4r ```r *tm_shape(zuerich_raster) + tm_rgb() + tm_shape(zuerich,is.master = T) + tm_borders(col = "red",lwd = 3) ``` <!-- --> --- ## Want to join? I'm looking for people who would like to simplify access for swiss raster maps in `R` because: -- - you use swiss raster maps in `R` _and / or_ -- - you want to learn package development _and / or_ -- - you have connections to **swisstopo** and/or **geodata4edu** _and / or_ -- - you have too much spare time 😄 ### Contact me! **rata@zhaw.ch** --- ## It's on Github! [https://github.engineering.zhaw.ch/rata/swissmapraster](https://github.engineering.zhaw.ch/rata/swissmapraster)  -- Openly accessible on the **ZHAW** github, I can easily move it to github.com **rata@zhaw.ch**