FWIW, this is the same at the command line with ogr2ogr so presumably the
error is from GDAL/OGR and not R-specific:

1) This works, whether "outdsn" folder exists or not:

C:\temp>ogr2ogr C:/temp/outdsn Drawing.shp  Drawing

(Command is "ogr2ogr [destination] [source] [sourcelayername]", and the
destination layer name is the sourcelayername, override with -nln).

2) This doesn't work, and if "outdsn2" folder does not exist it is created,
though the layer write fails

ogr2ogr C:/temp/outdsn2/ Drawing.shp  Drawing

C:\temp>ogr2ogr --version
GDAL 1.9.2, released 2012/10/08

I don't know how this relates to non-Windows.

Cheers, Mike.


On Sun, Apr 14, 2013 at 3:20 AM, Roman Luštrik <roman.lustrik@gmail.com>wrote:

> I just noticed that writing to a shape file using a trailing slash in
> the directory path doesn't work (with a somewhat non-informative
> error):
>
> > writeOGR(obj = pril08c2.poly, dsn = "q:/projekti/gams_eksp/analiza/",
> layer = "priloznostno_2008_2012_cona2", driver = "ESRI Shapefile")
> Error in writeOGR(obj = pril08c2.poly, dsn =
> "q:/projekti/gams_eksp/analiza/",  :
>   Creation of output file failed
>
> While this does:
>
> > writeOGR(obj = pril08c2.poly, dsn = "q:/projekti/gams_eksp/analiza",
> layer = "priloznostno_2008_2012_cona2", driver = "ESRI Shapefile")
> >
>
> The only difference is the trailing slash in the `dsn` path to the
> folder is missing. I hope this will save someone some time - it ate
> away most of my Saturday morning.
>
> Cheers,
> Roman
>
> --
> In God we trust, all others bring data.
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



-- 
Michael Sumner
Hobart, Australia
e-mail: mdsumner@gmail.com

	[[alternative HTML version deleted]]

