[R-sig-Geo] strange trouble with writeOGR call

Roger Bivand Roger.Bivand at nhh.no
Thu Feb 27 09:02:32 CET 2014


On Thu, 27 Feb 2014, Edzer Pebesma wrote:

> The first thing I would try is let the application print the complete
> file name (path+file) where it wants to create a layer, and then verify
> by hand that under the permissions of the application you can actually
> do this (you have write permission, there is disk space).

The test is:

library(rgdal)
td <- tempdir()
cities <- readOGR(system.file("vectors", package = "rgdal")[1], "cities")
writeOGR(cities, td, "cities", driver="ESRI Shapefile") # works first time
writeOGR(cities, td, "cities", driver="ESRI Shapefile") #fails with
#layer exists, use a new layer name (not this case - overwriting can
#be done using the appropriate argument)
td <- "<a directory to which I do not have write permissions>"
writeOGR(cities, td, "cities", driver="ESRI Shapefile")
#Layer creation failed, error message from within GDAL/OGR

So follow Edzer's advice and determine where Shiny is trying to write 
stuff, inserting:

print(file.info(td)[c("mode", "uname")])

where td is your dsn= argument. For my failing case I see 755 and root, if 
I do the same on R's tempdir:

td <- tempdir()

I see 700 and my user name, so R is giving me (alone) full writes (read 4, 
write 2, and execute 1 to the directory).

I suspect that Shiny is not putting things where you think on the server. 
Indeed, it may well be trying to behave in a secure way on the server, by 
locking down permissions - I would certainly do this on any service facing 
the internet. If in doubt, create a small reproducible example and send it 
to the Shiny people or ask wherever they accept questions.

Roger

>
> On 02/27/2014 04:49 AM, Cynthia Hart wrote:
>> I am working on an application that uses 'Shiny'; which allows for
>> basically running R through a web browser.  My application is tested on
>> my Windows laptop then ported to a Linux server.   My application
>> analyzes spatial data, and uses the rgdal library.
>>
>> I am getting s strange error from writeOGR from a recent version of my
>> application, and I don't understand why, as the error did not occur
>> before on either platform, and the changes should not have effected the
>> call to write.
>>
>> 'Error:  Layer Creation failed'
>>
>> is the error I am getting.  Which seems to imply a permissions problem,
>> but I've analyzed that angle to death, and I cannot see a problem (I
>> even saved a temporary variable to disk right before the writeOGR call,
>> to the same intended directory, and that works fine).   Is there some
>> other cause for this error, some other possible problem I should be
>> looking for?  Thanks!
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>

-- 
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no



More information about the R-sig-Geo mailing list