1 | | back to first page ![..][[BR]] |
2 | | back to !["CookBook Eda"] [[BR]] |
3 | | |
4 | | ["RStudio"] at Irstea [[BR]] |
5 | | |
6 | | ![[Image(source:data/Docs/trac/pourc_projette.jpg)]] |
7 | | |
8 | | ![[Image(source:data/Docs/trac/barrages_cutfrance.png,600px)]] |
9 | | |
10 | | See the ticket !#45 |
11 | | |
12 | | ![[Color(,#3849ce,source)]] |
13 | | |
14 | | ![[Freemind(htdocs://site/reunion7janv.mm)]] |
15 | | |
16 | | !source:"data/Docs/trac/POSE/SWOT in Pose.mm" |
17 | | or "Attach file" en bas de la page |
18 | | |
19 | | Size limit to attach a file : 256KB --> give the name of the folder where we can find the file.[[BR]] |
20 | | !source:"data/Docs/trac/POSE/" |
21 | | |
22 | | !{{{ |
23 | | !#!html |
24 | | !<h2 style="color: orange">This is raw HTML</h2> |
25 | | !}}} |
26 | | {{{ |
27 | | #!html |
28 | | <h2 style="color: orange">This is raw HTML</h2> |
29 | | }}} |
30 | | |
31 | | |
32 | | http://trac.edgewall.org/wiki/WikiFormatting |
33 | | |
34 | | == Eclipse == |
35 | | * Problem with the port http://lists.r-forge.r-project.org/pipermail/statet-user/2010-September/000531.html |
36 | | Window > Preferences > StatET > Run/Debug > R Interaction > Advanced Options and change the port |
37 | | |
38 | | == Postgre == |
39 | | |
40 | | New version with ST_HausdorffDistance see http://docs.postgresqlfr.org/8.1/migration.html [[BR]] |
41 | | {{{ |
42 | | SELECT version(); |
43 | | select postgis_full_version(); |
44 | | select PostGIS_version(); |
45 | | }}} |
46 | | SRID ["srid"] |
47 | | {{{ |
48 | | #!sql |
49 | | select * from spatial_ref_sys where srtext LIKE '%NTF%'; |
50 | | }}} |
51 | | |
52 | | ["Geometry functions"] [[BR]] |
53 | | http://blogs.msdn.com/b/davidlean/archive/2008/10/24/sql-20008-spatial-samples-part-n-of-n-conditional-methods.aspx [[BR]] |
54 | | |
55 | | {{{ |
56 | | #!sql |
57 | | --- Nombre de colonnes dans une table |
58 | | select relnatts from pg_class where relname='stationsp2' |
59 | | }}} |
60 | | |
61 | | Les données sont dans C:\Celine Jouanin\dataPostgreSQL\pg_log (pour les erreurs) [[BR]] |
62 | | |
63 | | {{{ |
64 | | C:\Documents and Settings\cedric.briand>C:\"Program Files"\PostgreSQL\9.0\bin\pgsql2shp -f "F:\IAV\eda\oria\export shape" -h 192.168.1.104 -p 5432 -u postgres -P petromyzon*** -g the_geom -r -k eda2 oria.obstacles_biskaia |
65 | | }}} |
66 | | |
67 | | {{{ |
68 | | cd C:\Program Files\PostgreSQL\8.4\bin\ |
69 | | pg_restore.exe --host localhost --port 5432 --username postgres --dbname "ccm21" --verbose "C:\CelineJouanin\riversegments.backup" |
70 | | }}} |
71 | | {{{ |
72 | | --supprimer la table puis : |
73 | | d: |
74 | | --repertoire ou a été mis le fichier |
75 | | cd D:\CelineJouanin\CCM21 |
76 | | C:\"Program Files"\PostgreSQL\8.4\bin\psql -U postgres --dbname "eda2.0" -f "riversegments_backup_fulldistsource.sql" |
77 | | }}} |
78 | | How to save only a table - backup |
79 | | {{{ |
80 | | C:\"Program Files"\PostgreSQL\8.4\bin\pg_dump -U postgres -p 5432 -t ccm21.riversegments eda2.0> riversegments_backup.sql |
81 | | |
82 | | C:\"Program Files"\PostgreSQL\8.4\bin\pg_dump -U postgres -p 5432 --inserts -t ccm21.catchments eda2.0> catchments_backup.sql |
83 | | }}} |
84 | | How to save a schema |
85 | | {{{ |
86 | | C:\"Program Files"\PostgreSQL\8.4\bin\pg_dump -U postgres -p 5432 --schema clc --verbose eda2.0> eda2_clc.sql |
87 | | }}} |
88 | | How to save several schema |
89 | | {{{ |
90 | | pg_dump -h 192.168.1.104 -U postgres --verbose --schema barlbr --schema shp --schema result --schema public --schema geobs --schema archive --file "barrage_vilaine_partiel_9012012.sql" barrage_vilaine |
91 | | |
92 | | pg_dump -h 192.168.1.104 -U postgres --verbose --exclude-schema barlbr --exclude-schema shp --exclude-schema result --exclude-schema public --exclude-schema geobs --exclude-schema archive --file "barrage_vilaine_autres_9012012.sql" barrage_vilaine |
93 | | }}} |
94 | | |
95 | | |
96 | | * Intégration d'une colonne géométrique |
97 | | {{{ |
98 | | #!sql |
99 | | SELECT AddGeometryColumn ( 'rht','attributs_rht_fev_2011_vs2','the_geom',3035,'MULTILINESTRING',2); |
100 | | update rht.attributs_rht_fev_2011_vs2 set the_geom=rht.the_geom from rht.rht |
101 | | where rht.id_drain=attributs_rht_fev_2011_vs2.id_drain; |
102 | | }}} |
103 | | |
104 | | * Add a primary key |
105 | | {{{ |
106 | | #!sql |
107 | | ALTER TABLE ccm21.riversegments ADD CONSTRAINT riversegments_pkey PRIMARY KEY (gid); |
108 | | }}} |
109 | | |
110 | | * Drop a primary key |
111 | | {{{ |
112 | | #!sql |
113 | | ALTER TABLE ccm21.riversegments DROP CONSTRAINT riversegments_pkey; |
114 | | }}} |
115 | | * Change the srid into 3035 (ETRS1989 LAEA) |
116 | | {{{ |
117 | | #!sql |
118 | | ALTER TABLE uga2010.uga DROP CONSTRAINT enforce_srid_the_geom; |
119 | | UPDATE uga2010.uga SET the_geom = ST_transform(the_geom, 3035); |
120 | | ALTER TABLE uga2010.uga ADD CONSTRAINT enforce_srid_the_geom CHECK (st_srid(the_geom) = 3035); |
121 | | }}} |
122 | | |
123 | | * Create view of a query |
124 | | {{{ |
125 | | #!sql |
126 | | CREATE VIEW results AS select * from ccm21.riversegments r inner join ccm21.resultmodel re on re.res_wso1_id=r.wso1_id |
127 | | }}} |
128 | | |
129 | | * Sequence |
130 | | {{{ |
131 | | #!sql |
132 | | ALTER SEQUENCE rht.model_mod_mod_id_seq RESTART WITH 2; |
133 | | }}} |
134 | | |
135 | | --- Riversegments |
136 | | |
137 | | {{{ |
138 | | #!sql |
139 | | DROP INDEX IF EXISTS ccm21.indexriversegments_wso1_id; |
140 | | CREATE INDEX indexriversegments_wso1_id |
141 | | ON ccm21.riversegments |
142 | | USING btree (wso1_id); |
143 | | |
144 | | -- ALTER TABLE ccm21.riversegments1 DROP CONSTRAINT enforce_dims_the_geom; |
145 | | ALTER TABLE ccm21.riversegments ADD CONSTRAINT enforce_dims_the_geom CHECK (st_ndims(the_geom) = 2); |
146 | | -- ALTER TABLE ccm21.riversegments1 DROP CONSTRAINT enforce_geotype_the_geom; |
147 | | ALTER TABLE ccm21.riversegments ADD CONSTRAINT enforce_geotype_the_geom CHECK (geometrytype(the_geom) = 'MULTILINESTRING'::text OR the_geom IS NULL); |
148 | | -- ALTER TABLE ccm21.riversegments1 DROP CONSTRAINT enforce_srid_the_geom; |
149 | | ALTER TABLE ccm21.riversegments ADD CONSTRAINT enforce_srid_the_geom CHECK (st_srid(the_geom) = 3035); |
150 | | -- ALTER TABLE ccm21.riversegments DROP CONSTRAINT riversegments_pkey; |
151 | | ALTER TABLE ccm21.riversegments ADD CONSTRAINT riversegments_pkey PRIMARY KEY(gid); |
152 | | }}} |
153 | | |
154 | | Sauvegarde tables CLC |
155 | | {{{ |
156 | | C:\"Program Files"\PostgreSQL\8.4\bin\pg_dump -U postgres -p 5432 -t clc.clc00_v2_bretagne eda2.0> clc00_v2_bretagne_backup.sql |
157 | | C:\"Program Files"\PostgreSQL\8.4\bin\pg_dump -U postgres -p 5432 -t clc.clc00_v2_europe eda2.0> clc00_v2_europe_backup.sql |
158 | | C:\"Program Files"\PostgreSQL\8.4\bin\pg_dump -U postgres -p 5432 -t clc.clc06_fr_l2e eda2.0> clc06_fr_l2e_backup.sql |
159 | | C:\"Program Files"\PostgreSQL\8.4\bin\pg_dump -U postgres -p 5432 -t clc.clipped eda2.0> clipped.sql |
160 | | C:\"Program Files"\PostgreSQL\8.4\bin\pg_dump -U postgres -p 5432 -t clc.clipped1 eda2.0> clipped1.sql |
161 | | C:\"Program Files"\PostgreSQL\8.4\bin\pg_dump -U postgres -p 5432 -t clc.clipped_anglian eda2.0> clipped_anglian.sql |
162 | | C:\"Program Files"\PostgreSQL\8.4\bin\pg_dump -U postgres -p 5432 -t clc.clipped_anglian1 eda2.0> clipped_anglian1.sql |
163 | | C:\"Program Files"\PostgreSQL\8.4\bin\pg_dump -U postgres -p 5432 -t clc.clipped_bretagne eda2.0> clipped_bretagne.sql |
164 | | C:\"Program Files"\PostgreSQL\8.4\bin\pg_dump -U postgres -p 5432 -t clc.clipped_bretagne1 eda2.0> clipped_bretagne1.sql |
165 | | C:\"Program Files"\PostgreSQL\8.4\bin\pg_dump -U postgres -p 5432 -t clc.surf_area eda2.0> surface_area.sql |
166 | | C:\"Program Files"\PostgreSQL\8.4\bin\pg_dump -U postgres -p 5432 -t clc.surf_area1_bretagne eda2.0> surface_area1_bretagne.sql |
167 | | C:\"Program Files"\PostgreSQL\8.4\bin\pg_dump -U postgres -p 5432 -t clc.surf_area_analyse eda2.0> surface_area_analyse.sql |
168 | | C:\"Program Files"\PostgreSQL\8.4\bin\pg_dump -U postgres -p 5432 -t clc.surf_area_anglian eda2.0> surface_area_anglian.sql |
169 | | C:\"Program Files"\PostgreSQL\8.4\bin\pg_dump -U postgres -p 5432 -t clc.surf_area_anglian_final eda2.0> surface_area_anglian_final.sql |
170 | | C:\"Program Files"\PostgreSQL\8.4\bin\pg_dump -U postgres -p 5432 -t clc.surf_area_bretagne eda2.0> surface_area_bretagne.sql |
171 | | C:\"Program Files"\PostgreSQL\8.4\bin\pg_dump -U postgres -p 5432 -t clc.surf_area_final eda2.0> surface_area_final.sql |
172 | | C:\"Program Files"\PostgreSQL\8.4\bin\pg_dump -U postgres -p 5432 -t clc.surf_area_final2 eda2.0> surface_area_final2.sql |
173 | | C:\"Program Files"\PostgreSQL\8.4\bin\pg_dump -U postgres -p 5432 -t clc.surf_area_final_spain eda2.0> surface_area_final_spain.sql |
174 | | C:\"Program Files"\PostgreSQL\8.4\bin\pg_dump -U postgres -p 5432 -t clc.remaining_catchment eda2.0> remaining_catchment.sql |
175 | | |
176 | | }}} |
177 | | {{{ |
178 | | select wso_id, area from france.wso f where area='France' except (select wso_id, area from europe.wso where area='France') |
179 | | }}} |
180 | | |
181 | | Permet connaitre id_drain qui n'a pas d'attribut |
182 | | {{{ |
183 | | #!sql |
184 | | select * from rht.rht where id_drain not in (select id_drain from rht.rht right outer join rht.attributs_rht_fev_2011 on id_drain=id_drainattr) |
185 | | }}} |