Spatial Data & GIS Operations in R
Spatial Data
- geometry: shape and location
- attributes: data about the feature
- two forms in GIS: raster (pixel, continous) and vector (points, lines and polygons)
- format of geo data: shp, geojson, KML/KMZ (Google Earth)…
shp
- includes shp (storaging geometry), shx, dbf (tabel)
sf package
- drop geo column if it is troublesome
- st_intersects(): Counties affected by flooding
- st_touches(): Neighboring counties
- st_within(): Schools within district boundaries
- st_contains(): Districts containing hospitals
- st_overlaps(): Overlapping service areas
- st_disjoint(): Counties separate from urban areas
Coordinate Reference Systems
- The Earth is round, but maps are flat
- Problems: hard to preserve area, distance, and angles simultaneously
- Calculation steps
- step 1: approximate the earth Ellipsoid
- step 2: tie the Ellipsoid into the real Earth
- step 3: put down the lat/lng grid
- Geographic (Geodetic) coordinate systems (Lat/lng)
- Mercator: keeps lines(lat) constantly long, areas far from the central line are in wrong shape
- Transverse: using Lng
- Conic
- cylindrical
- planer
- Projected coordinate systems
- GCS:
- Lat/Lng coordinated
- good for large scale, bad for area/distance calculations
- PCS:
- X/Y coordinates on a flat plane
- units: meters, feet
- good for local analysis, accurate measurement, bad for large areas, global data sets
- st_set_crs() is to set CRS if missing, st_transform() is to change CRS