-
Notifications
You must be signed in to change notification settings - Fork 299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reading shapefile from FAT-formatted keydrive on OSX #252
Comments
I followed Roger's request to see what happens when the dsn is specified as the full shapefile name. Indeed this solves the problem; it remains in the original case:
|
Good. Did this also work without changing the working directory?
|
Yes:
|
So this is the clearest resolution; with sf and (I hope) rgdal, you should now be able to get away with just giving the dsn, and leaving layer missing:
which will read the dsn, and choose the only or first layer. Shapefiles only have one layer, so that should be watertight. Please also try the rgdal::readOGR() equivalent. |
Indeed. These both succeed:
Although this goes against the usual practice for shapefiles. The documentation for st_read does say "in case layer is missing, st_read will read the first layer of dsn" and for readOGR "From rgdal 1.2.*, layer may be missing, in which case ogrListLayers examines the dsn, and fails if there are no layers, silently reads the only layer if only one layer is found, and reads the first layer if multiple layers are present, issuing a warning that layer should be given explicitly." And the documentation for dsn does say "for some dirvers, dsn is a file name". However, having different behaviour on FAT and Mac formatted external drives is certainly confusing to the user. |
@edzer : do you still have access to an OSX machine (as in December)? Is there anyone we could ask who knows both OSX and GDAL? @cyrus621 Are other drivers more robust? Could you consider migrating to a different format for your students (GPKG)? Do we need to think about changing usual practice? I could edit our book code (not in the book, but from the website). I agree that we should continue to use dsn=, layer=, and not rely on "automatic" layer choice. |
The issue is that many datasets, including the one in this exercise (USA climate stations) are provided as shapefiles, and in student projects they go get more shapefiles on their own. Also we use some ASDAR2 exercises which I've worked into tutorials, and many of these use shapfiles. Hence the need to read shapefiles. Now that the students are aware of the issue I can show them how to use readOGR with just the full file name as dsn and no layer. Then the developers can consider if it's possible to make the 'old' behaviour of dsn/layer also work on FAT volumes on OS/X. |
On 08/03/17 13:49, Roger Bivand wrote:
@edzer <https://github.com/edzer> : do you still have access to an OSX
machine (as in December)? Is there anyone we could ask who knows both
OSX and GDAL?
Yes, still have it here. keydrive, is that like OSX speak for USB stick?
@cyrus621 <https://github.com/cyrus621> Are other drivers more robust?
Could you consider migrating to a different format for your students (GPKG)?
--
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Heisenbergstraße 2, 48149 Münster, Germany; +49 251 83 33081
Journal of Statistical Software: http://www.jstatsoft.org/
Computers & Geosciences: http://elsevier.com/locate/cageo/
|
Yes, a USB stick, or any USB-connected external drive, mounted at /Volumes |
Yes, I can confirm that things work as documented on the hard drive, but not on a usb stick mounted on |
It will work properly on a Mac-formatted USB stick/hard drive. The issue is with FAT-formatted sticks/drives. |
I've changed to code examples using readOGR() on shapefiles on www.asdar-book.org to use only the file dsn rather than the directory - running tests now. |
Funny case. Should we add something to the documentation of |
I guess we might do that. I can't see how both sf and rgdal (with the same underlying static linked GDAL) and very different compiled code are being misled. It could be something in the GDAL build, but that is hard to test. |
Time to stop using shapefiles? |
I remember being at an ESRI demonstration in Syracuse in the early 1990s when the ESRI rep was promoting shapefiles as the new technology to replace coverages. I could never understand why they wanted to do away with proper topology. Anyway, shapefiles will be with us for a long time, for example the (US) Library of Congress has it as a "sustainable" format: http://www.digitalpreservation.gov/formats/fdd/fdd000280.shtml. |
You're right; we'd better document how they can be read. |
These threads 1 and 2 show odd behaviour when reading shapefiles from FAT-formatted keydrives on OSX with CRAN sfr and rgdal binaries. I'll ask the affected people to join in here with more details, for now:
The text was updated successfully, but these errors were encountered: