Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create ggmap with the new code overlaid with ggplot commands (geom_point, scale_fill_gradient) #359

Open
bjkramerumnedu opened this issue Feb 20, 2024 · 0 comments

Comments

@bjkramerumnedu
Copy link

Hello,

I was able to get the base map, but I was hoping to overlay the map with data at specific geographic coordinates. I also wanted to color the data points based on numerical values. I know the main github page provides some description on how to do this with the new code, but I'm not sure how much of what I originally had before the switch from Stamen to Stadia maps still works.

I am able to get the map with the following code:

GLGG <- c(left = -92.5, bottom = 41, right = -76, top = 49)

LGL <- get_stadiamap(GLGG, zoom = 6, scale = 2, maptype = "stamen_toner_background") %>% ggmap()

But when I run the following code:

GreatLakesSurfaceAlkalinity <- ggmap(LGL) +
theme_void() +
theme(plot.title = element_text(colour = "black", hjust=0.5),
panel.border = element_rect(colour = "black", fill=NA, size=1)) +
geom_point(data=GLDIC, aes(x=LONGITUDE, y=LATITUDE, fill=alkalinity), shape=21) +
scale_fill_gradient2(low="#e34234", mid="yellow", high="sky blue", space="Lab", guide="legend", aesthetics = "fill", midpoint = 1677, limits = c(800, 2400), breaks = c(800, 1200, 1600, 2000, 2400)) +
labs(title="Surface Mixed Layer")

I receive the following error:

Error in ggmap():
! ggmap::ggmap() only plots objects of class ggmap
Run rlang::last_trace() to see where the error occurred.

It seems like I have to run the get_map() command, but I'm not sure how to reformat everything else.

I've attached the .csv file I used as my dataframe as "GLDIC". Any help would be appreciated. Sorry for all the questions!

Ben
GLDIC.csv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant