[RS-ecology] RS-ecology Digest, Vol 29, Issue 2

Rop Willy ropcwillies at gmail.com
Thu Jul 12 03:13:50 CEST 2018


Thanks to Benjamin Leutner and Brent Thorne for the invaluable help. All
the techniques work very well. Thanks again. Looking forward to buying the
next book

On Wed, Jul 11, 2018 at 4:05 PM, <rs-ecology-request at lists.uni-wuerzburg.de>
wrote:

> Send RS-ecology mailing list submissions to
>         rs-ecology at lists.uni-wuerzburg.de
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         https://lists.uni-wuerzburg.de/mailman/listinfo/rs-ecology
> or, via email, send a message with subject or body 'help' to
>         rs-ecology-request at lists.uni-wuerzburg.de
>
> You can reach the person managing the list at
>         rs-ecology-owner at lists.uni-wuerzburg.de
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of RS-ecology digest..."
>
>
> Today's Topics:
>
>    1. Re: ADDING SCALE BAR AND CUSTOM COLOURS IN ggplot2
>       (Benjamin Leutner)
>    2. Re: ADDING SCALE BAR AND CUSTOM COLOURS IN ggplot2 (Brent Thorne)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Wed, 11 Jul 2018 13:12:47 +0200
> From: Benjamin Leutner <benjamin.leutner at uni-wuerzburg.de>
> To: rs-ecology at lists.uni-wuerzburg.de
> Subject: Re: [RS-ecology] ADDING SCALE BAR AND CUSTOM COLOURS IN
>         ggplot2
> Message-ID: <ac4f2897-51e2-d9ac-b7df-5de47262281c at uni-wuerzburg.de>
> Content-Type: text/plain; charset="utf-8"; Format="flowed"
>
> You're close. You need to use scale_fill_manual()
> ## Example (custom scale and NA handling):
> data(lsat)
> lsat[1:10,] <- NA ## add some NAs
> usc <- unsuperClass(lsat,nClasses=2)
> ggR(usc$map, geom_raster = TRUE, forceCat = TRUE) +
>  ??????? scale_fill_manual(values=c("red", "green"),? na.translate =
> FALSE)
>
>
> ## Scalebar:
> Here's what I use for local projected coordinate systems (e.g. UTM)
> Neither pretty, nor smart, but it does exactly that: a simple scalebar
>
> https://gist.github.com/bleutner/08fb0a5a893552b4413bbe02930f722d
>
> For more involved options have a look at the "ggsn" package (I'm not
> familiar with it, though)
>
>
>
> On 10.07.2018 19:54, Rop Willy wrote:
> >
> > Hi,
> >
> > The book is awesome and very helpful. I am doing practice and now in
> > Chapter 8. The code runs very well but I have three questions
> > concerning the final map produced:
> >
> >  1. When I plot the classification map using ggplot2 I?d like to use
> >     my own color scheme but don?t know how. I?ve tried using
> >     *scale_colour_manual ()* from the ggplot2 package as well as
> >     *scalebar()* from ggsn package but haven?t really been successful.
> >     The code I used is as follows:
> >
> > |// Used ggR() to plot the map map <- ggR(p224r63_2011_uc$map,
> > geom_raster = TRUE) // Then used custom theme elements to add other
> > features map + scale_x_continuous(expand = c(0, 0)) +
> > scale_y_continuous(expand = c(0, 0)) + labs(x = NULL, y = NULL) +
> > theme(axis.text.x = element_text(colour = "grey40", size = 6),
> > axis.text.y = element_text(colour = "grey40", size = 6, angle = 90,
> > hjust = 0.5), legend.text = element_text(colour = "grey10", size = 6),
> > legend.title = element_text(colour = "grey10", size = 8, face =
> > "bold"), axis.ticks = element_line(colour = "grey40")) |
> >
> > How can I change the color scheme manually in ggplot2 instead of using
> > RColorBrewer and other palettes? NB: I?ve tried most options from
> > Stack Overflow and other references but nothing seems to work for me.
> >
> > 1.
> >
> >     How do I set a simple scale bar like the one used in the book
> >     and/or the variant of it in ggplot2?
> >
> > 2.
> >
> >     When I plot the map for the unsupervised classification (again in
> >     ggplot2) there?s a class called NA ( I suppose from unclassified
> >     pixels) that appear grey on the legend. Should it be there or
> >     should I remove it? If it is not necessary, how is it removed from
> >     the final map presentation?
> >
> > Regards
> >
> > ?
> >
> >
> > _______________________________________________
> > RS-ecology mailing list
> > RS-ecology at lists.uni-wuerzburg.de
> > https://lists.uni-wuerzburg.de/mailman/listinfo/rs-ecology
>
> --
> Benjamin Leutner
>
> Department of Remote Sensing
> University of Wuerzburg
> Campus Hubland Nord 86
> 97074 Wuerzburg, Germany
>
> Tel: +49-(0)931-31 89594
> Email: benjamin.leutner at uni-wuerzburg.de
> Web: http://www.fernerkundung.uni-wuerzburg.de
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://lists.uni-wuerzburg.de/pipermail/rs-ecology/
> attachments/20180711/edaad4d1/attachment-0001.html>
>
> ------------------------------
>
> Message: 2
> Date: Wed, 11 Jul 2018 13:05:47 +0000
> From: Brent Thorne <bt10yi at brocku.ca>
> To: Benjamin Leutner <benjamin.leutner at uni-wuerzburg.de>,
>         "rs-ecology at lists.uni-wuerzburg.de"
>         <rs-ecology at lists.uni-wuerzburg.de>
> Subject: Re: [RS-ecology] ADDING SCALE BAR AND CUSTOM COLOURS IN
>         ggplot2
> Message-ID:
>         <YTOPR0101MB1273014AF9510D62870267B8D35A0 at YTOPR0101MB1273.
> CANPRD01.PROD.OUTLOOK.COM>
>
> Content-Type: text/plain; charset="utf-8"
>
> For the scale bar I would recommended the `ggspatial` package available on
> CRAN<https://cran.r-project.org/web/packages/ggspatial/index.html> or on
> github<https://github.com/paleolimbot/ggspatial>. It has automatically
> applied spatially aware scalebars with only a simple
> `annotation_scalebar()+` needed.  There are also other nice cartographic
> options available in this package like vectorized north arrows, where
> `ggsn` uses a png file for its north arrow options which is not ideal for
> scaling. Here is the ReadMe<https://github.com/paleolimbot/ggspatial/blob/
> master/README.md> documentation from GitHub.
>
> W. Brent Thorne, BSc
> Master of Science Candidate
> Brock University | Department of Earth Sciences
> Niagara Region | 1812 Sir Isaac Brock Way | St. Catharines, Ontario, L2S
> 3A1
>
> ________________________________
> From: RS-ecology <rs-ecology-bounces at lists.uni-wuerzburg.de> on behalf of
> Benjamin Leutner <benjamin.leutner at uni-wuerzburg.de>
> Sent: Wednesday, July 11, 2018 7:12:47 AM
> To: rs-ecology at lists.uni-wuerzburg.de
> Subject: Re: [RS-ecology] ADDING SCALE BAR AND CUSTOM COLOURS IN ggplot2
>
> You're close. You need to use scale_fill_manual()
> ## Example (custom scale and NA handling):
> data(lsat)
> lsat[1:10,] <- NA ## add some NAs
> usc <- unsuperClass(lsat,nClasses=2)
> ggR(usc$map, geom_raster = TRUE, forceCat = TRUE) +
>         scale_fill_manual(values=c("red", "green"),  na.translate = FALSE)
>
>
> ## Scalebar:
> Here's what I use for local projected coordinate systems (e.g. UTM)
> Neither pretty, nor smart, but it does exactly that: a simple scalebar
>
> https://gist.github.com/bleutner/08fb0a5a893552b4413bbe02930f722d
>
> For more involved options have a look at the "ggsn" package (I'm not
> familiar with it, though)
>
>
>
> On 10.07.2018 19:54, Rop Willy wrote:
>
> Hi,
>
> The book is awesome and very helpful. I am doing practice and now in
> Chapter 8. The code runs very well but I have three questions concerning
> the final map produced:
>
>   1.  When I plot the classification map using ggplot2 I?d like to use my
> own color scheme but don?t know how. I?ve tried using scale_colour_manual
> () from the ggplot2 package as well as scalebar() from ggsn package but
> haven?t really been successful. The code I used is as follows:
>
>
> // Used ggR() to plot the map
>
> map <- ggR(p224r63_2011_uc$map, geom_raster = TRUE)
>
> // Then used custom theme elements to add other features
>
> map + scale_x_continuous(expand = c(0, 0)) + scale_y_continuous(expand =
> c(0, 0)) + labs(x = NULL, y = NULL) + theme(axis.text.x =
> element_text(colour = "grey40", size = 6), axis.text.y =
> element_text(colour = "grey40", size = 6, angle = 90, hjust = 0.5),
> legend.text = element_text(colour = "grey10", size = 6), legend.title =
> element_text(colour = "grey10", size = 8, face = "bold"), axis.ticks =
> element_line(colour = "grey40"))
>
>
> How can I change the color scheme manually in ggplot2 instead of using
> RColorBrewer and other palettes? NB: I?ve tried most options from Stack
> Overflow and other references but nothing seems to work for me.
>
>   1.  How do I set a simple scale bar like the one used in the book and/or
> the variant of it in ggplot2?
>
>   2.  When I plot the map for the unsupervised classification (again in
> ggplot2) there?s a class called NA ( I suppose from unclassified pixels)
> that appear grey on the legend. Should it be there or should I remove it?
> If it is not necessary, how is it removed from the final map presentation?
>
> Regards
>
> ?
>
>
>
> _______________________________________________
> RS-ecology mailing list
> RS-ecology at lists.uni-wuerzburg.de<mailto:RS-ecology at lists.uni-wuerzburg.de
> >
> https://lists.uni-wuerzburg.de/mailman/listinfo/rs-ecology
>
>
>
> --
> Benjamin Leutner
>
> Department of Remote Sensing
> University of Wuerzburg
> Campus Hubland Nord 86
> 97074 Wuerzburg, Germany
>
> Tel: +49-(0)931-31 89594
> Email: benjamin.leutner at uni-wuerzburg.de<mailto:benjamin.
> leutner at uni-wuerzburg.de>
> Web: http://www.fernerkundung.uni-wuerzburg.de
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://lists.uni-wuerzburg.de/pipermail/rs-ecology/
> attachments/20180711/b8f60a80/attachment.html>
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> RS-ecology mailing list
> RS-ecology at lists.uni-wuerzburg.de
> https://lists.uni-wuerzburg.de/mailman/listinfo/rs-ecology
>
>
> ------------------------------
>
> End of RS-ecology Digest, Vol 29, Issue 2
> *****************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.uni-wuerzburg.de/pipermail/rs-ecology/attachments/20180712/c9318628/attachment.html>


More information about the RS-ecology mailing list