[R-SIG-Mac] Mac-only problem using readOGR() to read a shapefile from a directory on a USB pen drive
MacQueen, Don
macqueen1 at llnl.gov
Mon Mar 6 21:33:47 CET 2017
In that case I'm surprised. R is generally pretty solid about interactions with the OS. I may try to reproduce this on my Mac, though probably not today or tomorrow. If I have the same failure, the next step will probably be to contact the rgdal author(s).
-Don
--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
On 3/6/17, 11:48 AM, "D G. Rossiter" <d.g.rossiter at cornell.edu> wrote:
Good idea. From the shell, ogrInfo correctly reads the shapefile:
$ ogrInfo /Volumes/DRENTHE/ds/NEweather/ gdd50_7100j | more
INFO: Open of `/Volumes/DRENTHE/ds/NEweather/'
using driver `ESRI Shapefile' successful.
Layer name: gdd50_7100j
Geometry: Point
Feature Count: 5556
Extent: (-177.350000, -14.330000) - (174.100000, 71.280000)
Layer SRS WKT:
GEOGCS["GCS_North_American_1927",
DATUM["North_American_Datum_1927",
SPHEROID["Clarke_1866",6378206.4,294.9786982]],
PRIMEM["Greenwich",0.0],
UNIT["Degree",0.0174532925199433]]
STATION_ID: Integer (6.0)
STATE: String (2.0)
STATION_NA: String (24.0)
etc.
This is indeed an MS-DOS USB device (which came from a meeting at the Drenthe (NL) provincial enviromental bureau, hence the volume name):
$ mount | grep DRENTHE
/dev/disk3s1 on /Volumes/DRENTHE (msdos, local, nodev, nosuid, noowners)
From R comes the failure with readOGR:
> usa <- readOGR(dsn="/Volumes/DRENTHE/ds/NEweather/", layer=“gdd50_7100”)
Error in ogrInfo(dsn = dsn, layer = layer, encoding = encoding, use_iconv = use_iconv, :
Cannot open data source
D G (David) Rossiter
Section of Soil & Crop Sciences
Cornell University
http://www.css.cornell.edu/faculty/dgr2/
> On 06 Mar 2017, at 12:56, MacQueen, Don <macqueen1 at llnl.gov> wrote:
>
> It would be informative to try ogrInfo from the shell prompt (i.e., outside of R) to find out if this is an R problem or an ogrInfo problem.
>
> -Don
>
> --
> Don MacQueen
>
> Lawrence Livermore National Laboratory
> 7000 East Ave., L-627
> Livermore, CA 94550
> 925-423-1062
>
>
> On 3/4/17, 3:40 AM, "R-SIG-Mac on behalf of D G. Rossiter" <r-sig-mac-bounces at r-project.org on behalf of d.g.rossiter at cornell.edu> wrote:
>
> Thanks to Ken Beath, this indeed was the problem. I tested by formatting a USB drive to Mac format with Disk Info, copying the shapefiles onto it, and then reading with readOGR().
>
> Problem solved, although the Mac-formatted USB drive could not be used to transfer files to and from Windows machines.
>
> D G (David) Rossiter
> Section of Soil & Crop Sciences
> Cornell University
> http://www.css.cornell.edu/faculty/dgr2/
>
>
> 1. Re: Mac-only problem using readOGR(), which uses ogrInfo(),
> to read a shapefile from a directory on a USB pen drive (Ken Beath)
>
> From: Ken Beath <ken at kjbeath.com.au<mailto:ken at kjbeath.com.au>>
> Subject: Re: [R-SIG-Mac] Mac-only problem using readOGR(), which uses ogrInfo(), to read a shapefile from a directory on a USB pen drive
> Date: 3 March 2017 at 20:28:33 GMT-5
> To: "D G. Rossiter" <d.g.rossiter at cornell.edu<mailto:d.g.rossiter at cornell.edu>>
> Cc: "r-sig-mac at r-project.org<mailto:r-sig-mac at r-project.org>" <r-sig-mac at r-project.org<mailto:r-sig-mac at r-project.org>>
>
>
> My thought is that it might be that USB drives are usually MSDOS formatted. Usually not a problem but rgdal works with directories. Formatting in a Mac with Disk Utility might be a work-around, with the limitation that the USB will only work in Macs.
>
> I would also try verbose=TRUE which may give more information.
>
> In the absence of other ideas contacting the package author can help.
>
> Ken
>
> On 4 Mar 2017, at 3:32 am, D G. Rossiter <d.g.rossiter at cornell.edu<mailto:d.g.rossiter at cornell.edu>> wrote:
>
> I ran across a Mac-only problem using readOGR(), which uses ogrInfo(), to read a shapefile from a directory on a USB pen drive. I tested the behaviour on a Windows 10 machine and did not get the problem.
>
> Trying to read from the USB drive, with relative and full paths:
>
> setwd("/Volumes/ISPRS/“) # this is my connected USB drive
> list.files()
> [1] "map7100.dbf" "map7100.prj"
> [3] "map7100.sbn" "map7100.sbx"
> [5] "map7100.shp" "map7100.shp.xml"
> [7] "map7100.shx"
> file.exists("map7100.shp")
> [1] TRUE
> usa <- readOGR(dsn=".", layer="map7100")
> Error in ogrInfo(dsn = dsn, layer = layer, encoding = encoding, use_iconv = use_iconv, :
> Cannot open data source
> usa <- readOGR(dsn="/Volumes/ISPRS", layer="map7100")
> Error in ogrInfo(dsn = dsn, layer = layer, encoding = encoding, use_iconv = use_iconv, :
> Cannot open data source
>
> But, readOGR reads the shapefile correctly if it’s located on the Mac’s internal drive:
>
> setwd("/Users/rossiter/data/edu/dgeostats/ex")
> file.exists("./ds/NEweather/map7100.shp")
> [1] TRUE
> usa <- readOGR(dsn="./ds/NEweather", layer="map7100")
> OGR data source with driver: ESRI Shapefile
> Source: "./ds/NEweather", layer: "map7100"
> with 7926 features
> It has 19 fields
>
> All packages are up to date. Here is the sessionInfo():
>
> R version 3.3.2 (2016-10-31)
> Platform: x86_64-apple-darwin13.4.0 (64-bit)
> Running under: OS X El Capitan 10.11.6
>
> locale:
> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
>
> attached base packages:
> [1] stats graphics grDevices utils datasets methods base
>
> other attached packages:
> [1] ggplot2_2.2.1 sf_0.3-4 maptools_0.9-1 rgdal_1.2-5
> [5] sp_1.2-4 gstat_1.1-4
>
> loaded via a namespace (and not attached):
> [1] Rcpp_0.12.9 plyr_1.8.4 xts_0.9-7 tools_3.3.2
> [5] digest_0.6.12 evaluate_0.10 tibble_1.2 gtable_0.2.0
> [9] lattice_0.20-34 DBI_0.5-1 yaml_2.1.14 stringr_1.2.0
> [13] knitr_1.15.1 rprojroot_1.2 grid_3.3.2 spacetime_1.2-0
> [17] foreign_0.8-67 rmarkdown_1.3 udunits2_0.13 magrittr_1.5
> [21] backports_1.0.5 scales_0.4.1 intervals_0.15.1 htmltools_0.3.5
> [25] units_0.4-2 rsconnect_0.7 assertthat_0.1 colorspace_1.3-2
> [29] labeling_0.3 stringi_1.1.2 lazyeval_0.2.0 munsell_0.4.3
> [33] FNN_1.1 zoo_1.7-14
>
> This is a problem because several of my students have OS/X machines and like to work from USB-connected external drives.
>
> D G (David) Rossiter
> Section of Soil & Crop Sciences
> Cornell University
> http://www.css.cornell.edu/faculty/dgr2/
>
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
>
>
>
>
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac at r-project.org<mailto:R-SIG-Mac at r-project.org>
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
>
More information about the R-SIG-Mac
mailing list