Skip to content

Instantly share code, notes, and snippets.

@cquest
Created April 8, 2024 11:56
Show Gist options
  • Save cquest/dbceea993b1a5a8ca59353cbcf318b26 to your computer and use it in GitHub Desktop.
Save cquest/dbceea993b1a5a8ca59353cbcf318b26 to your computer and use it in GitHub Desktop.
Import données SIM2 météo-france dans postgresql
#! /bin/bash
# scrip d'import des données SIM2 (sim2/ISBA) dans postgresql
psql -c "
create table sim2 (LAMBX int,LAMBY int,DATE varchar,PRENEI_Q float,PRELIQ_Q float,T_Q float,FF_Q float,Q_Q float, DLI_Q float, SSI_Q float,HU_Q float,EVAP_Q float,ETP_Q float,PE_Q float,SWI_Q float,DRAINC_Q float,RUNC_Q float,RESR_NEIGE_Q float,RESR_NEIGE6_Q float, HTEURNEIGE_Q float, HTEURNEIGE6_Q float, HTEURNEIGEX_Q float, SNOW_FRAC_Q float, ECOULEMENT_Q float, WG_RACINE_Q float, WGI_RACINE_Q float, TINF_H_Q float, TSUP_H_Q float);"
create table sim2_grid (lambx int, lamby int, lat varchar, lon varchar);
\copy sim2_grid from 'coordonnees_grille_sim2_lambert-2-etendu.csv' with (format csv, header true, delimiter ';');
alter table sim2_grid add geom geometry(point,4326) ;
update sim2_grid set geom = st_makepoint(replace(lon,',','.')::numeric, replace(lat,',','.')::numeric);
create index sim2_grid_geom on sim2_grid using gist(geom);
"
for F in QUOT_SIM2*.csv;
do echo $F;
psql -c "\copy sim2 from $F with (format csv, header true, delimiter ';');"
done
psql -c " CREATE INDEX sim2_date on sim2 (date); " &
psql -c " CREATE INDEX sim2_geo_date on sim2 (lambx,lamby,date); " &
wait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment