[PDF] [PDF] Spatial Data in R - Michael Dorman

Several packages need to be installed to run code examples - install packages(" rgdal") install packages("sf") install packages("raster") install packages("rgeos")



Previous PDF Next PDF





[PDF] Package rgeos

7 sept 2020 · stalling the package from source, must be correctly installed first Windows and Mac In- URL https://r-forge r-project org/projects/rgeos/



[PDF] Package rgeos

7 sept 2020 · stalling the package from source, must be correctly installed first Windows and Mac In- URL https://r-forge r-project org/projects/rgeos/



[PDF] Getting Started with Package sampSurf

stall packages You can install the package from within R with gests' both the rgl and rgeos packages, which must be installed separately The rgl package 



[PDF] Software installation instructions - ISRIC

For the training the following packages are used and should be installed prior to the training: ○ R packages: sp, rgdal, gstat, rgeos, GSIF, plotKML, caret, plyr, 



[PDF] Spatial Data in R - Michael Dorman

Several packages need to be installed to run code examples - install packages(" rgdal") install packages("sf") install packages("raster") install packages("rgeos")



[PDF] Package rgeos

29 mar 2013 · library is external to the package, and, when installing the package URL https:// r-forge r-project org/projects/rgeos/ http://trac osgeo org/geos/



[PDF] R Scripts related to Analyzing spatio-temporal data with R

with R: Everything you always wanted to know – but 4 ) Estimating a space- time covariance function 43 4 1) Data preparation install packages( rgeos)



[PDF] RGeostats Manual - Free

20 août 2017 · Getting Started manual for installation of RGeostats package RGeoS is based on a library of geostatistical code written in C (and C++)



[PDF] Progress in the R ecosystem for representing and handling spatial

9 oct 2019 · rgdal and rgeos (and terra rather than raster), but existing packages are free packages available to users who are not able to install R source

[PDF] how to install smartguard keypad

[PDF] how to install telugu font in windows 10

[PDF] how to install vmware horizon client on mac

[PDF] how to integrate

[PDF] how to introduce yourself in a scholarship essay

[PDF] how to invoke the 5th amendment

[PDF] how to join bricklayers union

[PDF] how to join the adobe solution partner program

[PDF] how to know if confederate money is real

[PDF] how to learn 3ds max

[PDF] how to learn from a math textbook

[PDF] how to learn socket programming in c

[PDF] how to learn tenses in english in easy way pdf

[PDF] how to list the apa manual on your reference page

[PDF] how to lock a pdf so it cannot be copied

Spatial Data in R: Overview and Examples

Earth Observation Workshop, Basel

Michael Dorman

Geography and Environmental Development

dorman@post.bgu.ac.il

2018-02-26 - 2018-03-01

Contents

I The aim of this tutorial is to provide anoverviewtospatial analysis in R I

Slides and codeavailable onGitHub

I

Dataavailable onDropb ox

Requirements

ISeveral packagesneed to be installedto run code examples -install.packages("rgdal") install.packages("sf") install.packages("raster") install.packages("rgeos") install.packages("geosphere") install.packages("rmapshaper") install.packages("gstat") install.packages("automap") install.packages("spdep") install.packages("spatstat") install.packages("osmdata") install.packages("mapview")

Requirements

I

Set toworking directorywith thed ata-

I cb_2015_us_state_5m-US states (Shapefile)

Ius-states.geojson-US states (GeoJSON)

Idem.tif-Digital Elevation Model (GeoTIFF)

Introduction

I Ris aprogramming languageandenvironment, originally developed forstatistical computingandgraphics I Over time, there was an increasing number ofcontributed packagesfor handling and analysing spatial data in R I Today, spatial analysis is amajor functionality in R I

As of November 2017, there are over180 packages

specifically addressing spatial analysis in R

Figure 1:Bo okson Spatial Data Analysis with R

History

I pre-2003: Variable and incomplete approaches (MASS, spatstat,maptools,geoR,splancs,gstat, ...) I

2003: Concensus that a package with base classes should be

useful;rgdalreleased on CRAN I

2005:spreleased on CRAN;spsupport inrgdal

I

2008:Applied Spatial Data Analysis with R, 1st ed.

I

2010:rasterreleased on CRAN

I

2011:rgeosreleased on CRAN

I

2013:Applied Spatial Data Analysis with R, 2nd ed.

I

2016:sfreleased on CRAN

HistoryFigure 2:The net works tructureof CRAN 1;specosystem shown in green1blog.revolutionanalytics.com/2015/07/the-network-structure-of-cran.html

R as a GIS?

I

Strengthsof R as a GIS

IR capabilities indata processingandvisualization, combined with dedicatedpackages for spatial data IAsingle environmentencompassing all analysis aspects - acquiring data, computation, statistics, visualization, Web, etc. I

Generaladvantages of programming

I Automation- Doing otherwise unfeasible repetitive tasks IReproducibility- Precise control of instructions to the computer I

Situations whenother toolsare needed

I Interactive editing or georeferencing(but seemapedit) IUniqueGIS algorithms(label placement, network routing, splitting lines at intersections, etc.) IData thatcannot fit in RAM(but R canconnect to spatial databases)

Notable packages

I

Handling spatial data

I sp,rgdal,rgeos,sf,raster I

Geometry

I geosphere,mapshaper I

Statistics

I gstat,automap,spatstat,spdep I

Data access

I osmdata I

Visualization

I ggplot2,ggmap,mapview,leaflet

Vector: Types of dataPOINTLINESTRINGPOLYGON

MULTIPOINTMULTILINESTRINGMULTIPOLYGONGEOMETRYCOLLECTIONFigure 3:V ectordata t ypes(Simple F eatures)

Vector: File formats

I

Binary

I

ESRI Shapefile(.shp,.shx,.dbf,.prj, ...)

I

Plain Text

I

GeoJSON(.jsonor.geojson)

IGPX(.gpx)

I

Spatial Databases

I

PostGIS / PostgreSQL

Vector: Data structures (sp)

I

Packagesphas6 main classesfor vector layers

I One for eachgeometry type(points, lines, polygons) IOne forgeometry onlyand one forgeometry with attributes

Table 1

Spatial data structure sin package spclass geometry attributes

SpatialPointsPoints -

SpatialPointsDataFramePointsdata.frame

SpatialLinesLines -

SpatialLinesDataFrameLinesdata.frame

SpatialPolygonsPolygons -

Vector: Data structures (sf)

I

Packagesfdefines ahierarchical class system

I

Classsfgis for asingle geometry

IClasssfcis aset of geometrieswith a CRS

IClasssfis alayer with attributes

Table 2

Spatial data structure sin package sfclass hierarchy data sfggeometry coords, type, dimension sfcgeometry column Set ofsfg+ CRS sflayersfc+ attributes

Raster: Types of data

Figure 4

Raster data t ypes

Raster: File formats

I "Simple" rasters I

GeoTiff(.tif)

IErdas Imagine Image(.img)

I "Complex" rasters (>3D and / or metadata) I

HDF(.hdf)

INetCDF(.nc)

Raster: Data structures

I

Therasterpackage defines3 classesfor raster data

I

RasterLayerforsingle-band

IRasterStackandRasterBrickformulti-band

Table 3

Spatial data structu resin package rasterclass layers storage

RasterLayer1 Disk or RAM

RasterStack>=1 Disk and/or RAM

RasterBrick>=1 Disk (single file) or RAM

Input and output of spatial data

I

Reading spatial layers from a file into an R data structure, orwriting the R data structure into a file, are handled by external

libraries - I OGRis used for reading/writing vector files, withrgdal/sp orsf IGDALis used for reading/writing raster files, withraster IPROJ4is used for handling CRS, in bothrgdal/sp,sfand raster IWorking with specialized formats, e.g.HDFwithgdalUtils orNetCDFwithncdf4

Coordinate Reference Systems (CRS)

I

ACoordinate Reference System (CRS)defines how the

coordinates in the data relate to the surface of the Earth I

Two types of CRS

I

Geographic- longitude and latitude, in degrees

IProjected- implying flat surface, associated with measurement units (e.g. meters) Coordinate Reference Systems (CRS)Figure 5:Geographic (W GS84; left) and p rojected(NAD83 / UTM zone

12N; right) CRS33https://geocompr.robinlovelace.net/spatial-class.html

Coordinate Reference Systems (CRS)

IIn R, CRS are defined using anESPG codeorPROJ.4 string I

Comparing Map Projections

I A table with EPSG code and PROJ.4 strings for all projections -crs =rgdal ::make_EPSG()

Coordinate Reference Systems (CRS)

I

For example, theWGS84 geographic projectioncan be

defined using itsEPSG code4326 I Or using itsPROJ.4 string"+proj=longlat +datum=WGS84 +no_defs" rgdal,sf,raster: Handling spatial data I FunctionreadOGRcan be used to read vector layers intosp data structures -library(rgdal) pol_sp =readOGR("data","cb_201 5_us_state_5m") ## OGR data source with driver: ESRI Shapefile ## Source: "data", layer: "cb_2015_us_state_5m" ## with 49 features ## It has 1 fields class(pol_sp) ## [1] "SpatialPolygonsDataFrame" ## attr(,"package") ## [1] "sp" rgdal,sf,raster: Handling spatial data I Functionst_readcan be used to read vector layers intosf data structures -library(sf) pol_sf =st_read("data/cb_2015_us_state_5m.shp")

## Reading layer?cb_2015_us_state_5m?from data source?/home/michael/Dropbox/Presentations/p_2018_02_EO_Workshop_Basel/data/cb_2015_us_state_5m.shp?using driver?ESRI Shapefile?

## Simple feature collection with 49 features and 1 field ## geometry type: MULTIPOLYGON ## dimension: XY ## bbox: xmin: -124.7332 ymin: 24.51496 xmax: -66.9499 ymax: 49.38436 ## epsg (SRID): 4326 ## proj4string: +proj=longlat +datum=WGS84 +no_defs class(pol_sf) ## [1] "sf" "data.frame" rgdal,sf,raster: Handling spatial data I Sincesfis new, the majority of the R-Spatial ecosystemonly works withsp I "Migration"document betweenspandsf I

Conversionsp→sfx =st_as_sf(pol_sp)

class(x) ## [1] "sf" "data.frame" I

Conversionsf→spx =as(pol_sf,"Spatial" )

class(x) ## [1] "SpatialPolygonsDataFrame" ## attr(,"package") ## [1] "sp" rgdal,sf,raster: Handling spatial data I

Functionsraster,stackandbrickcan be used to read

single-band rasters intorasterdata structures -library(raster) r =raster("data/dem.tif") r ## class : RasterLayer ## dimensions : 333, 286, 95238 (nrow, ncol, ncell) ## resolution : 90, 90 (x, y) ## extent : 673414, 699154, 3615239, 3645209 (xmin, xmax, ymin, ymax) ## coord. ref. : +proj=utm +zone=36 +ellps=WGS84 +units=m +no_defs ## data source : /home/michael/Dropbox/Presentations/p_2018_02_EO_Workshop_Basel/data/dem.tif ## names : dem ## values : -12, 537 (min, max) class(r) ## [1] "RasterLayer" ## attr(,"package") ## [1] "raster" rgdal,sf,raster: Handling spatial data I

CRS ofspvector layerproj4string(pol_sp)

## [1] "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"quotesdbs_dbs14.pdfusesText_20