A package that provides simple features access for R. Package sf:
tibblewith a geometry list-column
(Illustration (c) by Allison Horst)
Install either from CRAN with:
this will install binary packages on Windows and MacOS, unless you configured R such that it tries to install source packages; in that case, see below.
Install development versions from github with
The easiest way to install
gdal is using Homebrew. Recent versions of homebrew include a full-featured up-to-date gdal formula, which installs
gdal at the same time:
brew install pkg-config brew install gdal
Once gdal is installed, you will be able to install
sf package from source in R. With the current version of
7.0.0) on homebrew, installation requires additional configuration:
install.packages("sf", configure.args = "--with-proj-lib=/usr/local/lib/")
Or the development version:
library(devtools) install_github("r-spatial/sf", configure.args = "--with-proj-lib=/usr/local/lib/")
If you are using
rgdal together it is necessary to install
rgdal from source using this configuration:
install.packages("rgdal", configure.args = c("--with-proj-lib=/usr/local/lib/", "--with-proj-include=/usr/local/include/"))
Alternatively these instructions explain how to install gdal using kyngchaos frameworks.
For Mac OS 11 Big Sur source install instruction see here
For Unix-alikes, GDAL (>= 2.0.1), GEOS (>= 3.4.0) and Proj.4 (>= 4.8.0) are required.
Dependencies for recent versions of Ubuntu (18.04 and later) are available in the official repositories; you can install them with:
apt-get -y update && apt-get install -y libudunits2-dev libgdal-dev libgeos-dev libproj-dev
However, to get more up-to-date versions of dependencies such as GDAL, we recommend adding the ubuntugis-unstable PPA to the package repositories and installing them as follows:
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable sudo apt-get update sudo apt-get install libudunits2-dev libgdal-dev libgeos-dev libproj-dev
Adding this PPA is required for installing
sf on older versions of Ubuntu (e.g. Xenial).
Another option, for advanced users, is to install dependencies from source; see e.g. an older travis config file for hints.
The following command installs all required dependencies:
sudo dnf install gdal-devel proj-devel proj-epsg proj-nad geos-devel sqlite-devel udunits2-devel
Get gdal, proj and geos from the main repos and udunits from the AUR:
pacman -S gdal proj geos yay/pacaur/yaourt/whatever -S udunits
In case you use dynamic linking (installation from source) and have multiple versions of these libraries installed (e.g. one from ubuntugis-unstable, another installed from source in
/usr/local/lib) then this will in general not work, even when setting
LD_LIBRARY_PATH manually. See here for the reason why.
Functions and methods that require
st_make_valid and all spherical or ellipsoidal metrics (area, distances), have since sf 0.5-5 been moved to their own package, lwgeom, which is also on CRAN.
<-; don't change indentation; tab stops of 4 spaces are preferred)
This project gratefully acknowledges financial support from the