1

Getting an error when trying to load a shapefile via readOGR. readOGR works fine on my personal computer (mac) but I am running into issues on my work computer (windows).

When loading a shapefile using the typical syntax, I get the following error:

    Warning in ogrInfo(dsn = dsn, layer = layer, encoding = encoding, use_iconv = use_iconv,  :
      ogrInfo: all features NULL
    Error in readOGR(dsn = ".", "shp_example")  : no features found

For something reproducible, when I run the following code from the example from help(readOGR):

    library(rgdal)

    ogrDrivers()
    dsn <- system.file("vectors", package = "rgdal")[1]
    ogrListLayers(dsn)
    ogrInfo(dsn)

I get the following warning after "ogrInfo(dsn)", telling me that all features are null. Note that I only get this error on my work computer; this error does not occur on my personal computer:

    Warning in ogrInfo(dsn) : ogrInfo: all features NULL

Any ideas as to what is going on?

  • I have both OS (mac and windows) and I haven't problems running the code exposed. Which version of GDAL is installed on your windows PC? Did you try reinstalling rgdal? – aldo_tapia Jul 24 '17 at 21:22
  • What's the output of ogrDrivers() and ogrListLayers(...) for this data? What version of R, sp, and rgdal is it? – Spacedman Jul 25 '17 at 7:03
  • @aldo_tapia I tried reinstalling rgdal but am running into the same problem. Trying to check which version of GDAL is installed - how do I check this? – Rob Marty Jul 25 '17 at 13:37
  • @Spacedman R version: 3.4.1 sp version: 1.2-5 rgdal version: 1.2-8 /// ogrDrivers() gives a matrix with 55 rows, with "name", "long_name", "write" (mix of TRUE and FALSE), "copy" (mostly FALSE), and "isVector" (all TRUE) /// ogrListLayers(...) gives: Error: '...' used in an incorrect context /// ogrListLayers("C:/Users/shpFldr") gives: [1] "buildings" attr(,"driver") [1] "ESRI Shapefile" attr(,"nlayers") [1] 1 – Rob Marty Jul 25 '17 at 13:37
  • @RobMarty in cmd windows run gdalinfo --version – aldo_tapia Jul 25 '17 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.