This file contains hidden or 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
## use the magick package to read a GIF file: | |
library(magick) | |
## use AmigaFFH to convert into Amiga IFF file, | |
## make sure to use version 0.2.0 or newer: | |
library(AmigaFFH) | |
## Read the GIF animation we created in an earlier post: | |
earth <- image_read("http://3.bp.blogspot.com/-CCurVbm1ChI/VdC2NrqeeaI/AAAAAAAAx_8/lyO9mFyVhU8/s1600/globe.gif") |
This file contains hidden or 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
## Library to handle Amiga files | |
library(AmigaFFH) | |
## Library to handle png-images | |
library(png) | |
## Download an image of the Amiga boing ball: | |
con <- url("http://www.f1-software.com/images/icons/amiga-boing-ball.png", "rb") | |
logo <- readBin(con, "raw", 100000L) | |
close(con) | |
logo <- as.raster(readPNG(logo)) |
This file contains hidden or 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 part of the code runs on a Shiny server and interacts with the | |
# user interface shown at the client's side. | |
# For details and tutorials go to http://shiny.rstudio.com | |
server <- shinyServer(function(input, output, server) { | |
# Make these character strings 'reactive'. That way | |
# the output text is automatically update when these | |
# values are changed. | |
values <- reactiveValues(state = c("Interface1: Waiting for clicks", | |
"Interface2: Waiting for clicks")) |
This file contains hidden or 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 part of the code generates the user interface show at the client's side. | |
# For details and tutorials go to http://shiny.rstudio.com | |
ui <- shinyUI(fluidPage( | |
# This adds a tiny bit of javascript to the client side's web page. | |
# It defines a global variable 'negator', which is negated when | |
# the javascript function negate() is called. | |
# This can be used to trick Shiny's event observers. | |
tags$head(tags$script("var negator=1; | |
function negate() { |
This file contains hidden or 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
## Required libraries for this example | |
library(png) | |
library(sp) | |
library(maptools) | |
library(raster) | |
## A function as a wrapper around 4 of the 5 steps | |
## described in the main text of the blog.... | |
## As input it requires a SpatialPolygons object | |
## and the URL to the png image that will be used |
This file contains hidden or 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
## package for handling spatial data: | |
library(sp) | |
## package that contains simple world map data | |
library(maptools) | |
## package for modifying spatial data: | |
library(rgeos) | |
## package used for setting up clipping areas | |
library(raster) | |
## function that segments the polygons of SpatialPolygons(DataFrame) object |
This file contains hidden or 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
require(pscl) | |
# the vuong test returns NULL. Lines below will modify the function to return the output table: | |
# Turn the vuong-function into text: | |
vuong2 <- deparse(vuong) | |
# remove the current return statement: | |
vuong2 <- vuong2[!grepl("return", vuong2)] | |
# instead of printing the output, return it!: | |
vuong2 <- gsub("print(out)", "return(out)", vuong2, fixed = T) | |
# now change the text back into an actual function that can be called: |
This file contains hidden or 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 package is used to retrieve data from openstreetmap.org: | |
require(osmar) | |
## This pacakge is used to process the spatial data: | |
require(rgeos) | |
## This package is used to convert the data from openstreetmap into something workable: | |
require(maptools) | |
## function to retrieve a relation from openstreetmap and convert it | |
## into a SpatialPolygons object: | |
OSM_relation_to_SP <- function(rel) { |
This file contains hidden or 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
require(raster) | |
require(KernSmooth) | |
require(maptools) | |
## load the simulation results. See the previous blog post | |
## how this file was created. This data file contains | |
## an object named 'part.results', which is a list | |
## of SpatialPointsDataFrame objects. | |
load("output/out.RData") |
This file contains hidden or 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
## load required packages: | |
require(sp) | |
require(raster) | |
require(ncdf4) | |
require(ncdf.tools) | |
require(rgeos) | |
require(maptools) | |
############################################################### | |
## STEP 1: load the water currents and wind data |
NewerOlder