Closed jackienyr93 closed 2 months ago
Hi @jackienyr93 I'm away today but I'll have a look this evening.
awesome! thanks so much @emhart
@jackienyr93 Here's a fix for you. The main problem is that the countries in the data and in the map data frame don't match. In the code below I find the missing country and exclude it from the mapping data frame. In the future I'll fix this so it's transparent and still plots. The country causing our problems is "UMI" or "US Minor Islands". When I check where they have data from, there's no UMI data until 2010. Here's the code I used. Also, you don't need to re-order the data frame like you're doing, just run a basic subset will get the job done. Let me know if this fix works for you.
library(rWBclimate)
options(kmlpath="~/kmltmp")
world <- c(NoAm_country,SoAm_country,Eur_country,Asia_country,Africa_country,Oceana_country)
world_map_df <- create_map_df(world)
world_dat4 <- get_historical_temp(world, "year")
### Get the year of interest
world_dat_sm <- subset(world_dat4,year == 1901)
### See what country is missing...
unique(world_map_df$ID)[!unique(world_map_df$ID)%in%world_dat_sm$locator]=
### We see it's UMI causing the problem.
world_map_df <- subset(world_map_df,ID!="UMI")
world_map <- climate_map(world_map_df,world_dat_sm,return_map = TRUE)
world_map + scale_fill_continuous("Temperature \n at 1901",low="yellow",high = "red") + theme_bw()
@emhart thank you so much!!!! this worked perfectly!!!
I am having the same issue. I tried to use the example you posted on rOpenSci, but I am getting the same error as @jackienyr93. I used the code on here to figure out which missing data, but I'm getting a character(0) return. Could you please help me with my error?
library("rWBclimate") library("spocc") library("plyr") library("sp") dir.create("~/kmltmp") options(kmlpath="~/kmltmp") options(stringsAsFactors = FALSE) require(rWBclimate) usmex <- c(273:284, 328:365) usmex.basin <- create_map_df(usmex) temp.dat <- get_model_temp(usmex, type= "mavg", 2080, 2100)
temp.dat <- subset(temp.dat, temp.dat$year ==2080) #for year 2080 temp.dat <- subset(temp.dat, temp.dat$gcm=="ukmo_hadcm3")
temp.dat <- subset(temp.dat, temp.dat$scenario!="b1")
usmex.map.df <- climate_map(usmex.basin, temp.dat, return_map =F)
polygon that I can plot later on. Error in climate_map(usmex.basin, temp.dat, return_map = F) : You can't have more than one piece of data for each region to map
any thoughts @emhart ?
Hmmm, @chinchuharris does the fix in the issue not work anymore?
@emhart That solution still works. I wasn't paying attention to the global environment in RStudio. I didn't have any data remaining after I ran all the subsets.
This package is about to be archived cf discussion in https://github.com/ropensci/rWBclimate/issues/47
Please contact info@ropensci.org
if you have any question or want to revive the package.
trying to make a world temperature map from 1901 but run into error at the end
world <- c(NoAm_country,SoAm_country,Eur_country,Asia_country,Africa_country,Oceana_country) world_map_df <- create_map_df(world) world_dat4 <- get_historical_temp(world, "year") world_dat4_small<-subset(world_dat4, year >=1901 & year <= 1901, select=c(1:length(world_dat4))) world_dat4<- world_dat4[order(world_dat4$locator),] world_map_df <- world_map_df[order(world_map_df$ID),] world_map <- climate_map(world_map_df,world_dat4_small,return_map = TRUE)
Error in climate_map(world_map_df, world_dat4_small, return_map = TRUE) : You can't have more than one piece fo data for each region to map
this would be the rest of the code world_map + scale_fill_continuous("Temperature \n at 1901",low="yellow",high = "red") + theme_bw()
any help would be greatly appreciated. or if you have another way to make a world map with historical temperatures…preferably before cars/smoke/etc affected world temps. thx!