[R-sig-Geo] Adding a shape with writeOGR

Edzer Pebesma edzer.pebesma at uni-muenster.de
Thu Apr 29 18:31:06 CEST 2010



German Sanchez Hernandez wrote:
> Hi again,
> 
> The "overwrite=no" doesn't work (it is not recognized so the error I get is that the table yet exists).
> 
> I'm using R not only to save my shape files into a database but to "sptransform" some of them and to perform some operations on them.
> 
> I've made a script to do all operations over the shapes and to write them in a unique folder. So, I could process them using shp2pgsql (with the "-a" flag for appending them to an existing table).
> 
> But I would like to do it using R because the current approach (reading, processing, writting to disk, reading and writting to DB) is not efficient at all. The alternative (reading, processing, writting to a temp table, moving to the final table and dropping the temp table) is better but it still has some expendable steps.
> 
> Any other idea?

Maybe, for finding help, I guess you need to get involved somehow with
the person who wrote or maintain the postgis driver in gdal -- R simply
interfaces to it, but has no possibility nor any pretention to extend
gdal drivers as such.
--
Edzer

> 
> Thanks,
> Germán Sánchez
> 
> On 22/04/2010, Alex Mandel wrote:
> The obvious question here, what happens if you set overwrite=no?
> 
> If the only thing you're using R for is converting a shapefile to
> postgis you might want to just use ogr2ogr on the command line with the
> -append option. Postgis also ships with a shp2pgsql tool that might
> handle this too.
> 
> Alternately you can always load more data into a temp table and then run
>  some SQL to add the additional records to the first table.
> 
> 
> Alex
> 
> El 22/04/2010, a las 14:03, German Sanchez Hernandez escribió:
> 
>> Dear all,
>>
>> I'm trying to save some shapes to a postGIS table. I can do it by:
>>
>>  shape <- readShapePoly(...)
>>  writeOGR(shape, dsn="PG:dbname=gis user=gis password=...", layer='onetable', driver="PostgreSQL", layer_options="overwrite=yes")
>>
>> It empties the "onetable" table. Then, how could I do if I want to add other shape to this table without overwritting it?
>>
>> I've searched for the params of "layer_options", but I didn't find nothing.
>>
>> Thank you!
>> Germán Sánchez
>>
> 
> 
> 	[[alternative HTML version deleted]]
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

-- 
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
8333081, Fax: +49 251 8339763  http://ifgi.uni-muenster.de
http://www.52north.org/geostatistics      e.pebesma at wwu.de



More information about the R-sig-Geo mailing list