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

Lesson 01 (plotting) questions #20

Closed
KristinaRiemer opened this issue Nov 5, 2015 · 11 comments
Closed

Lesson 01 (plotting) questions #20

KristinaRiemer opened this issue Nov 5, 2015 · 11 comments

Comments

@KristinaRiemer
Copy link
Contributor

So first, when I made a pull request, it said there are merge conflicts and I have no idea how to deal with that.

Second, what is the difference between plot() and image(), and do we need to introduce image here?

Third, is there anything else that needs to be included in this lesson? I can't think of anything that is basic that might be useful.

@lwasser
Copy link
Member

lwasser commented Nov 5, 2015

Hi Kristina! Thank you for working on this today :) i think i took care of the merge conflicts. have a look at the file to make sure all looks ok!

Do you know how to update your branch BEFORE doing a pull request. Or the other option is that you can work directly in the repo if you want to do that. whatever you prefer. then you don't have to do a pull request. totally up to you how you'd like to work. Just say the word if you need further explanation! :)

i will look at the lesson tomorrow and see if i have ideas in terms of what to include.

i have the same question as you about the image vs plot. i know there are some differences in terms of how the axes render, etc... but maybe someone else knows more? pinging @jhollist @bbest ?? image vs plot anyone know how they differ?

@bbest
Copy link

bbest commented Nov 5, 2015

Note that when you look for help on plot (ie type ?plot at the command prompt) and you already have the raster package already loaded (ie library(raster)), then you're presented with help documentation on functions from two different packages:

Similarly with ?image:

The graphics library is a base package, and raster an add-on. Following the links to documentation above, especially raster::image yields the best summary of differences:

This is an implementation of a generic function in the graphics package. In most cases the plot function would be preferable because it produces a legend (and has some additional options).

@jhollist
Copy link

jhollist commented Nov 5, 2015

What @bbest said!

To add, plot will handle colormaps (if they exist) and image won't. There also can be a performance hit on image if you are limiting the x or y axis. IMO, plot is preferable and for this lesson in which we use raster sticking with plot makes the most sense.

@KristinaRiemer
Copy link
Contributor Author

Thanks for all the helpful and prompt comments y'all!

@lwasser I definitely forgot to update my branch! I'm still getting used to the collaborative workflow in Github, which is why I would kind of prefer to do pull requests instead of changing the repo directly, if that's okay? This adds another step, but I can accept my pull requests myself so that it's not a hassle for anyone else.

@bbest and @jhollist My intuition was to just use plot for this lesson, so I'm glad you both seem to concur.

During the hackathon, we discussed whether or not to explain the difference between the base R plot and the raster plot functions during the lesson. Does that seem important/a good use of time to people? I'm starting to think it might be a good idea so that people aren't confused about the multiple options when they use ?plot.

@jhollist
Copy link

jhollist commented Nov 5, 2015

@KristinaRiemer I think it is OK to mention this but more as an abstract concept, as we don't want to get into the details of OOP in R. I wouldn't be able to help too much with that anyway, as I don't know a whole lot. Plus from what I hear it is a bit of a mess.

I think you can say something about many functions (including plot) often have specific implementations written for specific packages. As long as you have the package loaded into the current session R will know which version of plot to use. Perhaps we could show the error that occurs if you try to plot a raster object without having raster loaded up. Something like

rast_obj<-raster::raster("file.tif")
plot(rast_obj)

should do the trick and will return the "cannot coerce type 'S4' to vector of type 'double'" error. If they know about that it should hopefully server as reminder to library(raster).

@KristinaRiemer
Copy link
Contributor Author

@jhollist That's about the level of detail we were thinking about, including trying to plot a raster with the base plot. As @brymz had brought up, it seems like something general that everyone who codes in R should be aware of.

I'll incorporate that into the lesson when I get a chance next week. Thanks!

@lwasser
Copy link
Member

lwasser commented Nov 5, 2015

Thank you @KristinaRiemer - whatever work flow is good for you, is good for me! :) it will be useful to fork and work remotely to learn more about collaboration in git! Let me know if you run into any other issues. It's much easier to resolve merge conflicts using shell / command line. Very happy to walk you through some of the basics IF at some point you'd like to do that :) Thank you again for the help with this.

I'm going to have a look at the lessons again and will post another issue about plot vs ggplot2. I'm almost thinking it's worth introducing ggplot somewhere early in the workshop materials. But i want everyone's input on this! I get it's a very different syntax approach but it's also very powerful and efficient for mapping from what i can tell so far.

@lwasser
Copy link
Member

lwasser commented Nov 9, 2015

Hi @KristinaRiemer ! a quick update!
I went through the plot rasters lesson and added a hill shade exercise at the end (overlaying one raster over another and adding transparency. See what you think and feel free to edit away!

http://data-lessons.github.io/NEON-R-Spatial-Raster/R/Plot-Rasters-In-R.R/

I thought that would be cool because then in lesson 02 (a new lesson) i added something on reprojection and used the same set of data and same plotting techniques HOWEER one of the hillshades is in the wrong projection. So it doesn't line up! It's a nice way to reinforce plotting in the following lesson but also introduce projection issues. Anyway - see what you think, when you have time!

@KristinaRiemer
Copy link
Contributor Author

@lwasser I like the hill shade overlay added to this lesson. Where can I get the hill shade raster file? (I don't think it's in the figshare).

I'm wondering a bit about the use of "overlay" between lessons 01 and 03. In lesson 01, this means to put a raster on top of another visually, while in lesson 03 overlay means doing math using two rasters. This might be unnecessarily picky, but I could see how this might confuse participants.

@lwasser
Copy link
Member

lwasser commented Nov 12, 2015

@KristinaRiemer totally not picky -- good point. It will be confusing.

Hmmm... language. what language should we use then to stack two rasters on top of each other like we do in the hillshade? Any ideas?

Also - the hillshade is in the most current figshare download! Thank you for noting this.

http://files.figshare.com/2434040/NEON_RemoteSensing.zip

@brymz
Copy link
Contributor

brymz commented Nov 12, 2015

Is an image that represents multiple bands a 'composite' image? 'Stack' is also a potential good option.

@lwasser lwasser closed this as completed Mar 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants