For my MSc thesis I am trying to get data from soilGrids for a list of xy coordinates in R. Because I am not very good with R I am running into some problems when using this code: https://git.wur.nl/isric/soilgrids/soilgrids.notebooks/-/blob/master/markdown/xy_info_from_R.md

When I used the original piece of code:

spdata <- st_as_sf(data,coords = c("longitude", "latitude"), crs = 4326)

I got this error:

Error in [.data.frame(x, cords) : undefined columns selected

Therefore, I changed it, so that the column names would match the ones in my dataset, this gave me no errors or warning anymore:

spdata <- st_as_sf(data,coords = c("Longitude", "Latitude"), crs = 4326)

I was not sure what the dataset had to look like, so I first used a dataset with two columns, Longitude and Latitude. When I used that, I got the following error after this line:


Error in data.frame(st_coordinates(spdata_igh), id = spdata_igh$ID) : arguments imply differing number of rows: 546, 0

Therefore I changed my dataset into three columns, ID, Longitude and Latitude. (I don’t know how to load just a few xy coordinates for you to run the code, with R still recognizing the three columns, sorry….) I then received no errors. However, value_pixels is a value that says: numeric (empty). So I don’t think it worked. I received this warning:

Warning messages: 1: In gdal_setInstallation(ignore.full_scan = ignore.full_scan, verbose = verbose) : No GDAL installation found. Please install 'gdal' before continuing:

I have tried: install.packages(“gdal”) , but that gives me the warning:

WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding: Warning in install.packages : package ‘gdal’ is not available (for R version 3.6.3)

I have updated R to the newest version, but I still get the same warning when I try to install gdal. Furthermore, when I load gdalUtils nothing happens, I also get no warnings or errors. So, maybe the problem lies within these packages, but I can’t find out how to download them.

  • Welcome to Geographic Information Systems! Welcome to GIS SE! We're a little different from other sites; this isn't a discussion forum but a Q&A site. Your questions should as much as possible describe not just what you want to do, but precisely what you have tried and where you are stuck trying that. Please check out our short tour for more about how the site works
    – Ian Turton
    Apr 20, 2021 at 14:23
  • Could you post the code to be checked and controlled that is actually correct, mainly the adjustments made ?! Apr 20, 2021 at 14:54
  • 1
    You need to post your "adjusted" code and any "warnings" or "errors" returned after running the code. After a quick glance, I do not see where the original code would return an empty set so, it could easily be something that you unintentionally introduced when modifying the code. Rather than a line that reads in data, just include a few x,y coordinates from your data. You can hit the "edit" option at the bottom of the post, insert the code, highlight it and then hit the {} button to denote it as a code block. Apr 20, 2021 at 15:11

1 Answer 1


When you run install.packages() are you specifying the binary version, even if the source version is newer? There should be a message about that. You generally don't need the latest source version.

  • I am not sure what you mean by specifying the binary version. When I run install.packages("gdal") I only get the following warnings: WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding: cran.rstudio.com/bin/windows/Rtools Installing package into ‘C:/Users/annab/Documents/R/win-library/4.0’ (as ‘lib’ is unspecified) Warning in install.packages : package ‘gdal’ is not available for this version of R Apr 28, 2021 at 9:29
  • From the Rtools site: "Note that rtools40 is only needed build R packages with C/C++/Fortran code from source. By default, R for Windows installs the precompiled “binary packages” from CRAN, for which you do not need rtools!" So when you install.packages("gdal") you should get a binary (pre-compiled for Windows) package. If there is a newer one that needs to be built on your system from its source, you should be given the choice to use this one or the (slightly older) binary. Select the binary. Apr 29, 2021 at 14:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.