"The explosive growth of the GeoWeb and geographic information has made GIS powerful media for the general public to communicate, but perhaps more importantly, GIS have also become media for constructive dialogs and interactions about social issues." - Sui & Goodchild
This shows you the differences between two versions of the page.
geoinf15:postgis1 [2015/11/16 10:31] oertz [Premiers pas] |
geoinf15:postgis1 [2018/05/16 10:05] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Spatial Query Language :: Part1 ====== | ||
- | Créer une //géotable// : | ||
- | <code> | ||
- | CREATE TABLE test (id serial PRIMARY KEY, genre text); | ||
- | SELECT AddGeometryColumn( 'test', 'the_geom', -1, 'GEOMETRY', 2 ); | ||
- | </code> | ||
- | Alimenter la table avec quelques géométries //en dur// et pas vraiment "spatiales" (SRS = -1 !!): | ||
- | <code> | ||
- | INSERT INTO test VALUES ( 3, 'batiment1', ST_GeometryFromText( 'POLYGON((10 10,40 20,35 8,12 4,10 10))', -1 ) ); | ||
- | INSERT INTO test VALUES ( 4, 'batiment2', ST_GeometryFromText( 'POLYGON((10 40,20 30,30 40,40 35,50 60,35 80,20 60,10 40))', -1 ) ); | ||
- | INSERT INTO test VALUES ( 5, 'batiment3', ST_GeometryFromText( 'POLYGON((10 95,20 95,20 135,10 135,10 95))', -1 ) ); | ||
- | |||
- | INSERT INTO test VALUES ( 1, 'pieton1', ST_GeometryFromText( 'POINT(10 70)', -1 ) ); | ||
- | INSERT INTO test VALUES ( 2, 'pieton2', ST_GeometryFromText( 'POINT(30 30)', -1 ) ); | ||
- | INSERT INTO test VALUES ( 6, 'pieton3', ST_GeometryFromText( 'POINT(35 70)', -1 ) ); | ||
- | INSERT INTO test VALUES ( 7, 'pieton4', ST_GeometryFromText( 'POINT(35 60)', -1 ) ); | ||
- | |||
- | INSERT INTO test VALUES ( 8, 'bordureRoute1', ST_GeometryFromText( 'LINESTRING(1 85,50 85)', -1 ) ); | ||
- | INSERT INTO test VALUES ( 9, 'bordureRoute2', ST_GeometryFromText( 'LINESTRING(1 92,50 92)', -1 ) ); | ||
- | </code> | ||
- | ===== Premiers pas ===== | ||
- | (-> cf. documentation [[http://postgis.net/docs/manual-2.0/reference.html|PostGIS Reference]]) | ||
- | - Quelles sont les aires des objets ? -> ST_Area2d<code>cf. 2</code> | ||
- | - Quel sont les types géométriques des objets ? -> Geometrytype<code>select genre, ST_Area2d(the_geom) from test where ST_GeometryType(the_geom) = 'ST_Polygon';</code> | ||
- | - Quel est l'objet géométrique le plus proche du pieton 2 ? -> ST_Distance<code>...</code> | ||
- | - Qui est dans le bâtiment 2 ? -> ST_Within<code>...</code> | ||
- | |||
- | //(source: [[http://www.davidgis.fr|Jean David Techer]])// |