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

Intergrating tmap and qtm() for quick visualization of raster/vector data #307

Open
dcarver1 opened this issue Dec 17, 2019 · 3 comments
Open
Labels
type:discussion Discussion or feedback about the lesson type:enhancement Propose enhancement to the lesson

Comments

@dcarver1
Copy link

Hello,
I appreciated the direction and overall need for this lesson, but as I was working through, I couldn't help but think to myself that this was a lot of flipping rasters to data frames and building out ggplot statements.
I understand the utility of ggplot, and it should be a core part of this lesson. Yet, in my workflows with spatial data in R, I rely heavily on the library tmap and the function qtm to provide quick visual checks of the data.

For example, lesson 4 we plot a df derived from a raster with the following code

ggplot() +
      geom_raster(data = DTM_HARV_df , 
              aes(x = x, y = y, fill = HARV_dtmCrop)) +
     scale_fill_gradientn(name = "Elevation", colors = terrain.colors(10)) + 
     coord_quickmap()

We could send a few less minutes typing (these ggplot elements are used later in the lesson) and use a single line as this is just for visualization purposes.

qtm(DTM_HARV)

Yes, we loose some controll and visualization techniques, but I just don't think we need to worry about the color gradiaent or the legend name in cases where we just want to see what we are working with.

Again, for me, this all comes back to wanting to spend more time talking about spatial data and less time typing out ggplot statements. This may be outside the framework of the lesson, but I'm curious what others think about it.

@jsta
Copy link
Member

jsta commented Dec 18, 2019

Hi @dcarver1, you might be interested in previous discussion of tmap in #133 and links therein. Personally, I favor a ggplot only approach because it means that only one tool needs to be explained and ggplot has more "brand" recognition outside the spatial community. I do agree with your point however that ggplot plotting of raster objects is a bit clunky.

@mstrimas
Copy link
Contributor

mstrimas commented Mar 7, 2020

I'm working through these lessons in preparation for teaching an upcoming workshop and want to second the opinion that ggplot2 is the wrong choice for much of this material, for the following reasons:

  1. It won't plot rasters natively so we're always having to convert to data frames
  2. ggplot2 performs poorly for large rasters and requires loading all the data into memory, loosing one of the main benefits of the raster package. In contrast, I regularly plot massive raster datasets with raster::plot() without issue.
  3. I can see an argument for using ggplot to make "pretty" raster maps, but it's unreasonable to suggest using it to make quick exploratory maps as in the Raster Calculations in R episode. ggplot requires a ton of typing, plot() saves so much time teaching.
  4. If you want to make true, publication quality maps, ggplot simply does't get you there. For example, I produce these maps, all of which are done with plot(), and I'd argue it would be challenging to make something like this in ggplot: https://ebird.org/science/status-and-trends/woothr. plot() is good for the whole spectrum, from exploratory maps to publication quality maps.

@jsta if your daily work, if you load a raster for the first time and want to quickly visualize it to see what you're dealing with, do you actually go to the trouble of typing all the ggplot syntax?

For context, I'll say that I'm a diehard Tidyverse/ggplot fan in almost all scenarios, and I do often use it for vector data, but despite that I don't think it's the way to go for raster plotting. I also agree with @jsta that adding a new tool (tmap) is problematic, so why not use raster::plot(). Perhaps ggplot for the plotting specific lessons making "pretty" maps, but sub in plot() for other lessons when you just want a quick exploratory map.

To be clear, I'm just referring to raster data here, vector plotting is a different story.

@jsta
Copy link
Member

jsta commented Jul 18, 2020

True, I rarely type out the ggplot syntax for rasters in my daily work. My goto is actually mapview for interactive work.

My opinion is that we should leave the written lesson material in ggplot but individual instructors can sub-out or supplement the ggplot code with raster::plot() on the fly in the workshop itself. However I don't have strong feelings about this.

One sticking point I see is how to handle lesson 11, which combines vector and raster layers, if we drop ggplot for rasters but don't drop ggplot for vector layers.

@jsta jsta added type:discussion Discussion or feedback about the lesson type:enhancement Propose enhancement to the lesson labels Jul 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:discussion Discussion or feedback about the lesson type:enhancement Propose enhancement to the lesson
Projects
None yet
Development

No branches or pull requests

3 participants