Posts

Showing posts from December, 2012

Quantum GIS copy paste geom and attributes into Postgis

Problem: I have a shapefile with 5000 points and I have a Postgis table that I want to add data to from the shapefile.  I want to select 1500 points from the shapefile and use copy paste into the Postgis table. process: open qgis add the shapefile layer add the postgis layer start editing the postgis layer (this is where the new data is going) select the 1500 points using the table editor based on criteria select copy select the postgis layer from the layers menu on the left select paste data is pasted save ERROR Änderungen am Layer poi konnten nicht gespeichert werden Fehler: FEHLER: 14 Objekte nicht hinzugefügt. Datenlieferantenfehler: PostGIS-Fehler beim Attributhinzufügen: ERROR: duplicate key value violates unique constraint "poi_pkey" DETAIL: Key (id)=(0) already exists. What to do? open attribute table of postgis layer and you should see the data selected and make sure you only see the selected data click field calculator select edit exist

Geoserver batch create layers from Postgis

Goal: Goal is to automatically slurp up all tables in the Postgresql Postgis database in the schema "geodata" and create the geoserver layers.  Then we want to assign a SLD to the layer. Finally create a l ayer g r oup. Prerequisites: Postgresql PostGIS database exists Geoserver Workspace exists (demo_wrkspc) Geoserver Datastore exists (temp_datastore) Text file list of all table names (tablelist.txt) curl is installed SLD style is created and located in a workspace OS: ran on CentOS 6.3  Code: my bash script saved as upload_db.sh while read p; do   curl -u username:password -v -XPOST -H 'Content-Type:text/xml' -d '<featureType><name>'$p'</name></featureType>' http://localhost:8080/geoserver/rest/workspaces/demo_wrkspc/datastores/temp_datastore/featuretypes; done < tablelist.txt tablelist.txt is a list of the table names in my database here are 3 tables i have in my list.  (originally i had 75 tables)