7 | | Il faut d'abord ouvrir un batch de commande exécuter> cmd |
8 | | Changer de répertoire de travail pour atteindre le fichier à importer |
| 7 | The following example applies to the creation of a database from the CCM |
| 8 | |
| 9 | [http://www.bostongis.com/?content_name=postgis_tut01] |
| 10 | is the usefull to read next if the following does not work |
| 11 | |
| 12 | === 1- Install postgres and postgis === |
| 13 | (Use stack builder application in postgres command menu) |
| 14 | |
| 15 | === 2- create database CCM === |
| 16 | |
| 17 | In PgAdmin, connect to the serveur |
| 18 | right clic, create new database, use template postgis to that the database is a geodatabase |
| 19 | [[Image(source:EDA/data/Docs/trac/PgAmin_create_gis_database.jpg)]] |
| 20 | |
| 21 | === 3- Figure out SRID of the data === |
| 22 | We'll need to match this descriptive projection to an SRID (the id field of a spatial ref record in the spatial_ref_sys table) if we ever want to reproject our data. |
| 23 | Open up your PgAdmin III query tool and type in the following statement, use the green arrow to launch the command |
| 24 | {{{ |
| 25 | select srid, srtext, proj4text from spatial_ref_sys where srtext ILIKE '%ETRS89%'; |
| 26 | }}} |
| 27 | Now we have to find the good line, it seems to be srid='3035' since it refers to the Eu system and equal area |
| 28 | === 4- Create sql database === |
| 29 | Open a command batch > execute> cmd |
| 30 | Change directory to get to the working directory where the shapes are stored |
| 31 | example : |
12 | | Dans PgAdmin, se connecter au serveur |
13 | | > clic droit creation d'une base de donnee |
14 | | PgAmin_create_gis_database.jpg |
15 | | #* à partir du programme shp2pqsql création d'un fichier sql (ci dessous un exemple) |
16 | | C:\PostgresPlus\8.3\bin\shp2pgsql -? |
17 | | C:\PostgresPlus\8.3\bin\shp2pgsql -s 26986 TOWNS_POLY towns > towns.sql |
18 | | C:\PostgresPlus\8.3\bin\shp2pgsql -s 3035 CATCHMENT_W catchment_w > catchment_w.sql |
| 35 | The program shp2pqsql installed along postgris allows to transform from shape to .sql |
| 36 | type in |
| 37 | {{{ |
| 38 | C:\program files\postgres\8.4\bin\shp2pgsql -s 3035 COAST coast > coast.sql |
| 39 | }}} |
| 40 | The file will be created at ''C:\program files\postgres\8.4\bin\shp2pgsql'' |
| 41 | to create the coast.sql file from the COAST shape file |
| 42 | warning these files are very big and won't open in pgAdmin, use the command batch to lauch the sql file |
| 43 | {{{ |
| 44 | C:\program files\postgres\8.4\bin\psql -d CCM -h localhost -U postgres -f catchment_w.sql |
| 45 | }}} |
| 46 | where: -d database -h host -U user -f the sql file. |
| 47 | Check at the end of the process if the database is created |