Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add description how this can be added to the .Renviron / .Rprofile #101

Open
github-actions bot opened this issue Feb 10, 2021 · 0 comments
Open

add description how this can be added to the .Renviron / .Rprofile #101

github-actions bot opened this issue Feb 10, 2021 · 0 comments
Assignees
Labels

Comments

@github-actions
Copy link

add description how this can be added to the .Renviron / .Rprofile

/ todo: add description how this can be added to the .Renviron / .Rprofile

For this chapter, you will need the following packages and datasets:

```{r}
library(arc2r) 
library(sf)
library(raster)

data("gemeinde_zh")
data("swissAlti3D")

As we saw in chapter @ref(importing-vector-sf), we can quickly visualize an sf object by simply calling plot. This will return a small multiple of your geodata, where each facet is colour coded based on a column.

plot(gemeinde_zh)

You will get one facet for each column, where the maximum number of facets is set to 9 by default. I find this behaviour pretty annoying, since I usually just want get a quick look at the data in space, and these small multiples take ages to render. There are several workarounds to prevent small multiples:

  1. Extract the geometry from the sf object and just plot that
  2. Specify the column which should colourcode your data
  3. Specify max.plot = 1 to just plot 1 facet (using the first column in your dataset for colour coding)
  4. Set the option sf_max.plot to 1 with Option(sf_max.plot = 1) (this will persist throughout your R Session)

plot(st_geometry(gemeinde_zh))  # 1
plot(gemeinde_zh["bezirksnam"]) # 2
plot(gemeinde_zh, max.plot = 1) # 3

options(sf_max.plot = 1)        # 4
plot(gemeinde_zh)

We dont have the "problem" of facets with raster data, so we can simply call plot() on a raster object to visualize it.

plot(swissAlti3D)

The plot() method is fine for quick view of the data, but as you want to add more layers, legend etc. plot() becomes complicated. There are many alternative methods to visualizing spatial data, we will showcase our favourite methods here.

Package ggplot2


f4a6f112fa74a6a851e4e325c6387bc660524d52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant