December 2019

Geographical Data in R

Quick Overview

  • Before modelling it is useful to
    • See some geographical data models
    • Understand about map projections
    • Be familiar with R’s sf (simplefeatures) package
    • See some basic geographical operations
    • Create some maps

So what does geographical data look like?


  • Point data
    • Like a standard data table but each observation is a point in 2D space
    • eg Rain gauge stations
Simple feature collection with 25 features and 3 fields
geometry type:  POINT
dimension:      XY
bbox:           xmin: -10.23 ymin: 51.79 xmax: -5.99 ymax: 55.36
epsg (SRID):    4326
proj4string:    +proj=longlat +datum=WGS84 +no_defs
# A tibble: 25 x 4
  Station      Elev      geometry  Rain
  <chr>       <dbl>   <POINT [°]> <dbl>
1 Athboy         87  (-6.93 53.6)  81.0
2 Foulksmills    71  (-6.77 52.3) 103. 
3 Mullingar     112 (-7.37 53.47)  76.7
4 Portlaw         8 (-7.31 52.28) 110. 
5 Rathdrum      131 (-6.22 52.91) 130. 
6 Strokestown    49  (-8.1 53.75)  97.0
# … with 19 more rows

Also, line data


  • Here the geometry column is a list of points
    • Represents paths, or geographical networks
    • eg roads, railways, rivers, footpaths etc.
Simple feature collection with 479 features and 1 field
geometry type:  LINESTRING
dimension:      XY
bbox:           xmin: -9.87 ymin: 51.85 xmax: -6.04 ymax: 54.27
epsg (SRID):    4326
proj4string:    +proj=longlat +datum=WGS84 +no_defs
First 6 features:
        LEN                       geometry
1 27.832735 LINESTRING (-7.510596 53.46...
2  3.601239 LINESTRING (-8.747836 53.25...
3 11.241874 LINESTRING (-7.996752 51.93...
4 13.993221 LINESTRING (-8.752088 52.57...
5 10.890816 LINESTRING (-8.29744 52.548...
6 14.080600 LINESTRING (-8.467084 51.91...