hugomflavio / actel

Standardised analysis of acoustic telemetry data from fish moving through receiver arrays
https://hugomflavio.github.io/actel-website
26 stars 6 forks source link

Error for path in loadShape() #74

Closed PieterjanVerhelst closed 2 years ago

PieterjanVerhelst commented 2 years ago

When I feed loadShape() with the .shp files stored in my default path, the function runs perfectly:

water.shape <- loadShape(shape = 'be_rivers.shp',
                         size = 10, buffer = 10) 

However, when I run the function on a .shp files stored in a specific folder, I get an error related to the readOGR() function from the rgdal package:

water.shape <- loadShape(path = "./data/external/shapefiles/", 
                         shape = 'be_rivers.shp',
                         size = 10, buffer = 10)  
Error in ogrInfo(dsn = dsn, layer = layer, encoding = encoding, use_iconv = use_iconv,  : 
  Cannot open data source
hugomflavio commented 2 years ago

My first thought was that the last / in the path could be the issue, but I just tried it locally and the code seems to work both with and without the last bar.

It is interesting that actel itself is finding the file (otherwise there would be a different error earlier on). It may be an rgdal bug...

Can you try running the code below to see if the error persists?

rgdal::readOGR(dsn = "./data/external/shapefiles/", layer = 'be_rivers')

Can you also confirm which rgdal version you are using?

packageVersion('rgdal')
PieterjanVerhelst commented 2 years ago

That code is returning the same error indeed. I use version 1.5.28

hugomflavio commented 2 years ago

It is the same version as I am using. Try removing the last / to see if that changes anything. Next, try to remove the ./ at the beginning. If the error persists, confirm that the shapefile is not corrupted. Consider trying a different shapefile to see if the error persists.

PieterjanVerhelst commented 2 years ago

Aah, when removing the final / it works. Thanks for the quick service 👍!