Giter Club home page Giter Club logo

plot_map's Introduction

plot a surface map for ocean data

Description

This function uses ggplot to make a surface map to visualize ocean science data. It is not suitable for terrestrial data because the land map is plotted above the data points. Land map data is contained in the package mapdata. Ocean bathymetry is optionally plotted and data is retrieved from NOAA with a call to marmap::getNOAA.bathy(); alternatively, bathymetry data can be supplied as an existing object of class bathy.

Arguments

bathymetry = FALSE – can be logical (i.e. should a bathymetry be plotted) or the name of an object of class bathy

keep = FALSE – keep downloaded bathymetry in the current wd? only relevant with bathymetry=TRUE

lon.min, lon.max, lat.min, lat.max – map limits, if not supplied the range of lats and lons will be slightly extended

lats, lons – latitude and longitude of data

values – optional, data values

value.name – optional, name for the data legend

Example

normal plot

p1 <- plot_map(
    bathymetry = TRUE,
    keep = FALSE,
    lon.min = 112,
    lon.max = 118,
    lat.min = 16,
    lat.max = 24,
    lats = seq(22, 17, length.out = 10),
    lons = seq(114, 116, length.out = 10),
    values = rnorm(10),
    value.name = "example [unit]"
)
## Registered S3 methods overwritten by 'adehabitatMA':
##   method                       from
##   print.SpatialPixelsDataFrame sp  
##   print.SpatialPixels          sp

## Querying NOAA database ...

## This may take seconds to minutes, depending on grid size

## Building bathy matrix ...
p1

because the result is a ggplot, it can be extended with additional layers, and the theme can be changed

p1 +
    annotate("text", x = 115, y = 22, label = "some\ntext", size = 4, fontface = "bold") +
    geom_point(aes(x = c(116, 116.5, 117), y = c(22, 22, 22)), col = "red", size = 4) +
    theme_dark()

plot with bathy object supplied

plot_map(
    bathymetry = marmap::getNOAA.bathy(lon1 = 114, lon2 = 116, lat1 = 18, lat2 = 20, resolution = 1),
    keep = FALSE,
    lon.min = 112,
    lon.max = 118,
    lat.min = 16,
    lat.max = 24,
    lats = seq(22, 17, length.out = 10),
    lons = seq(114, 116, length.out = 10),
    values = rnorm(10),
    value.name = "example [unit]")
## Querying NOAA database ...

## This may take seconds to minutes, depending on grid size

## Building bathy matrix ...

bounding box not fully supplied

plot_map(
    lon.min = -59, 
    lat.max = -33,
    lats = seq(-35.5, -37.5, length.out = 10),
    lons = seq(-56.5, -52, length.out = 10),
    values = rnorm(10),
    value.name = "example [unit]"
)

plot with categorical values

plot_map(
    lon.min = -59, 
    lat.max = -33,
    lats = seq(-35.5, -37.5, length.out = 10),
    lons = seq(-56.5, -52, length.out = 10),
    values = c(rep("cat1", 3), rep("cat2", 7)),
    value.name = "category")

the function can also be used to make an empty

p1 <- plot_map(lon.min = -5, lon.max = 15, lat.min = 50, lat.max = 60)
p1

… which can then be filled with data

p1 + geom_point(aes(seq(2, 9, length.out = 10), seq(52, 58, length.out = 10), col = rnorm(10)))

plot_map's People

Contributors

davidatlarge avatar

Stargazers

 avatar

Watchers

 avatar

plot_map's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.