Dear All.
Kindly assist me with the proper code for the following. I have converted
the dose to factor and grouped it into 5 levels. I need to assign a color
code to each of the levels and use is for spatial mapping. Thank you
ggplot(Mrima, mapping=aes(x=lon,y=lat))+
geom_point(data=Mrima, aes(colour=factor(dose),
cut(dose,br=c(0,60,120,360,600,5144)))) +
scale_color_manual(my_col, values = c("#D01556#", "#DF785B","EFDC60",
"#B5D374","#7CCA89"),breaks=waiver(), aesthetics =c("colour","fill"))
This is the error I am getting
Error: Insufficient values in manual scale. 1806 needed but only 5 provided.
On Mon, 16 Mar 2020, PAMELLA KAGELIZA KILAVI wrote:
Dear All.
Kindly assist me with the proper code for the following. I have converted
the dose to factor and grouped it into 5 levels. I need to assign a color
code to each of the levels and use is for spatial mapping. Thank you
ggplot(Mrima, mapping=aes(x=lon,y=lat))+
geom_point(data=Mrima, aes(colour=factor(dose),
cut(dose,br=c(0,60,120,360,600,5144)))) +
scale_color_manual(my_col, values = c("#D01556#", "#DF785B","EFDC60",
"#B5D374","#7CCA89"),breaks=waiver(), aesthetics =c("colour","fill"))
This is the error I am getting
Error: Insufficient values in manual scale. 1806 needed but only 5 provided.
Please either make the Mrima object available for download (provide a URL,
do not attach), or use a built-in data set to reproduce the problem. I
think that the arguments to geom_point() are either not as expected, or
should be named, or both. I further think that Mrima should be as sf
object, and if you then use tmap (or tmap or mapview for webmaps), life
may become much easier. See perhaps:
https://geocompr.robinlovelace.net/adv-map.html,
https://www.r-spatial.org/r/2018/10/25/ggplot2-sf.html,
https://r-spatial.github.io/sf/articles/sf5.html
Using the North Carolina SIDS data set, I get:
library(sf)
Linking to GEOS 3.8.0, GDAL 3.1.0dev-e52a02d452, PROJ 7.0.0
aes(colour=dose_f)) + scale_colour_manual(values=c("#D01556",
"#DF785B","#EFDC60","#B5D374","#7CCA89"),breaks=waiver(), aesthetics
=c("colour","fill"))
As an alternative, since we already had an sf object:
Thank you. I actually have converted Mrima into sf to be able to use the
lon and lat after filtering it from the main file fetched by readxl of
different files downloaded from Safecast bGeiger nano Counter.
the continuous data on continuous scale worked out perfectly with
scale_color_viridis. However, However, we are interested in highlighting
areas that are hot spots around the area. We, therefore, need the data such
that we classed kind of post map (as used in Surfer program) such that the
geo-referenced dose rates are grouped into coded discrete classes.
Let me try out. I will get back to you with the progress
Once again thank you for the feedback
On Mon, Mar 16, 2020 at 7:55 PM Roger Bivand <Roger.Bivand at nhh.no> wrote:
On Mon, 16 Mar 2020, PAMELLA KAGELIZA KILAVI wrote:
Dear All.
Kindly assist me with the proper code for the following. I have converted
the dose to factor and grouped it into 5 levels. I need to assign a color
code to each of the levels and use is for spatial mapping. Thank you
ggplot(Mrima, mapping=aes(x=lon,y=lat))+
geom_point(data=Mrima, aes(colour=factor(dose),
cut(dose,br=c(0,60,120,360,600,5144)))) +
scale_color_manual(my_col, values = c("#D01556#", "#DF785B","EFDC60",
"#B5D374","#7CCA89"),breaks=waiver(), aesthetics =c("colour","fill"))
This is the error I am getting
Error: Insufficient values in manual scale. 1806 needed but only 5
provided.
Please either make the Mrima object available for download (provide a URL,
do not attach), or use a built-in data set to reproduce the problem. I
think that the arguments to geom_point() are either not as expected, or
should be named, or both. I further think that Mrima should be as sf
object, and if you then use tmap (or tmap or mapview for webmaps), life
may become much easier. See perhaps:
https://geocompr.robinlovelace.net/adv-map.html,
https://www.r-spatial.org/r/2018/10/25/ggplot2-sf.html,
https://r-spatial.github.io/sf/articles/sf5.html
Using the North Carolina SIDS data set, I get:
library(sf)
Linking to GEOS 3.8.0, GDAL 3.1.0dev-e52a02d452, PROJ 7.0.0
aes(colour=dose_f)) + scale_colour_manual(values=c("#D01556",
"#DF785B","#EFDC60","#B5D374","#7CCA89"),breaks=waiver(), aesthetics
=c("colour","fill"))
As an alternative, since we already had an sf object:
will create an sf object defined in decimal degrees (possibly your lon and
lat if they are decimal degrees).
Hope this helps,
Roger
--
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; e-mail: Roger.Bivand at nhh.no
https://orcid.org/0000-0003-2392-6140https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en