Skip to content

Instantly share code, notes, and snippets.

View rmarrotte's full-sized avatar

Robby rmarrotte

View GitHub Profile
@rmarrotte
rmarrotte / 0_reuse_code.js
Last active August 29, 2015 14:21
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
# Clear workspace
rm(list=ls())
# load libraries
library(rgeos)
library(maptools)
# Set seed
set.seed(1234)
@rmarrotte
rmarrotte / CompareEffectiveDistances.R
Last active April 18, 2016 20:02
Circuitscape is a tool that is used to measure effective resistance between pairs of nodes. A more recent package in R called "gdistance" can also perform a similar measurement and offers other function to measure effective distance such as cost distance. In this script I compare all 3 and include euclidean distance.
# Compare CS, costDist and commuteDist
# Clear workspace
rm(list=ls())
# Load libraries
library(gdistance)
library(scales)
library(gstat)
######################
## Web scraping ##
######################
# Clear workspace
rm(list=ls())
# Load libraries
require(RCurl)
require(XML)
# Clear workspace
rm(list=ls())
# Load libraries
require(rasterVis)
require(dismo)
require(GISTools)
require(spdep)
require(RColorBrewer)
####################################
# Run zonal statistics in parallel #
####################################
# Clear workspace
rm(list=ls())
# Libraries
library(raster)
library(gstat)
@rmarrotte
rmarrotte / Circuitscape in R (Windows).R
Last active December 20, 2018 14:25
Simple script that shows how to run Circuitscape through R under Windows. It runs an examples found in the Circuitscape examples folder
########################################
#### Getting started ####
########################################
# Make a place holder for the cs_run.exe path
CS_exe <- 'C:/"Program Files"/Circuitscape/cs_run.exe' # Don't forget the "Program Files" problem
# We want to run one of the CS examples found in /examples/, first we need to fix the .ini file
# We first read in the .ini file and then we change the arguments
Example_lines <- readLines("C:/Program Files/Circuitscape/examples/eight_neighbor_example.ini")
@rmarrotte
rmarrotte / Circuitscape example.R
Last active November 17, 2024 16:04
Simple script that shows how to run Circuitscape through R under Windows. It runs data created directly in R.
######################################
#### Example Run ####
######################################
# Clear workspace
rm(list=ls())
# load raster library
library(raster)
# Make a place holder for the cs_run.exe path