0

I tried to open a list of shp file, using this code:

path_par <- list.files(path = "E:\\core", full.names = T, pattern = "shp")
parch <-path_par %>% map(read_sf)

But I receive this error message:

Error: Cannot open "E:\core\CorePO_Esc0.shp.xml"; The source could be corrupt or not supported. See `st_drivers()` for a list of supported formats.

Any help will be greatly appreciated.

  • 2
    I'm not an expert on this, but I thought that `read_sf` was intended to read `.shp` files, not `.xml` files. Do you mean `pattern="\\.shp$"` instead? – r2evans Jan 28 '22 at 04:49

1 Answers1

0

Just add $in your pattern (if not your are trying to open one of the many sidecars files) :

dir.create("test")
file.create("test/my_file.shp")
file.create("test/my_file.shp.xml")
list.files("test")

path_par <- list.files(path = "test", full.names = T, pattern = "shp$")
path_par
defuneste
  • 376
  • 2
  • 7