2 Requirements
For this walkthrough we will be using the R programming language.
You will need to install:
- R and RTools programming language and compiler tool
- R Studio (Suggested) editor for easily working with R
- sf, mapview, lwgeom, and units libraries in the R console (seen below)
2.1 Overview of R Packages
sf is a very convenient and relatively user-friendly R package that provides tools for working with geometries - making it easy to read, write, and work with geospatial data.
mapview provides interactive mapping functionality so we can inspect geospatial data in detail. For our particular purpose, it also provides a handy npts
function that allows us to extract the number of vertices given a polygon or polyline.
lwgeom is needed by sf to get the lengths of polylines and other geometric objects, so we will install it to satisfy the dependencies.
units is package for converting and handling units of measurements. We will use this package to convert unit of measurements for our area calculations when deciding on a state/UT to use.
2.2 Loading the R Libraries
After you have finished installing the requirements, don’t forget to load the libraries in the R console!:
Note: All code will be assumed to be in the R console moving forward.
After satisfying all of the requirements, the next section will show you how to get the DIVA-GIS data into R.