Learn R GIS What is GIS GIS Geographic

  • Slides: 12
Download presentation
Learn R! GIS

Learn R! GIS

What is GIS? GIS = “Geographic Information System” Ideally Answer questions related to proximity

What is GIS? GIS = “Geographic Information System” Ideally Answer questions related to proximity In practice A method of job security A method of intimidation A method of making money Tools better understood than ideas behind them

Disclaimer: Why I don't use Arc. GIS QGIS is a free replacement with better

Disclaimer: Why I don't use Arc. GIS QGIS is a free replacement with better features Arc. GIS is a pain to install/set up licenses Faster than Arc. GIS to an order of 10 x Useless for Linux/Mac users Arc. GIS expense limits use: government/industry/universities ESRI spends $$$ promoting and “locking in” Arc. GIS users Point-and-click is nice for making maps, but “toolbox” style analysis is painful for

ESRI's Legacy: “Shapefile” Format Most common GIS data format (90's relic) Information stored across

ESRI's Legacy: “Shapefile” Format Most common GIS data format (90's relic) Information stored across many files . shp geometry feature information (i. e. counties) . shx index of features . dbf attributes of each geometry (i. e. population) Sometimes also . prj projection information . shp. xml metadata Imagine if Word docs were split into 5 files!

Geometry features (. shp) Actually just a list of coordinate sets Software connects each

Geometry features (. shp) Actually just a list of coordinate sets Software connects each set into a polygon (1, 3) X Y 0 0 0 2 1 3 2 2 (0, 2) (2, 2) (0, 0)

Geometry projection (. prj) The earth isn't flat, but maps are! Are my points

Geometry projection (. prj) The earth isn't flat, but maps are! Are my points GPS coordinates, or what? TWO Basic Types: Geographic (“GPS”) Latitude/longitude Pseudo-spherical Projected (“Survey”) Feet/meters Rectangular

Geometry attributes (. dbf) Really just a dataset Contains one row per polygon in

Geometry attributes (. dbf) Really just a dataset Contains one row per polygon in dataset ID Area Toxins Cases 0 12 1000 10 1 99 0 1 2 120 200 5 3 54 50 2

GIS Junk (but don't delete!) Shapefile index (. shx) Metadata (. shp. xml) Helps

GIS Junk (but don't delete!) Shapefile index (. shx) Metadata (. shp. xml) Helps Arc. GIS go faster (but still slower than QGIS) Data source, notes, etc. Other things in the (. shp) Presence of holes Bounding box Shape type (point, line, polygon)

The sp package in R Packs GIS data into an addressable object Spatial. Points.

The sp package in R Packs GIS data into an addressable object Spatial. Points. Data. Frame @ @ polygons proj 4 string data $ var 1 @ bbox $ var 2 plot. Order

Working with spatial data With rgeos and rgdal installed, common data commands will be

Working with spatial data With rgeos and rgdal installed, common data commands will be intuitively translated! plot(myshape) myshape$var 1 myshape[1: 2, ] myshape[myshape$var 1==FALSE, ] Sp objects work like any other object: mile 3 <- gbuffer(myshape, 3*5280) cents <- gcentroid(myshape)

Caveat: Don't use merge()! Sometimes need to link attribute/shape data US Census Data TIGER

Caveat: Don't use merge()! Sometimes need to link attribute/shape data US Census Data TIGER Line Files Don't use merge()! Looks good but doesn't work This re-orders the data, but NOT the shapes! Instead, re-order the new data & append to old Example in lab

Lab Import an ESRI shapefile (w/built-in data) Basic maps with plot() Link attribute data

Lab Import an ESRI shapefile (w/built-in data) Basic maps with plot() Link attribute data to spatial data Write to. kml so you can show your maps on Google Earth (good for interactivity). Examples of working with Google Earth/QGIS