sf package error in RStudio

Hello Community!

I'm trying to load the "sf" package and had the follow error warning:

Error: package or namespace load failed for ‘sf’:
 .onLoad failed in loadNamespace() for 'units', details:
  call: udunits_init(path)
  erro: no database found!

I tried to reinstall packages, Rcpp, units, and sf but it still doesn't work. This same problem is happening with another package rnaturalearth. Somebody can help me solve the units package problem please?

Thanks so much!!!

Try

install.packages(“udunits2”)
library(udunits2)

If you are on linux you have to install udunits on the shell. Follow the instructions on this web page and you should fine.

2 Likes

To give a little background on this error: the {sf} package depends on a whole host of external libraries, one of which is udunits2 (wrapped for use in R in package units, the naming is somewhat confusing). A small C library for unit conversion, which seems to be missing or corrupted on your computer, even though the wrapper R package is present. You will need to reinstall it.

As the library is external to R it will have to be done on your OS level - so it matters if you are on Windows, Linux or Mac. Linux instructions can be found at GitHub - r-quantities/units: Measurement units for R

For an overview have a look at R spatial follows GDAL and PROJ development and especially this picture

2 Likes