PostGIS - Tipps und Tricks: Unterschied zwischen den Versionen

Aus Geoinformation HSR
Wechseln zu: Navigation, Suche
(shp2pgsql)
(SRID)
Zeile 9: Zeile 9:
 
* In the geometry_columns system table: select * from geometry_columns;
 
* In the geometry_columns system table: select * from geometry_columns;
  
Mit der Methode UpdateGeometrySRID([<schema_name>], <table_name>, <column_name>, <srid>) kann man  
+
Mit der Methode UpdateGeometrySRID([<schema_name>], <table_name>, <column_name>, <srid>) kann man die Kolonne aktualisieren.
 +
 
 +
* Tipp: http://www.spatialreference.org/
  
 
== shp2pgsql ==
 
== shp2pgsql ==

Version vom 12. Oktober 2007, 18:18 Uhr

Siehe auch

SRID

Der SRID (projection identifier) wird an drei Orten verwaltet:

  • In der geometry column: select SRID(the_geom) from mytable limit 5;
  • As a constraint on the table for the geometry column: \d mytable
  • In the geometry_columns system table: select * from geometry_columns;

Mit der Methode UpdateGeometrySRID([<schema_name>], <table_name>, <column_name>, <srid>) kann man die Kolonne aktualisieren.

shp2pgsql

Man beachte beim Import von Shapefiles das .prj File. Ohne weitere Angaben wird der SRID auf -1 gesetzt. Siehe SRID (Quelle).

Shapfeil Geodaten in Datenbank geo1 laden:

 % shp2pgsql -s 21781 -I -W ISO-8859-1 gemeinden public.gemeinden > gemeinden.sql
 % psql -d geo1 -U geo1 -f gemeinden.sql

Eine Alternative zu shp2pgsql ist ogr2ogr von OGR.

Mit einfachster Webapplikation und PostGIS zur Online-Karte

Von PostGIS direkt nach Google Earth

Man starte psql (Beispiel mit Box um Victoria, BC, Kanada):

 -- Set output to unaligned
 \a
 -- Show only tuples
 \t
 -- Dump query to a file
 \o my_kml_file.kml
 -- Run your query
 SELECT askml('my_line', 'description', 'SRID=3005;LINESTRING( 1190000
 390000, 1200000 390000, 1200000 380000, 1190000 380000, 1190000 390000
 )'::geometry);
 -- Flush output your file and close the output stream
 \o

Dann Doppelklick auf die KML-Datei und Google Earth startet!