Skip to content
Prev 23672 / 29559 Next

rgdal_1.1-1: dsn path string problems

Hi Roger,

many thanks for your quick answer.


Am 08.11.15 um 18:02 schrieb Roger Bivand:
OK, that seems reasonable. Of course, rgdal should handle this like R in
total. Thanks you for clarification.
The syntax, shown in the helpfile, does not work for me:

rgdal::ogrListLayers(dsn="/path", layer="layername")
Fehler in rgdal::ogrListLayers(dsn = "/path", layer = "layername") :
  unbenutztes Argument (layer = "layername")    # unused argument


The same, with layer integrated in the dsn, works fine:

rgdal::ogrListLayers(dsn="/path/layername.shp")
[1] "layername"
attr(,"driver")
[1] "ESRI Shapefile"
attr(,"nlayers")
[1] 1


This leads me to the idea, that the same could work for writeOGR or
ogrWrite.R. And yes, this works on FreeBSD:

writeOGR(gis.layer, dsn="/path/layername.shp",
         layer="layername", driver="ESRI Shapefile",
         check_exists=TRUE, overwrite_layer=TRUE)

So, I have to double 'layername' here, once in dsn and once in layer.
But it should be ok as a workaround until I found the real cause.
Thanks for the tip. I will investigate into it.

A first question to this: If I want to integrate some Rprintf into
ogrsource.cpp in the section of ogrCheckExists (lines 832 ...), what is
a good syntax to output for example 'ogrSource' and 'Layer'?

What I tried at ogrsource.cpp:l834 without success is:

Rprintf( "ogrCheckExists: OGRSource %s %p\n", OGRLayer, (void *)
ogrSource) ;

It think, I have to wrap 'ogrSource' with some function here? (I am not
a C/C++ programmer)
Because using the shapefile.shp as the dsn helps, I did not try a
different driver. If this is important for you, I can catch it up later.

Thanks again for your help,
Rainer