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

Alex Mandel tech_dev at wildintellect.com
Thu Apr 22 19:12:58 CEST 2010

German Sanchez Hernandez wrote:
> 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

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.


More information about the R-sig-Geo mailing list