[R-sig-Geo] Suggestion: option overwrite=T for writeOGR()

Agustin Lobo alobolistas at gmail.com
Fri Dec 10 18:39:15 CET 2010


Roger,

it works fine on another computer:

> require(rgdal)
Loading required package: rgdal
Geospatial Data Abstraction Library extensions to R successfully loaded
Loaded GDAL runtime: GDAL 1.7.2, released 2010/04/23
Path to GDAL shared files: /usr/share/gdal17
Loaded PROJ.4 runtime: Rel. 4.7.1, 23 September 2009
Path to PROJ.4 shared files: (autodetected)

> writeOGR(xygcatLO,dsn="xygcatLO",layer="xygcatLO", driver="ESRI Shapefile")
> sessionInfo()
R version 2.12.0 (2010-10-15)
Platform: i486-pc-linux-gnu (32-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8          LC_NUMERIC=C
LC_TIME=en_US.UTF-8
 [4] LC_COLLATE=en_US.UTF-8        LC_MONETARY=en_US.UTF-8
LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8          LC_NAME=en_US.UTF-8
LC_ADDRESS=en_US.UTF-8
[10] LC_TELEPHONE=en_US.UTF-8      LC_MEASUREMENT=en_US.UTF-8
LC_IDENTIFICATION=en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] rgdal_0.6-27  raster_1.6-22 sp_0.9-72     rkward_0.5.4

loaded via a namespace (and not attached):
[1] grid_2.12.0     lattice_0.19-13 tools_2.12.0

Agus


2010/12/10 Agustin Lobo <alobolistas at gmail.com>:
> Roger,
>
> is this all you need? I thought sessionInfo was providing everything
> needed. The driver is
> "ESRI Shapefile" as stated in the command, have not tested any other
> (it does work for
> raster though, as you mention):
>
>> require(rgdal)
> Loading required package: rgdal
> Geospatial Data Abstraction Library extensions to R successfully loaded
> Loaded GDAL runtime: GDAL 1.8dev, released 2010/01/19
> Path to GDAL shared files: /usr/local/share/gdal
> Loaded PROJ.4 runtime: Rel. 4.7.1, 23 September 2009
> Path to PROJ.4 shared files: (autodetected)
>
> Thanks
>
> Agus
>
> 2010/12/10 Roger Bivand <Roger.Bivand at nhh.no>:
>> On Fri, 10 Dec 2010, Agustin Lobo wrote:
>>
>>> Roger,
>>>
>>> It does not for me. The error is solved by deleting files xygcatLO.* ,
>>> while directory xygcatLO may continue to exist.
>>
>> Agus,
>>
>> With which drivers, OGR version (in header when rgdal loads)? If I cannot
>> reproduce this, I cannot readily help.
>>
>> Roger
>>
>>>
>>> Also, I've found that with this version the below command does not
>>> save the files within
>>> the folder indicated by dsn, but outside. This was not the case in the
>>> past, but do not know if this is
>>> because of a change in rgdal, gdal or ubuntu 10.04 (I've changed all 3
>>> since the last time I used writeOGR()).
>>>
>>>> writeOGR(xygcatLO,dsn="xygcatLO",layer="xygcatLO", driver="ESRI
>>>> Shapefile")
>>>
>>> Error in writeOGR(xygcatLO, dsn = "xygcatLO", layer = "xygcatLO",
>>> driver = "ESRI Shapefile") :
>>>
>>>        GDAL Error 1: Layer 'xygcatLO' already exists
>>> Calls: writeOGR -> .Call
>>>
>>>> sessionInfo()
>>>
>>> R version 2.12.0 (2010-10-15)
>>> Platform: x86_64-pc-linux-gnu (64-bit)
>>>
>>> locale:
>>> [1] LC_CTYPE=en_US.utf8          LC_NUMERIC=C
>>> [3] LC_TIME=en_US.utf8           LC_COLLATE=en_US.utf8
>>> [5] LC_MONETARY=en_US.utf8       LC_MESSAGES=en_US.utf8
>>> [7] LC_PAPER=en_US.utf8          LC_NAME=en_US.utf8
>>> [9] LC_ADDRESS=en_US.utf8        LC_TELEPHONE=en_US.utf8
>>> [11] LC_MEASUREMENT=en_US.utf8    LC_IDENTIFICATION=en_US.utf8
>>>
>>> attached base packages:
>>> [1] stats     graphics  grDevices utils     datasets  methods   base
>>>
>>> other attached packages:
>>> [1] RANN_2.1.2      outliers_0.13-3 rgdal_0.6-30    raster_1.7-2
>>> [5] sp_0.9-73       rkward_0.5.4
>>>
>>> loaded via a namespace (and not attached):
>>> [1] grid_2.12.0     lattice_0.19-13 tools_2.12.0
>>> 2010/12/10 Roger Bivand <Roger.Bivand at nhh.no>:
>>>>
>>>> On Thu, 9 Dec 2010, Barry Rowlingson wrote:
>>>>
>>>>> On Thu, Dec 9, 2010 at 8:56 AM, Agustin Lobo <alobolistas at gmail.com>
>>>>> wrote:
>>>>>>
>>>>>> Hi!
>>>>>>
>>>>>> Could an option overwrite=T (default overwrite=F) be included in
>>>>>> writeOGR()?
>>>>>> Thanks!
>>>>>
>>>>> Submit a Feature Request here:
>>>>>
>>>>> http://sourceforge.net/tracker/?group_id=84716&atid=573625
>>>>
>>>> No, rgdal is on R-Forge, and a list called rgdal-devel will be available
>>>> from tomorrow.
>>>>
>>>>>
>>>>> It looks like it just needs to be a wrapper around OGR's delete layer
>>>>> function.
>>>>
>>>> Contributions welcome. Note that the facility is present for rasters,
>>>> which
>>>> I fould out by accidentally deleting GRASS database objects (for which of
>>>> course I did not have backups). Is this really needed - which drivers do
>>>> not
>>>> already overwrite without complaint? These do not complain for me:
>>>> driver="ESRI Shapefile"; driver="KML"; driver="MapInfo File";
>>>> driver="MapInfo File", dataset_options="FORMAT=MIF".
>>>>
>>>> Hope this helps,
>>>>
>>>> Roger
>>>>
>>>>>
>>>>> Barry
>>>>>
>>>>> _______________________________________________
>>>>> R-sig-Geo mailing list
>>>>> R-sig-Geo at r-project.org
>>>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>>>>
>>>>
>>>> --
>>>> Roger Bivand
>>>> Economic Geography Section, Department of Economics, Norwegian School of
>>>> Economics and Business Administration, 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
>>>>
>>>> _______________________________________________
>>>> R-sig-Geo mailing list
>>>> R-sig-Geo at r-project.org
>>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>>>
>>>
>>
>> --
>> Roger Bivand
>> Economic Geography Section, Department of Economics, Norwegian School of
>> Economics and Business Administration, 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
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>



More information about the R-sig-Geo mailing list