Dear R users, i would like to plot the maps of the Gulf Cooperation Council (GCC) countries (KSA, Qatar, Bahrain, Kuwait, UAE and Oman) with these constraints: i/ KSA , Qatar and Bahrain have the same face color , ii/ Kuweit and UAE with the same face color and iii/Oman with another face color. Is there any code in R doing this task. Many thanks. [[alternative HTML version deleted]]
Hello George! Do you mean to have a map of the world with these countries filled in, or to have just those countries on the map, please? Thanks, Erin Erin Hodgess, PhD mailto: erinm.hodgess at gmail.com On Mon, Mar 30, 2020 at 7:38 PM george brida <george.brida at gmail.com> wrote:> Dear R users, > > i would like to plot the maps of the Gulf Cooperation Council (GCC) > countries (KSA, Qatar, Bahrain, Kuwait, UAE and Oman) with these > constraints: i/ KSA , Qatar and Bahrain have the same face color , ii/ > Kuweit and UAE with the same face color and iii/Oman with another face > color. Is there any code in R doing this task. > > Many thanks. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
Probably better posted to the r-sig-geo list, where you are more likely to find the relevant expertise. Perhaps see also https://cran.r-project.org/web/views/Spatial.html, depending on what you plan to do with your maps. Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Mon, Mar 30, 2020 at 8:03 PM Erin Hodgess <erinm.hodgess at gmail.com> wrote:> > Hello George! > > Do you mean to have a map of the world with these countries filled in, or > to have just those countries on the map, please? > > Thanks, > Erin > > Erin Hodgess, PhD > mailto: erinm.hodgess at gmail.com > > > On Mon, Mar 30, 2020 at 7:38 PM george brida <george.brida at gmail.com> wrote: > > > Dear R users, > > > > i would like to plot the maps of the Gulf Cooperation Council (GCC) > > countries (KSA, Qatar, Bahrain, Kuwait, UAE and Oman) with these > > constraints: i/ KSA , Qatar and Bahrain have the same face color , ii/ > > Kuweit and UAE with the same face color and iii/Oman with another face > > color. Is there any code in R doing this task. > > > > Many thanks. > > > > [[alternative HTML version deleted]] > > > > ______________________________________________ > > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
On 2020-03-31 03:38 +0200, george brida wrote:> i would like to plot the maps of the Gulf Cooperation Council (GCC) > countries (KSA, Qatar, Bahrain, Kuwait, UAE and Oman) with these > constraints: i/ KSA , Qatar and Bahrain have the same face color , ii/ > Kuweit and UAE with the same face color and iii/Oman with another face > color.Hi! Perhaps by using rnaturalearth, sf, and ggplot2: world <- rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") grp1 <- c("Saudi Arabia", "Qatar", "Bahrain") grp2 <- c("Kuwait", "United Arab Emirates") grp3 <- c("Oman") world$GCC <- rep(NA, length(world$name)) idx <- world$name %in% c(grp1, grp2, grp3) world$GCC[idx] <- world$name[idx] world$GCC world$CountryGroup <- rep(NA, length(world$name)) world$CountryGroup[world$name %in% grp1] <- "i/ KSA, Qatar and Bahrain" world$CountryGroup[world$name %in% grp2] <- "ii/ Kuwait and UAE" world$CountryGroup[world$name %in% grp3] <- "iii/ Oman" names(world) world <- cbind(world, sf::st_coordinates(sf::st_centroid(world$geometry))) ggplot2::ggplot(data = world) + ggplot2::theme_bw() + ggplot2::geom_sf() + ggplot2::geom_sf(fill = NA, color = gray(.5)) + ggplot2::geom_sf(ggplot2::aes(fill=CountryGroup)) + # ggrepel::geom_text_repel(ggplot2::aes(x=X, y=Y, label=GCC)) + # ggplot2::geom_sf(ggplot2::aes(fill=CountryGroup, label=CountryGroup)) + ggplot2::coord_sf(xlim = c(32, 61), ylim = c(10, 33), expand = FALSE) + ggplot2::xlab("Longitude") + ggplot2::ylab("Latitude") + ggplot2::ggtitle("Gulf Cooperation Council (GCC)") Regards, Rasmus
Hi George, Try this: library(maps) map("world",xlim=c(34.353,60.369),ylim=c(16.7,32.193), regions="Saudi Arabia",col="yellow",fill=TRUE) map("world",regions="Bahrain",col="yellow",fill=TRUE,add=TRUE) map("world",regions="Kuwait",col="lightblue",fill=TRUE,add=TRUE) map("world",regions="Qatar",col="yellow",fill=TRUE,add=TRUE) map("world",regions="United Arab Emirates",col="lightblue",fill=TRUE,add=TRUE) map("world",regions="Oman",col="lightgreen",fill=TRUE,add=TRUE) Jim On Tue, Mar 31, 2020 at 12:39 PM george brida <george.brida at gmail.com> wrote:> > Dear R users, > > i would like to plot the maps of the Gulf Cooperation Council (GCC) > countries (KSA, Qatar, Bahrain, Kuwait, UAE and Oman) with these > constraints: i/ KSA , Qatar and Bahrain have the same face color , ii/ > Kuweit and UAE with the same face color and iii/Oman with another face > color. Is there any code in R doing this task. > > Many thanks. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
Hi Erin, Thanks for the reply. I would like to have just those countries on the map. Best George On Tue, Mar 31, 2020 at 5:02 AM Erin Hodgess <erinm.hodgess at gmail.com> wrote:> Hello George! > > Do you mean to have a map of the world with these countries filled in, or > to have just those countries on the map, please? > > Thanks, > Erin > > Erin Hodgess, PhD > mailto: erinm.hodgess at gmail.com > > > On Mon, Mar 30, 2020 at 7:38 PM george brida <george.brida at gmail.com> > wrote: > >> Dear R users, >> >> i would like to plot the maps of the Gulf Cooperation Council (GCC) >> countries (KSA, Qatar, Bahrain, Kuwait, UAE and Oman) with these >> constraints: i/ KSA , Qatar and Bahrain have the same face color , ii/ >> Kuweit and UAE with the same face color and iii/Oman with another face >> color. Is there any code in R doing this task. >> >> Many thanks. >> >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> >[[alternative HTML version deleted]]
That would have been my code too! On Tue, Mar 31, 2020 at 2:10 AM Jim Lemon <drjimlemon at gmail.com> wrote:> Hi George, > Try this: > > library(maps) > map("world",xlim=c(34.353,60.369),ylim=c(16.7,32.193), > regions="Saudi Arabia",col="yellow",fill=TRUE) > map("world",regions="Bahrain",col="yellow",fill=TRUE,add=TRUE) > map("world",regions="Kuwait",col="lightblue",fill=TRUE,add=TRUE) > map("world",regions="Qatar",col="yellow",fill=TRUE,add=TRUE) > map("world",regions="United Arab > Emirates",col="lightblue",fill=TRUE,add=TRUE) > map("world",regions="Oman",col="lightgreen",fill=TRUE,add=TRUE) > > Jim > > On Tue, Mar 31, 2020 at 12:39 PM george brida <george.brida at gmail.com> > wrote: > > > > Dear R users, > > > > i would like to plot the maps of the Gulf Cooperation Council (GCC) > > countries (KSA, Qatar, Bahrain, Kuwait, UAE and Oman) with these > > constraints: i/ KSA , Qatar and Bahrain have the same face color , ii/ > > Kuweit and UAE with the same face color and iii/Oman with another face > > color. Is there any code in R doing this task. > > > > Many thanks. > > > > [[alternative HTML version deleted]] > > > > ______________________________________________ > > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Erin Hodgess, PhD mailto: erinm.hodgess at gmail.com [[alternative HTML version deleted]]
Dear Jim, Thank you very much. I obtained now the required map. I would like to know how to add the names of the countries. Best George On Tue, Mar 31, 2020 at 10:10 AM Jim Lemon <drjimlemon at gmail.com> wrote:> Hi George, > Try this: > > library(maps) > map("world",xlim=c(34.353,60.369),ylim=c(16.7,32.193), > regions="Saudi Arabia",col="yellow",fill=TRUE) > map("world",regions="Bahrain",col="yellow",fill=TRUE,add=TRUE) > map("world",regions="Kuwait",col="lightblue",fill=TRUE,add=TRUE) > map("world",regions="Qatar",col="yellow",fill=TRUE,add=TRUE) > map("world",regions="United Arab > Emirates",col="lightblue",fill=TRUE,add=TRUE) > map("world",regions="Oman",col="lightgreen",fill=TRUE,add=TRUE) > > Jim > > On Tue, Mar 31, 2020 at 12:39 PM george brida <george.brida at gmail.com> > wrote: > > > > Dear R users, > > > > i would like to plot the maps of the Gulf Cooperation Council (GCC) > > countries (KSA, Qatar, Bahrain, Kuwait, UAE and Oman) with these > > constraints: i/ KSA , Qatar and Bahrain have the same face color , ii/ > > Kuweit and UAE with the same face color and iii/Oman with another face > > color. Is there any code in R doing this task. > > > > Many thanks. > > > > [[alternative HTML version deleted]] > > > > ______________________________________________ > > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]