A suite of conversion scripts to create internally standardized spatial polygons data frames. Utility scripts use these data sets to return values such as country, state, timezone, watershed, etc. associated with a set of longitude/latitude pairs. (They also make cool maps.)
polygons dataframes. Utility scripts use these datasets to return values suchas country, state, timezone, watershed, etc. associated with a set oflongitude/latitude pairs. (They also make cool maps.)```## BackgroundThe MazamaSpatialUtils package was created by MazamaScience to regularize ourwork with spatial data. The sp, rgdal and maptools packages have made it mucheasier to work with spatial data found in shapefiles. Many sources of shapefiledata are available and can be used to make beautfiul maps in R. Unfortunately,the data attached to these datasets, even when fairly complete, often lacksstandardized identifiers such as the ISO 3166-1 alpha-2 encodings for countries.Maddeningly, even when these ISO codes are used, the dataframe column in whichthey are stored does not have a standardized name. It may be called ISO or ISO2or alpha or COUNTRY or any of a dozen other names we have seen.While many mapping packages provide ‘natural’ naming of countries, those whowish to develop operational, GIS-like systems need something that is bothstandardized and language-independent. The ISO 3166-1 alpha-2 encodings haveemerged as the defacto standard for this sort of work. In similar fashion, ISO3166-2 alpha-2 encodings are aviailable for the next administrative level down –state/province/oblast, etc.. For timezones, the defacto standard is the set ofOlson timezones used in all UNIX systems.The main goal of this package is to create an internally standardized set ofspatial data that we can use in various projects. Along with two built-indatasets, this package provides ‘convert~’ functions for other spatial datasetsthat we currently use. These convert functions all follow the same recipe:* download spatial data in shapefile format into a standard directory* convert shapefile data into a sp SpatialPolygonsDataFrame* modify the dataframe in the @data slot so that it adheres to package internal standardsOther datasets can be added following the same procedure.The ‘package internal standards’ are very simple. Every spatial dataset willhave at least one of the following, consistently named colums of data:* countryCode – ISO 3166-1 alpha-2* stateCode – ISO 3166-2 alpha-2* timezone – Olson timezoneIf another column contains this data, that column must be renamed orduplicated with the internally standardized name. This simple level ofconsistency makes it posisble to generate maps for any data that is ISO encoded.It also makes it possible to create functions that return the country, state ortimezone associated with a set of locations.## InstallationThis package is designed to be used with [R]() (>= 3.1.0)and [RStudio]() so make sure you have those installed first.Users will want to install the **devtools** package to have access to latest versionsof some packages that are not yet available on CRAN.The following packages should be installed with devtools by typing the following at the RStudio console:``` devtools::install_github('mazamascience/MazamaSpatialUtils', build_vignettes=TRUE) ```## ExamplesThe package vigentte 'Introduction to MazamaSpatialUtils' has numerous examples.----This project is supported by Mazama Science.