Skip to content

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

@bjkramerumnedu

Description

@bjkramerumnedu

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions