Appending data to PostGIS layer
Mauro,
On 30/11/2010, at 5:56 AM, Mauro Rossi wrote:
I have n shapefiles and n .txt files. For each shapefile I need to
merge the attributes table with the attributes in the corresponding .txt
file. After this I need to put all these new merged spatial layers in
the same Postgis layer. Given the high number of shapefiles, I need to
add one file at a time. I've completed the part regarding the merging,
but I still understand how to append the different spatial layers to the
same PostGis layer. Function writeOGR{rgdal} doesn't seem to have this
possibility. Does anybody know how I can do this?
If you already have the spatial data in the database, and some key attribute which is common between the two (ie province name or code) just use normal SQL to achieve this - use ALTER TABLE to ADD the required columnsand UPDATE based on the common attribute. The advantage to doing this in R is maybe looping to cover all tables, using read.table to load the txt file - you can make it as complex as you want after that!! look at library(RPostgreSQL) if you don't already have it. cheers Ben
Mauro -- Mauro Rossi Istituto di Ricerca per la Protezione Idrogeologica Consiglio Nazionale delle Ricerche Via della Madonna Alta, 126 06128 Perugia Italia Tel.+39 075 5014421 Fax +39 075 5014420 [[alternative HTML version deleted]]
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo