Changes between Version 1 and Version 2 of CookBook Eda


Ignore:
Timestamp:
Jan 22, 2010 3:26:37 PM (15 years ago)
Author:
cedric
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • CookBook Eda

    v1 v2  
    33In this section we will report "how to" procedures to do the differents tasks in EDA 
    44 
    5 == How to create a postgres database from a shape file" 
     5== How to create a postgres database from a shape file" PostgresSQl 8.4 == 
    66 
    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 
     7The following example applies to the creation of a database from the CCM 
     8 
     9[http://www.bostongis.com/?content_name=postgis_tut01] 
     10is 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 
     17In 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 === 
     22We'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.  
     23Open up your PgAdmin III query tool and type in the following statement, use the green arrow to launch the command 
     24 {{{ 
     25select srid, srtext, proj4text from spatial_ref_sys where srtext ILIKE '%ETRS89%'; 
     26}}} 
     27Now 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 ===  
     29Open a command batch > execute> cmd 
     30Change directory to get to the working directory where the shapes are stored 
     31example : 
    932 {{{ 
    1033cd C:\Documents and Settings\cedric\Mes documents\Migrateur\eda\w2000a18 
    1134}}} 
    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 
     35The program shp2pqsql installed along postgris allows to transform from shape to .sql 
     36type in  
     37 {{{ 
     38C:\program files\postgres\8.4\bin\shp2pgsql -s 3035 COAST coast > coast.sql 
     39}}} 
     40The file will be created at ''C:\program files\postgres\8.4\bin\shp2pgsql'' 
     41to create the coast.sql file from the COAST shape file 
     42warning these files are very big and won't open in pgAdmin, use the command batch to lauch the sql file 
     43{{{ 
     44C:\program files\postgres\8.4\bin\psql -d CCM -h localhost -U postgres -f catchment_w.sql  
     45}}} 
     46where: -d database -h host -U user -f the sql file. 
     47Check at the end of the process if the database is created 
    1948 
    20  
    21 C:\PostgresPlus\8.3\bin\psql -d CCM -h localhost -U postgres -f catchment_w.sql