Code Monkey home page Code Monkey logo

somap's People

Contributors

maschette avatar mdsumner avatar raymondben avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

somap's Issues

Why not use coord_proj("+proj=laea")?

A rhetorical question, but should be interesting to explore different approaches.

How would you make this map?

image

The chlorophyll-a data:

u <- "https://oceandata.sci.gsfc.nasa.gov/cgi/getfile/A20022132017243.L3m_MC_CHL_chl_ocx_9km.nc"
download.file(u, basename(u), mode = "wb")

The chlorophyll-a palette (breaks and colours):

pal <- palr::chlPal(palette = TRUE)

The projection and extents:

  • outer boundary is -20 (20S)
  • central longitude is 180, central latitude -90
  • inner graticule is xx <- c(0, 90, 180, 270, 360); yy <- c(-60, -40)
"+proj=laea +lat_0=-90 +lon_0=180 +datum=WGS84 +ellps=WGS84 +no_defs +towgs84=0, 0, 0"

The fronts are from orsifronts::orsifronts:

subset(orsifronts::orsifronts, front %in% c("pf", "saf"))

to dos

  • extend to coastline if given, control what the extents is defined by
  • increase used of sf
  • ggplot converter for output object
  • allow custom prj input
  • input types (e.g. spatial points)
  • palettes

croptograt

Try

  • build graticule of tiles, or just one big grat
  • union them all together (rgeos::gUnionCascaded, or sf::st_union)
  • mask the raster with the grat (or find the cell numbers that overlap, and set the rest to NA)
  • intersect the coastline with the grat
  • add the border

SOcool

Prototype:

library(sospatial)  ## devtools::install_github("AustralianAntarcticDivision/sospatial")
library(SOmap)
SOcool <- function(xs, ys, icedate = "2017-09-01") {
  ice <-  tibble::tibble(lon = rep_len(seq(-180, 179), length.out = length(packed_lats)), 
                lat = packed_lats/10,
                day = as.Date(rep(ice_dates, each = 360)))
  icedate <- as.Date(icedate)
  f <- "%Y-%m-%d"
  if (icedate < min(ice$day) || icedate > max(ice$day)) {
    stop(sprintf("sorry, available range of icedate is %s : %s", format(min(icedate), f), format(max(icedate), f)))
  }
                                                                
                                                                
  ind <- which(icedate == ice$day)
  x <- default_somap(xs, ys)
  ice <- dplyr::slice(ice, ind)
  ice[c("x", "y")] <- rgdal::project(as.matrix(ice[c("lon", "lat")]), projection(x$bathy))
  ix <- which(ice$x >= xmin(x$bathy) & ice$x <= xmax(x$bathy) &
                ice$y >= ymin(x$bathy) & ice$y <= ymax(x$bathy))
  ice <- dplyr::slice(ice, ix)
  lines(ice[c("x", "y")], lty = 2)
  x$ice <- ice
  invisible(x)
}

SOcool(xs, ys)

image

I expect sospatial will get incorporated into this package, though first we need a way to keep the ice data up to date - it's about a year out atm.

Why not just coord_proj("+proj=laea")?

A rhetorical question, but might be interesting to explore. How would you make this map?

image

The chlorophyll-a data:

u <- "https://oceandata.sci.gsfc.nasa.gov/cgi/getfile/A20022132017243.L3m_MC_CHL_chl_ocx_9km.nc"
download.file(u, basename(u), mode = "wb")

The chlorophyll-a palette (breaks and colours):

pal <- palr::chlPal(palette = TRUE)

The projection and extents:

  • outer boundary is -20 (20S)
  • central longitude is 180, central latitude -90
  • inner graticule is xx <- c(0, 90, 180, 270, 360); yy <- c(-60, -40)
"+proj=laea +lat_0=-90 +lon_0=180 +datum=WGS84 +ellps=WGS84 +no_defs +towgs84=0, 0, 0"

The fronts are from orsifronts::orsifronts:

subset(orsifronts::orsifronts, front %in% c("pf", "saf"))

cast problem with albatross data

Why?

data("albatross", package = "adehabitatLT")
track <- rgdal::project(as.matrix(purrr::map_df(albatross, ~rbind(.x[c("x", "y")], NA))), "+proj=utm +zone=42 +south +datum=WGS84", inv = TRUE)
SOauto_map(track[,1], track[,2])
 Error in st_cast_sfc_default(x) : list item(s) not of class sfg 

why not just

Why not just coord_proj("+proj=laea")?

A rhetorical question, but should be interesting to explore different approaches.

How would you make this map?

image

The chlorophyll-a data:

u <- "https://oceandata.sci.gsfc.nasa.gov/cgi/getfile/A20022132017243.L3m_MC_CHL_chl_ocx_9km.nc"
download.file(u, basename(u), mode = "wb")

The chlorophyll-a palette (breaks and colours):

pal <- palr::chlPal(palette = TRUE)

The projection and extents:

  • outer boundary is -20 (20S)
  • central longitude is 180, central latitude -90
  • inner graticule is xx <- c(0, 90, 180, 270, 360); yy <- c(-60, -40)
"+proj=laea +lat_0=-90 +lon_0=180 +datum=WGS84 +ellps=WGS84 +no_defs +towgs84=0, 0, 0"

The fronts are from orsifronts::orsifronts:

subset(orsifronts::orsifronts, front %in% c("pf", "saf"))

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.