wiki:Cookbook CCM21_Region

Version 3 (modified by celine, 15 years ago) (diff)

--

back to first page..
back to France departement

ALTER TABLE france.wso1 ALTER COLUMN area TYPE varchar(25)
--Ile de France
insert into france.wso1(wso_id) 
select distinct on (wso_id)  wso_id from ccm21.riversegments r
join (SELECT the_geom
    FROM france.region where code_reg='11') as sub
ON ST_Contains(sub.the_geom,r.the_geom); --170703 lines

UPDATE france.wso1 set area='IleDeFrance' where area IS NULL

--Champagne Ardenne
insert into france.wso1(wso_id) 
select distinct on (wso_id)  wso_id from ccm21.riversegments r
join (SELECT the_geom
    FROM france.region where code_reg='21') as sub
ON ST_Contains(sub.the_geom,r.the_geom); --170703 lines

UPDATE france.wso1 set area='ChampagneArdenne' where area IS NULL

--Picardie
insert into france.wso1(wso_id) 
select distinct on (wso_id)  wso_id from ccm21.riversegments r
join (SELECT the_geom
    FROM france.region where code_reg='22') as sub
ON ST_Contains(sub.the_geom,r.the_geom); --170703 lines

UPDATE france.wso1 set area='Picardie' where area IS NULL

--Haute-Normandie
insert into france.wso1(wso_id) 
select distinct on (wso_id)  wso_id from ccm21.riversegments r
join (SELECT the_geom
    FROM france.region where code_reg='23') as sub
ON ST_Contains(sub.the_geom,r.the_geom); --170703 lines

UPDATE france.wso1 set area='HauteNormandie' where area IS NULL

--Centre
insert into france.wso1(wso_id) 
select distinct on (wso_id)  wso_id from ccm21.riversegments r
join (SELECT the_geom
    FROM france.region where code_reg='24') as sub
ON ST_Contains(sub.the_geom,r.the_geom); --170703 lines

UPDATE france.wso1 set area='Centre' where area IS NULL

--BasseNormandie
insert into france.wso1(wso_id) 
select distinct on (wso_id)  wso_id from ccm21.riversegments r
join (SELECT the_geom
    FROM france.region where code_reg='25') as sub
ON ST_Contains(sub.the_geom,r.the_geom); --170703 lines

UPDATE france.wso1 set area='BasseNormandie' where area IS NULL

--Bourgogne
insert into france.wso1(wso_id) 
select distinct on (wso_id)  wso_id from ccm21.riversegments r
join (SELECT the_geom
    FROM france.region where code_reg='26') as sub
ON ST_Contains(sub.the_geom,r.the_geom); --170703 lines

UPDATE france.wso1 set area='Bourgogne' where area IS NULL

--Nord-Pas-de-Calais
insert into france.wso1(wso_id) 
select distinct on (wso_id)  wso_id from ccm21.riversegments r
join (SELECT the_geom
    FROM france.region where code_reg='31') as sub
ON ST_Contains(sub.the_geom,r.the_geom); --170703 lines

UPDATE france.wso1 set area='NordPasdeCalais' where area IS NULL

--Lorraine
insert into france.wso1(wso_id) 
select distinct on (wso_id)  wso_id from ccm21.riversegments r
join (SELECT the_geom
    FROM france.region where code_reg='41') as sub
ON ST_Contains(sub.the_geom,r.the_geom); --170703 lines

UPDATE france.wso1 set area='Lorraine' where area IS NULL


--Alsace
insert into france.wso1(wso_id) 
select distinct on (wso_id)  wso_id from ccm21.riversegments r
join (SELECT the_geom
    FROM france.region where code_reg='42') as sub
ON ST_Contains(sub.the_geom,r.the_geom); --170703 lines

UPDATE france.wso1 set area='Alsace' where area IS NULL

--Franche-Comté
insert into france.wso1(wso_id) 
select distinct on (wso_id)  wso_id from ccm21.riversegments r
join (SELECT the_geom
    FROM france.region where code_reg='43') as sub
ON ST_Contains(sub.the_geom,r.the_geom); --170703 lines

UPDATE france.wso1 set area='FrancheComte' where area IS NULL

--Pays-de-la-Loire
insert into france.wso1(wso_id) 
select distinct on (wso_id)  wso_id from ccm21.riversegments r
join (SELECT the_geom
    FROM france.region where code_reg='52') as sub
ON ST_Contains(sub.the_geom,r.the_geom); --170703 lines

UPDATE france.wso1 set area='PaysdelaLoire' where area IS NULL

--Bretagne
insert into france.wso1(wso_id) 
select distinct on (wso_id)  wso_id from ccm21.riversegments r
join (SELECT the_geom
    FROM france.region where code_reg='53') as sub
ON ST_Contains(sub.the_geom,r.the_geom); --170703 lines

UPDATE france.wso1 set area='Bretagne' where area IS NULL

--Poitou-Charentes
insert into france.wso1(wso_id) 
select distinct on (wso_id)  wso_id from ccm21.riversegments r
join (SELECT the_geom
    FROM france.region where code_reg='54') as sub
ON ST_Contains(sub.the_geom,r.the_geom); --170703 lines

UPDATE france.wso1 set area='PoitouCharentes' where area IS NULL

--Aquitaine
insert into france.wso1(wso_id) 
select distinct on (wso_id)  wso_id from ccm21.riversegments r
join (SELECT the_geom
    FROM france.region where code_reg='72') as sub
ON ST_Contains(sub.the_geom,r.the_geom); --170703 lines

UPDATE france.wso1 set area='Aquitaine' where area IS NULL

--Midi-Pyrénées
insert into france.wso1(wso_id) 
select distinct on (wso_id)  wso_id from ccm21.riversegments r
join (SELECT the_geom
    FROM france.region where code_reg='73') as sub
ON ST_Contains(sub.the_geom,r.the_geom); --170703 lines

UPDATE france.wso1 set area='MidiPyrenees' where area IS NULL

--Limousin
insert into france.wso1(wso_id) 
select distinct on (wso_id)  wso_id from ccm21.riversegments r
join (SELECT the_geom
    FROM france.region where code_reg='74') as sub
ON ST_Contains(sub.the_geom,r.the_geom); --170703 lines

UPDATE france.wso1 set area='Limousin' where area IS NULL

--Rhône-Alpes
insert into france.wso1(wso_id) 
select distinct on (wso_id)  wso_id from ccm21.riversegments r
join (SELECT the_geom
    FROM france.region where code_reg='82') as sub
ON ST_Contains(sub.the_geom,r.the_geom); --170703 lines

UPDATE france.wso1 set area='RhoneAlpes' where area IS NULL

--Auvergne
insert into france.wso1(wso_id) 
select distinct on (wso_id)  wso_id from ccm21.riversegments r
join (SELECT the_geom
    FROM france.region where code_reg='83') as sub
ON ST_Contains(sub.the_geom,r.the_geom); --170703 lines

UPDATE france.wso1 set area='Auvergne' where area IS NULL

--Languedoc-Roussillon
insert into france.wso1(wso_id) 
select distinct on (wso_id)  wso_id from ccm21.riversegments r
join (SELECT the_geom
    FROM france.region where code_reg='91') as sub
ON ST_Contains(sub.the_geom,r.the_geom); --170703 lines

UPDATE france.wso1 set area='Languedoc-Roussillon' where area IS NULL

--Provence Alpes Côte d'Azur
insert into france.wso1(wso_id) 
select distinct on (wso_id)  wso_id from ccm21.riversegments r
join (SELECT the_geom
    FROM france.region where code_reg='93') as sub
ON ST_Contains(sub.the_geom,r.the_geom); --170703 lines

UPDATE france.wso1 set area='PACA' where area IS NULL

--Corse
insert into france.wso1(wso_id) 
select distinct on (wso_id)  wso_id from ccm21.riversegments r
join (SELECT the_geom
    FROM france.region where code_reg='94') as sub
ON ST_Contains(sub.the_geom,r.the_geom); --170703 lines

UPDATE france.wso1 set area='Corse' where area IS NULL

Et c'est qu'une fois fini que tu te rends compte qu'il y avait un moyen plus rapide