Reading spatial data from mapped network drive

230 Views Asked by At

I am working with a shared folder containing multiple datasets. Because this is part of a teamwork and so that we can all use the same scripts without the need to always update the local paths in our personal machines, we mapped the shared folder as a network drive. Of course tat the content in the shared folder and the network drive is the same. However, when reading spatial data such as a gdb or shp from the mapped drive it returns an empty feature collection or error (see examples below).

I apologize for not providing a reproducible example, but I don't think it’s possible in this instance.

library(sf)
library(tidyverse)

#Shared main dir
shared.dir <- 'N:/mapped_path/'

#Data dir
data.dir <- paste0(shared.dir, 'data/')

# Reading gdb file from mapped_path (N:\\)
dsn <- paste0(data.dir, "file.gdb")
dat_raw <- st_read(dsn, layer = 'annual')

#################################
# Returns empty feature collection
Reading layer `annual' from data source 
  `N:\mapped_path\data\file.gdb' 
  using driver `OpenFileGDB'
Simple feature collection with 0 features and 0 fields
Bounding box:  xmin: NA ymin: NA xmax: NA ymax: NA
Geodetic CRS:  WGS 84
Warning message:
In CPL_read_ogr(dsn, layer, query, as.character(options), quiet,  :
  GDAL Error 4: Cannot open N:\mapped_path\data\file.gdb\a00000009.gdbtable (layer annual): No error
#####################################

# Reading shp file from mapped_path (N:\\)
dat_sf <- st_read(paste0(data.dir, “file.shp”))
#####################################
Error: Cannot open "N:\mapped_path\data\file.shp"; The source could be corrupt or not supported. See `st_drivers()` for a list of supported formats.
In addition: Warning message:
In CPL_read_ogr(dsn, layer, query, as.character(options), quiet,  :
  GDAL Message 4: Failed to open .
#####################################

I can easily read csv files from mapped_path

# Reading csv file from mapped_path
pa_dat <- read_delim(paste0(data.dir, "file.csv"), 
name_repair = 'universal')

head(pa_dat)
# A tibble: 6 × 4
  Country.Name                Country.Code Indicator.Name                                     PA_coverage
  <chr>                       <chr>        <chr>                                                    <dbl>
1 Aruba                       ABW          Terrestrial protected areas (% of total land area)       18.9 
2 Africa Eastern and Southern AFE          Terrestrial protected areas (% of total land area)       16.9 
3 Afghanistan                 AFG          Terrestrial protected areas (% of total land area)        3.64
4 Africa Western and Central  AFW          Terrestrial protected areas (% of total land area)       15.7 
5 Angola                      AGO          Terrestrial protected areas (% of total land area)        6.97

And if I use the local path (pointing to the same files as before) I can read the spatial data without any problem:

# Reading gdb file from local_path (C:\\)
dsn <- "C:\\local_path\\file.gdb"
dat_raw <- st_read(dsn, layer = 'annual')

#####################################
# Returns feature collection with 68506
Reading layer `annual' from data source 
  `C:\local_path\file.gdb' 
  using driver `OpenFileGDB'
replacing null geometries with empty geometries
Simple feature collection with 68506 features and 262 fields (with 12 geometries empty)
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: -180 ymin: -89.99999 xmax: 180.0006 ymax: 83.65833
Geodetic CRS:  WGS 84
Warning message:
In CPL_read_ogr(dsn, layer, query, as.character(options), quiet,  :
  GDAL Message 1: organizePolygons() received a polygon with more than 100 parts. The processing may be really slow.  You can skip the processing by setting METHOD=SKIP, or only make it analyze counter-clock wise parts by setting METHOD=ONLY_CCW if you can assume that the outline of holes is counter-clock wise defined
#####################################

# Reading shp file from local_path (C:\\)
dat_sf <- st_read("C:\\local_path\\file.shp")
#####################################
Reading layer `file' from data source 
  `C:\local_path\file.shp' 
  using driver `ESRI Shapefile'
Simple feature collection with 6933 features and 6 fields
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: -171.7608 ymin: -54.77436 xmax: 179.4398 ymax: 81.35914
Geodetic CRS:  WGS 84
#####################################

Interestingly my colleague can read these files using the exact same approach. Any clue on what the problem (and solution) might be when reading spatial data from the mapped network would be very much appreciated.

0

There are 0 best solutions below