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(rgeos) | |
library(maptools) | |
library(gpclib) | |
if (!rgeosStatus()) gpclibPermit() | |
gpclibPermit() | |
# Read in the data | |
fi.kunnat <- readShapePoly("fi_kunnat.shp") |
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(sorvi) | |
library(rgeos) | |
library(rgdal) | |
library(maptools) | |
library(gpclib) | |
if (!gpclibPermit()) { gpclibPermit() } | |
################################## | |
# Lue uusi kuntajako |
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
#!/bin/bash | |
# | |
# Install Postgres 9.1, PostGIS and create PostGIS template on a clean Ubuntu 11.10 Oneiric Ocelot box | |
# http://wildfish.com | |
# add the ubuntu gis ppa | |
sudo apt-get -y install python-software-properties | |
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable | |
sudo apt-get update |
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(sorvi) | |
library(rgdal) | |
library(plotGoogleMaps) | |
data(MML) | |
shp <- MML[["1_milj_Shape_etrs_shape"]][["kunta1_p"]] | |
proj4string(shp)<-("+init=epsg:3047") | |
shp2 <- spTransform(shp, CRS("+proj=longlat +datum=WGS84")) |
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(ggplot2) | |
library(reshape2) | |
library(scales) | |
Scholar <- read.csv("scholarly_impact_2012.4.9.csv") | |
Little6 <- c("JMP","Minitab","Stata","Statistica","Systat","R") | |
Subset <- Scholar[ , Little6] | |
Year <- rep(Scholar$Year, length(Subset)) | |
ScholarLong <- melt(Subset) |
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("RPostgreSQL") | |
# For examples, see https://code.google.com/p/rpostgresql/ | |
connect.rli <- function(config.file="config.R") { | |
source(config.file) | |
drv <- dbDriver("PostgreSQL") | |
con <- dbConnect(drv, dbname=DBNAME, user=USER, password=PASSWORD, |
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
# jaccard.R | |
# Written in 2012 by Joona Lehtomäki <[email protected]> | |
# To the extent possible under law, the author(s) have dedicated all | |
# copyright and related and neighboring rights to this software to | |
# the public domain worldwide. This software is distributed without any warranty. | |
# You should have received a copy of the CC0 Public Domain Dedication along with | |
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. |
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(raster) | |
library(dismo) | |
# Sample both raster with the same points | |
sample.points <- randomPoints(raster1, 500000) | |
# Extract raster values at sample point locations | |
sample.raster1 <- extract(raster1, sample.points,method='simple', na.rm=TRUE) | |
sample.raster2 <- extract(raste2, sample.points,method='simple', na.rm=TRUE) |
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
# Based on: | |
# http://stackoverflow.com/questions/4401498/how-to-rank-values-in-a-vector-and-give-them-corresponding-values | |
# http://stackoverflow.com/questions/5468280/scale-a-series-between-two-points-in-r/5468527#5468527 | |
values <- runif(1000000) | |
# replace runif with getValues(raster) | |
ranks <- as.numeric(factor(values)) | |
# Transform variables to a scale between 0 and 1, while retaining rank order and |
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(raster) | |
# HUOM! Kaikissa hakemistopoluissa pitää Windows-kenoviiva korvata normikenoviivalla | |
# esim. C:\Kansio\tiedosto.txt -> C:/Kansio/tiedosto.txt | |
workspace <- "[KANSIO-JOSSA-LAHTORASTERIT]" | |
# Oletus: rasterit ovat yllä mainitussa kansiossa | |
org.raster.file <- "[ALKUPERAISEN-RASTERIN-NIMI]" | |
agg.raster.file <- "[AGGREGOIDUN-RASTERIN-NIMI]" |