10  Inspecting Geographic Data Files

Often, when we open a new geographic data file, we don’t know what fields of data it contains.

It is useful to get an idea of what data our geographic data file already contains in order to know whether or not we may need to merge in other data (Chapter 15).

names and head are two useful commands for learning about new geographic data files.

As an example, I am going to use the country data from the rnaturalearth library (Chapter 12).

10.1 Data

I use ne_countries() to create the mapdata dataset as an sf object (Chapter 7).

library(rnaturalearth) 

mapdata <- ne_countries(scale = "medium", 
                        returnclass = "sf") 

10.2 names

names gives us the names of all of the fields of the data.

names(mapdata)
 [1] "scalerank"  "featurecla" "labelrank"  "sovereignt" "sov_a3"    
 [6] "adm0_dif"   "level"      "type"       "admin"      "adm0_a3"   
[11] "geou_dif"   "geounit"    "gu_a3"      "su_dif"     "subunit"   
[16] "su_a3"      "brk_diff"   "name"       "name_long"  "brk_a3"    
[21] "brk_name"   "brk_group"  "abbrev"     "postal"     "formal_en" 
[26] "formal_fr"  "note_adm0"  "note_brk"   "name_sort"  "name_alt"  
[31] "mapcolor7"  "mapcolor8"  "mapcolor9"  "mapcolor13" "pop_est"   
[36] "gdp_md_est" "pop_year"   "lastcensus" "gdp_year"   "economy"   
[41] "income_grp" "wikipedia"  "fips_10"    "iso_a2"     "iso_a3"    
[46] "iso_n3"     "un_a3"      "wb_a2"      "wb_a3"      "woe_id"    
[51] "adm0_a3_is" "adm0_a3_us" "adm0_a3_un" "adm0_a3_wb" "continent" 
[56] "region_un"  "subregion"  "region_wb"  "name_len"   "long_len"  
[61] "abbrev_len" "tiny"       "homepart"   "geometry"