<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
You're close. You need to use scale_fill_manual()<br>
## Example (custom scale and NA handling):<br>
data(lsat)<br>
lsat[1:10,] <- NA ## add some NAs<br>
usc <- unsuperClass(lsat,nClasses=2)<br>
ggR(usc$map, geom_raster = TRUE, forceCat = TRUE) + <br>
scale_fill_manual(values=c("red", "green"), na.translate =
FALSE)<br>
<br>
<br>
## Scalebar: <br>
Here's what I use for local projected coordinate systems (e.g. UTM)<br>
Neither pretty, nor smart, but it does exactly that: a simple
scalebar<br>
<br>
<a class="moz-txt-link-freetext" href="https://gist.github.com/bleutner/08fb0a5a893552b4413bbe02930f722d">https://gist.github.com/bleutner/08fb0a5a893552b4413bbe02930f722d</a><br>
<br>
For more involved options have a look at the "ggsn" package (I'm not
familiar with it, though)<br>
<br>
<br>
<br>
<div class="moz-cite-prefix">On 10.07.2018 19:54, Rop Willy wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAHwAZ_QJE9Fm-KWWMbAHZ3XdTEB8WytUjT03Y3JFY6otp8Q0GA@mail.gmail.com">
<div dir="ltr">
<div class="markdown-here-wrapper" style="">
<p style="margin:0px 0px 1.2em!important">Hi,</p>
<p style="margin:0px 0px 1.2em!important">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:</p>
<ol style="margin:1.2em 0px;padding-left:2em">
<li style="margin:0.5em 0px">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 <strong>scale_colour_manual
()</strong> from the ggplot2 package as well as <strong>scalebar()</strong>
from ggsn package but haven’t really been successful. The
code I used is as follows:</li>
</ol>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code class="hljs language-javascript" style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline;white-space:pre;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important;display:block;overflow-x:auto;padding:0.5em;color:rgb(0,0,0);background:rgb(248,248,255)">
<span class="hljs-comment" style="color:rgb(64,128,128);font-style:italic">// Used ggR() to plot the map</span>
map <- ggR(p224r63_2011_uc$map, geom_raster = TRUE)
<span class="hljs-comment" style="color:rgb(64,128,128);font-style:italic">// Then used custom theme elements to add other features</span>
map + scale_x_continuous(expand = c(<span class="hljs-number" style="color:rgb(64,160,112)">0</span>, <span class="hljs-number" style="color:rgb(64,160,112)">0</span>)) + scale_y_continuous(expand = c(<span class="hljs-number" style="color:rgb(64,160,112)">0</span>, <span class="hljs-number" style="color:rgb(64,160,112)">0</span>)) + labs(x = NULL, y = NULL) + theme(axis.text.x = element_text(colour = <span class="hljs-string" style="color:rgb(33,145,97)">"grey40"</span>, size = <span class="hljs-number" style="color:rgb(64,160,112)">6</span>), axis.text.y = element_text(colour = <span class="hljs-string" style="color:rgb(33,145,97)">"grey40"</span>, size = <span class="hljs-number" style="color:rgb(64,160,112)">6</span>, angle = <span class="hljs-number" style="color:rgb(64,160,112)">90</span>, hjust = <span class="hljs-number" style="color:rgb(64,160,112)">0.5</span>), legend.text = element_text(colour = <span class="hljs-string" style="color:rgb(33,145,97)">"grey10"</span>, size = <span class="hljs-number" style="color:rgb(64,160,112)">6</span>), legend.title = element_text(colour = <span class="hljs-string" style="color:rgb(33,145,97)">"grey10"</span>, size = <span class="hljs-number" style="color:rgb(64,160,112)">8</span>, face = <span class="hljs-string" style="color:rgb(33,145,97)">"bold"</span>), axis.ticks = element_line(colour = <span class="hljs-string" style="color:rgb(33,145,97)">"grey40"</span>))
</code></pre>
<p style="margin:0px 0px 1.2em!important">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.</p>
<ol style="margin:1.2em 0px;padding-left:2em">
<li style="margin:0.5em 0px">
<p style="margin:0px 0px 1.2em!important;margin:0.5em
0px!important">How do I set a simple scale bar like the
one used in the book and/or the variant of it in
ggplot2?</p>
</li>
<li style="margin:0.5em 0px">
<p style="margin:0px 0px 1.2em!important;margin:0.5em
0px!important">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?</p>
</li>
</ol>
<p style="margin:0px 0px 1.2em!important">Regards</p>
<div
title="MDH:PGRpdj5IaSw8L2Rpdj48ZGl2Pjxicj48L2Rpdj48ZGl2PlRoZSBib29rIGlzIGF3ZXNvbWUgYW5kIHZlcnkgaGVscGZ1bC4gSSBhbSBkb2luZyBwcmFjdGljZSBhbmQgbm93IGluIENoYXB0ZXIgOC4g
VGhlIGNvZGUgcnVucyB2ZXJ5IHdlbGwgYnV0IEkgaGF2ZSB0aHJlZSBxdWVzdGlvbnMgY29uY2Vy
bmluZyB0aGUgZmluYWwgbWFwIHByb2R1Y2VkOjwvZGl2PjxkaXY+PGJyPjwvZGl2PjxkaXY+MS4g
V2hlbiBJIHBsb3QgdGhlIGNsYXNzaWZpY2F0aW9uIG1hcCB1c2luZyBnZ3Bsb3QyIEknZCBsaWtl
IHRvIHVzZSBteSBvd24gY29sb3Igc2NoZW1lIGJ1dCBkb24ndCBrbm93IGhvdy4mbmJzcDsgSSd2
ZSB0cmllZCB1c2luZyAqKnNjYWxlX2NvbG91cl9tYW51YWwgKCkqKiBmcm9tIHRoZSBnZ3Bsb3Qy
IHBhY2thZ2UgYXMgd2VsbCBhcyAqKnNjYWxlYmFyKCkqKiBmcm9tIGdnc24gcGFja2FnZSBidXQg
aGF2ZW4ndCByZWFsbHkgYmVlbiBzdWNjZXNzZnVsLiBUaGUgY29kZSBJIHVzZWQgaXMgYXMgZm9s
bG93czo8L2Rpdj48ZGl2Pjxicj48L2Rpd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5IGluIGdncGxvdDIgaW5zdGVhZCBvZiB1c2luZyBSQ29sb3JCcmV3ZXIgYW5k
IG90aGVyIHBhbGV0dGVzPyZuYnNwOyBOQjogSSd2ZSB0cmllZCBtb3N0IG9wdGlvbnMgZnJvbSBT
dGFjayBPdmVyZmxvdyBhbmQgb3RoZXIgcmVmZXJlbmNlcyBidXQgbm90aGluZyBzZWVtcyB0byB3
b3JrIGZvciBtZS48L2Rpdj48ZGl2Pjxicj48L2Rpdj48ZGl2PjMuIEhvdyBkbyBJIHNldCBhIHNp
bXBsZSBzY2FsZSBiYXIgbGlrZSB0aGUgb25lIHVzZWQgaW4gdGhlIGJvb2sgYW5kL29yIHRoZSB2
YXJpYW50IG9mIGl0IGluIGdncGxvdDI/PC9kaXY+PGRpdj48YnI+PC9kaXY+PGRpdj40LiBXaGVu
IEkgcGxvdCB0aGUgbWFwIGZvciB0aGUgdW5zdXBlcnZpc2VkIGNsYXNzaWZpY2F0aW9uIChhZ2Fp
biBpbiBnZ3Bsb3QyKSB0aGVyZSdzIGEgY2xhc3MgY2FsbGVkIE5BICggSSBzdXBwb3NlIGZyb20g
dW5jbGFzc2lmaWVkIHBpeGVscykgdGhhdCBhcHBlYXIgZ3JleSBvbiB0aGUgbGVnZW5kLiBTaG91
bGQgaXQgYmUgdGhlcmUgb3Igc2hvdWxkIEkgcmVtb3ZlIGl0PyBJZiBpdCBpcyBub3QgbmVjZXNz
YXJ5LCBob3cgaXMgaXQgcmVtb3ZlZCBmcm9tIHRoZSBmaW5hbCBtYXAgcHJlc2VudGF0aW9uPzwv
ZGl2PjxkaXY+PGJyPjwvZGl2PjxkaXY+UmVnYXJkczwvZGl2Pg=="
style="height:0;width:0;max-height:0;max-width:0;overflow:hidden;font-size:0em;padding:0;margin:0"></div>
</div>
</div>
<!--'"--><br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
RS-ecology mailing list
<a class="moz-txt-link-abbreviated" href="mailto:RS-ecology@lists.uni-wuerzburg.de">RS-ecology@lists.uni-wuerzburg.de</a>
<a class="moz-txt-link-freetext" href="https://lists.uni-wuerzburg.de/mailman/listinfo/rs-ecology">https://lists.uni-wuerzburg.de/mailman/listinfo/rs-ecology</a>
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Benjamin Leutner
Department of Remote Sensing
University of Wuerzburg
Campus Hubland Nord 86
97074 Wuerzburg, Germany
Tel: +49-(0)931-31 89594
Email: <a class="moz-txt-link-abbreviated" href="mailto:benjamin.leutner@uni-wuerzburg.de">benjamin.leutner@uni-wuerzburg.de</a>
Web: <a class="moz-txt-link-freetext" href="http://www.fernerkundung.uni-wuerzburg.de">http://www.fernerkundung.uni-wuerzburg.de</a>
</pre>
</body>
</html>