-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
2,386 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
.Rproj.user | ||
.Rhistory | ||
.RData | ||
ESP2_msk_alt.grd | ||
ESP2_msk_alt.gri | ||
ESP2_msk_alt.vrt | ||
ESP_msk_alt.grd | ||
ESP_msk_alt.gri | ||
ESP_msk_alt.vrt | ||
occs.dbf | ||
occs.prj | ||
occs.shp | ||
occs.shx | ||
wc10 | ||
GISwithR-figure |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,234 @@ | ||
GIS with R: slides for the unconverted | ||
======================================================== | ||
author: Francisco Rodriguez-Sanchez | ||
date: @frod_san | ||
2015-11-14 | ||
|
||
|
||
R: not only for stats | ||
===================== | ||
|
||
![](images/R.jpg) | ||
|
||
|
||
R can make beautiful maps | ||
========================= | ||
type: section | ||
|
||
|
||
|
||
Made in R | ||
========== | ||
|
||
![](images/bike_ggplot.png) | ||
|
||
<small>http://spatial.ly/2012/02/great-maps-ggplot2/</small> | ||
|
||
|
||
Made in R | ||
========= | ||
|
||
![](images/facebook_map.png) | ||
|
||
<small>http://paulbutler.org/archives/visualizing-facebook-friends/</small> | ||
|
||
|
||
Made in R | ||
========= | ||
|
||
![](images/airMadrid_stamen.png) | ||
|
||
<small>http://oscarperpinan.github.io/spacetime-vis/</small> | ||
|
||
|
||
Made in R | ||
========= | ||
|
||
![](images/cft.png) | ||
|
||
<small>http://oscarperpinan.github.io/spacetime-vis/</small> | ||
|
||
|
||
Made in R | ||
========= | ||
|
||
![](images/vLine.svg) | ||
|
||
<small>http://oscarperpinan.github.io/spacetime-vis/</small> | ||
|
||
|
||
And it's very easy! | ||
=================== | ||
type: section | ||
|
||
|
||
Map species occurrences in 2 lines of code | ||
========================================== | ||
|
||
```{r echo=FALSE} | ||
library(knitr) | ||
library(dismo) | ||
data(acaule) | ||
acaule <- acaule[acaule$continent == "South America", ] | ||
acaule <- acaule[!is.na(acaule$lat) | !is.na(acaule$lon), ] | ||
acaule <- subset(acaule, select = c("species", "lon", "lat")) | ||
crs.geo <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84") | ||
occs <- acaule | ||
acaule.sp <- acaule | ||
coordinates(acaule.sp) <- c("lon", "lat") | ||
crs(acaule.sp) <- crs.geo | ||
occdata <- Mercator(acaule.sp) | ||
``` | ||
|
||
```{r fig.keep = "last"} | ||
plot(gmap(occdata, type = "satellite")) | ||
points(occdata, col = "red", pch=20, cex = 2) | ||
``` | ||
|
||
|
||
|
||
Let's go step by step | ||
===================== | ||
type: section | ||
|
||
|
||
A dataframe of species occurrences | ||
================================== | ||
|
||
```{r echo=FALSE} | ||
kable(head(occs)) | ||
``` | ||
|
||
|
||
Make it a spatial object | ||
======================== | ||
|
||
```{r} | ||
coordinates(occs) <- c("lon", "lat") | ||
str(occs, 2) | ||
``` | ||
|
||
|
||
Specify projection (CRS) | ||
======================== | ||
|
||
```{r} | ||
crs(occs) <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84") | ||
``` | ||
|
||
See http://spatialreference.org | ||
|
||
|
||
Project to Mercator and plot | ||
============================ | ||
|
||
```{r fig.keep = "last"} | ||
plot(gmap(occs, type = "satellite")) | ||
points(Mercator(occs), col = "red", pch = 20, cex = 2) | ||
``` | ||
|
||
|
||
Alternatively, load shapefile | ||
============================= | ||
|
||
```{r echo = FALSE} | ||
shapefile(occs, filename = "occs.shp", overwrite = TRUE) | ||
``` | ||
|
||
```{r fig.keep = "last"} | ||
occs <- shapefile("occs.shp") | ||
plot(gmap(occs, type = "satellite")) | ||
points(Mercator(occs), col = "red", pch = 20, cex = 2) | ||
``` | ||
|
||
|
||
Using ggmap | ||
=========== | ||
|
||
```{r eval=TRUE} | ||
library(ggmap) | ||
map <- get_map(bbox(occs), maptype = "watercolor", source = "stamen") | ||
ggmap(map) + | ||
geom_point(aes(x = coords.x1, y = coords.x2), data = as.data.frame(coordinates(occs)), | ||
colour = "red", size = 4) | ||
``` | ||
|
||
|
||
Raster data | ||
=========== | ||
type: section | ||
|
||
|
||
Download elevation data | ||
========================== | ||
|
||
```{r} | ||
elevation <- getData("alt", country = "ESP") | ||
``` | ||
|
||
```{r} | ||
library(rasterVis) | ||
levelplot(elevation) | ||
``` | ||
|
||
|
||
|
||
Dynamic interactive maps with leaflet | ||
===================================== | ||
|
||
```{r} | ||
library(mapview) | ||
mapView(occs) | ||
``` | ||
|
||
|
||
|
||
Remote sensing growing fast | ||
=========================== | ||
|
||
e.g. RStoolbox | ||
|
||
![](images/rstoolbox.png) | ||
|
||
|
||
Doing GIS in R: main advantages | ||
=============================== | ||
incremental: true | ||
|
||
- Fully-reproducible scripts | ||
|
||
- **Harness all R stats power** | ||
|
||
- Data wrangling | ||
|
||
- Modelling | ||
|
||
- Dataviz | ||
|
||
- Easy! | ||
|
||
|
||
|
||
|
||
Calling GIS from R | ||
================== | ||
|
||
- Grass: [`spgrass6`](http://www.rdocumentation.org/packages/spgrass6) | ||
- SAGA: [`RSAGA`](http://www.rdocumentation.org/packages/RSAGA) | ||
- ArcGIS: https://github.com/R-ArcGIS | ||
![](images/R_ArcGis.png) | ||
|
||
Includes calling R from ArcGIS too | ||
|
||
|
||
|
||
|
||
To read more | ||
============ | ||
|
||
http://pakillo.github.io/R-GIS-tutorial | ||
|
||
|
||
|
||
|
||
|
Oops, something went wrong.