GithubHelp home page GithubHelp logo

2017-02-03-graphics-imas's Introduction

Graphics and maps in R

R set up

Wondering what this Git thing is? https://www.rstudio.com/resources/videos/happy-git-and-gihub-for-the-user-tutorial/

Getting Help

Local

Worldwide

The Good Stuff

Extra stuff

General resources

GIS with R

Introduction to visualising spatial data in R by Robin Lovelace and James Cheshire

Create Maps with R Graphics

Intro to Spatial Analysis in R

Books

interactive session

http://pad.software-carpentry.org/DaSH-R

http://rpubs.com/cyclemumner/aad-mapping-tips

  • group session about problems, identify some examples to explore

Questions

These are all open questions! We can use this to collect resources, all work in progress.

  • How to get data on oceanographic features and make nice maps?

#3

  • How to add ice edge to maps?

#1

Illustrations

Exactly what we do will depend on the group session.

Broad topics to touch on

Reading in data

Shapefiles

raster::shapefile("myfile.shp")

Rasters, grids, images.

raster::raster("myraster.tif")

raster::brick("myRGB.tif")

raster::brick("myMegaSplat.nc", varname = "Mega")

raster::stack(c("mydata1.nc", "mydata2.nc", "mydata3.nc"))

Packages with data.

maptools, rworldmap, maps, orsifronts,

Here I list packages we should also look at so we know what they have.

colours

https://github.com/Bart6114/artyfarty

viridis

RColorBrewer

colorspace

mapping

leaflet

mapview

raster and rgdal

sf

graphics paradigms

ggplot2

base, lattice, grid

ggvis and leaflet and plotly

2017-02-03-graphics-imas's People

Contributors

mdsumner avatar j-cleeland avatar

Stargazers

Felipe Sodré M. Barros avatar Tommy Lees avatar  avatar  avatar

Watchers

James Cloos avatar  avatar  avatar Tomas Remenyi avatar  avatar Tommy Lees avatar

2017-02-03-graphics-imas's Issues

Aggregating isobaths

Hey @mdsumner,

Wondering how you work out the intervals between isobaths when aggregating etopo?

Here's how I've been making them (for anyone interested):

rasterToContour(aggregate(topo1, fact=16, fun=mean))

Can't open etopo from Gough- so needing to guess/work out what a fact=16 equates to...200m?

Cheers,

J.

Add ice edge to maps

Hi Mike,

It would be great if you could cover how to add the mean ice extent in the Antarctic for September (a line) to my maps.
cheers,

Nat

Boxplots

Hey Mike,

I was wondering if there is anyway to make the attached boxplot more visually appealing?
The data file is to big to load.

The code I use:
library(ggplot2)
library(plotrix)
library(gridExtra)
library(ggthemes)

p1 <- ggplot(surv, aes(x=age, y=values))
p1+facet_grid(species~sex, scales="free_y")

p <- ggplot(surv, aes(factor(age, levels=c("Pup", "Juvenile", "Adult")), values))+
theme_bw() + theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
strip.background = element_rect(colour="black", fill="white"),
strip.background = element_blank())#### Removes everything

p + geom_boxplot() +facet_grid(sex~species, scales="free_y") +
ylab("Survival probability") + xlab('Age class')

boxplot no colour

notes from session

Pulled from the etherpad

R Graphics and Mapping

samples on a map, bathymetry

map projections sp::spTransform raster::projectRaster
avoid reprojecting rasters and remodelling data, use extract

overlaying satellite data raster::extract(grid, polygon/points)
pkg:Raster

  • super versatile, can handle many different formats

labels
use ggplot2 for better labelling
tip: use base map with labels already included
otherwise rely on manually entering spatial points and custom labels
SCAR gazetteer for placenames in R package:
https://github.com/AustralianAntarcticDataCentre/antanym

custom polygons

  • use qgis

legends

  • ggplot good for legends (sometimes incompatible)

What do you need?

  • http://proj4.org/ proj4 has documentation on projection formation that can be used to transform data
  • Help overlaying spatial data on maps eg. satellite data. +1
  • automatic? Cartographic labels of ocean features eg. Bounty Trough, Tasman Rise etc.
    creating custom polygons
    editting shapfiles ?polylines?
    *shape files in maps
    *visually appealing plots
    *regional SO map, plot sample data over oceanographic/bathymetry data
    *pretty figures also...how to make plots with lots of data points clear
    *Create a legend
    *Fix scales-make them meaningful
  • Make colour bars with labels
  • viridis colour palette; good contrast and colour blind friendly colours
    *Add background colour and pictures to plots
    *raster layers- the basics

  • CCAMLR gis package available with relevant polygons/data layers for Southern Ocean biology; predominantly CCAMLR management areas

Piping:
Avoids nesting within functions...and indecipherable code.
Reorganises code

PLaces to find help/tutorials:
Data Carpentry
DataScienceHobart Github site > ISSUES
Software Carpentry Creating Publication-Quality Graphics
Rpubs http://rpubs.com/cyclemumner/aad-mapping-tips
Rpubs https://rpubs.com/bhaskarvk/leaflet-polarmaps

how to snapshot zoomed in leaflet

Tried this code, how to save as image zoomed into Macquarie Island?

library(orsifronts)  ## install. packages("orsifronts")
library(leaflet)        ## install.packages("leaflet")

## orsifronts is a SpatialPolygonsDataFrame (could be read via shapefile, or contoured from other data)
data(orsifronts)
fronts_as_points <- as(orsifronts, "SpatialPointsDataFrame")
fronts_as_points <- fronts_as_points[sample(nrow(fronts_as_points), 20), ]

leaflet() %>% leaflet::setMaxBounds(130, -60, 160,  -40) %>% 
  addProviderTiles(providers$Esri.NatGeoWorldMap) %>% 
  addPolylines(data = rmapshaper::ms_simplify(orsifronts), 
               color = ~colorFactor(viridis::viridis(nrow(orsifronts)), front)(front)) %>% 
  addMarkers(data = fronts_as_points, label = ~front,  labelOptions = labelOptions(noHide = TRUE))

lessons from the Aleutians

  • in/out extent specification
  • graticule across dateline problem
  • juggling projection metadata objects
  • misunderstandings of source/target, graticule as long/lat, vs. projected
  • role of asp/ ratio
  • what does the projected end point look like versus 170, 180, -180, -170 etc. (i.e. implicit wrap confusion)
  • role of spTransform as a high level on project(xy, inv = TRUE/FALSE)
  • the seam in continent at -180/180 (removed with ms_simplify/gUnionCascaded
  • North arrows are of limited utility
    -relationship between plot(extent, asp = 1) and par(mar, xpd)

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.