forked from Maschette/SOmap
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
96f9c8b
commit 83df0f4
Showing
2 changed files
with
43 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,40 @@ | ||
SOgg_auto <- function(x) { | ||
if (!inherits(x, "SOmap_auto")) stop("x must be an SOmap_auto object as generated by SOmap_auto") | ||
myext <- extent(x$target) | ||
## plot bathymetry | ||
bdf <- raster::as.data.frame(x$bathy, xy = TRUE) | ||
names(bdf) <- c("Longitude","Latitude","Depth") | ||
p <- ggplot(data = bdf, aes_string(x = "Longitude", y = "Latitude")) + geom_raster(aes_string(fill = "Depth")) | ||
p <- p + coord_sf(default = TRUE) ## default = TRUE makes this the default coordinate system for geom_sf objects | ||
p <- p + scale_fill_gradientn(colours = x$bathy_palette, na.value = "#FFFFFF00") #need to duplicate for guide=FALSE | ||
if (!inherits(x, "SOmap_auto")) stop("x must be an SOmap_auto object as generated by SOmap_auto") | ||
myext <- extent(x$target) | ||
## plot bathymetry | ||
bdf <- raster::as.data.frame(x$bathy, xy = TRUE) | ||
names(bdf) <- c("Longitude","Latitude","Depth") | ||
p <- ggplot(data = bdf, aes_string(x = "Longitude", y = "Latitude")) + geom_raster(aes_string(fill = "Depth")) | ||
p <- p + coord_sf(default = TRUE) ## default = TRUE makes this the default coordinate system for geom_sf objects | ||
p <- p + scale_fill_gradientn(colours = x$bathy_palette, na.value = "#FFFFFF00") #need to duplicate for guide=FALSE | ||
|
||
if (!is.null(x$coastline)) { | ||
this <- suppressWarnings(sf::st_as_sf(x$coastline$data)) | ||
p <- p + geom_sf(data = this, fill = x$coastline$fillcol, col = x$coastline$linecol, inherit.aes = FALSE) | ||
} | ||
if (!is.null(x$coastline)) { | ||
this <- suppressWarnings(sf::st_as_sf(x$coastline$data)) | ||
p <- p + geom_sf(data = this, fill = x$coastline$fillcol, col = x$coastline$linecol, inherit.aes = FALSE) | ||
} | ||
if (!is.null(x$ice)) { | ||
this <- suppressWarnings(sf::st_as_sf(x$ice$data)) | ||
p <- p + geom_sf(data = this, fill = x$ice$fillcol, col = x$ice$linecol, inherit.aes = FALSE) | ||
} | ||
|
||
if (x$contours) { | ||
this <- suppressWarnings(sf::st_as_sf(x$coastline$data)) | ||
p <- p + geom_sf(data = this, fill = x$coastline$fillcol, col = x$coastline$linecol, inherit.aes = FALSE) | ||
} | ||
if (x$contours) { | ||
this <- suppressWarnings(sf::st_as_sf(x$coastline$data)) | ||
p <- p + geom_sf(data = this, fill = x$coastline$fillcol, col = x$coastline$linecol, inherit.aes = FALSE) | ||
} | ||
|
||
if (!is.null(x$graticule)) { | ||
p <- p + geom_sf(data = x$graticule, col = "grey", inherit.aes = FALSE)} | ||
if (!is.null(x$graticule)) { | ||
p <- p + geom_sf(data = x$graticule, col = "grey", inherit.aes = FALSE)} | ||
|
||
if(!is.null(x$lines_data)){ | ||
p <- p + geom_line(data= as.data.frame(x$lines_data), aes_string(x="x", y="y"), col=x$lcol, linetype=x$llty, size=x$llwd ) | ||
} | ||
if(!is.null(x$lines_data)){ | ||
p <- p + geom_line(data = setNames(as.data.frame(x$lines_data), c("x", "y")), aes_string(x = "x", y = "y"), col = x$lcol, linetype = x$llty, size = x$llwd) | ||
} | ||
|
||
if(!is.null(x$points_data)){ | ||
p <- p + geom_point(data= as.data.frame(x$points_data), aes_string(x="x", y="y"), col=x$pcol, shape=x$ppch, size=x$pcex ) | ||
} | ||
if(!is.null(x$points_data)){ | ||
p <- p + geom_point(data = setNames(as.data.frame(x$points_data), c("x", "y")), aes_string(x = "x", y = "y"), col = x$pcol, shape = x$ppch, size = x$pcex) | ||
} | ||
|
||
p <- p + theme(axis.title = element_blank(), | ||
panel.border = element_rect(color = "black", fill=NA), | ||
panel.background = element_blank(), | ||
axis.text.x = element_text(angle = 90, vjust=0.5))+ | ||
scale_x_continuous(expand = c(0,0))+ | ||
scale_y_continuous(expand = c(0,0)) | ||
} | ||
p <- p + theme(axis.title = element_blank(), panel.border = element_rect(color = "black", fill = NA), | ||
panel.background = element_blank(), axis.text.x = element_text(angle = 90, vjust = 0.5)) + | ||
scale_x_continuous(expand = c(0, 0)) + scale_y_continuous(expand = c(0, 0)) | ||
} | ||
|