-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFSTD_DrainDensity.tcl
More file actions
98 lines (74 loc) · 2.82 KB
/
Copy pathFSTD_DrainDensity.tcl
File metadata and controls
98 lines (74 loc) · 2.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/sh
# the next line restarts using tclsh \
exec $SPI_PATH/tclsh "$0" "$@"
#============================================================================
# Environnement Canada
# Centre Meteorologique Canadien
# 2100 Trans-Canadienne
# Dorval, Quebec
#
# Projet : Exemple de scripts.
# Fichier : FSTD_DarinDensity.tcl
# Creation : Mars 2007 - J.P. Gauthier - CMC/CMOE
# Description: Calcule la densite de drainage sur une grille RPN en utilisant
# des donnees vectorielles de lacs et rivieres (Shapefile)
#
# somme(longueur cours d'eau) + somme(périmètre étendues d'eau) DD
# -------------------------------------------------------------
# aire de la maille - aire des étendues d'eau
#
# Parametres :
#
# Retour:
#
# Remarques :
#
#============================================================================
package require TclData
#package require TclGeoEER
package require Logger
Log::Start [info script] 0.1
#----- Ouvrir les fichiers d'entree et de sortie
catch { file delete -force $env(CI_DATA_OUT)/FSTD_DrainDensity.fstd }
fstdfile open FSTDOUT write $env(CI_DATA_OUT)/FSTD_DrainDensity.fstd
fstdfile open FSTDIN read $env(CI_DATA_IN)/noire.fst
#----- Copier les TIC TAC
fstdfield read TIC FSTDIN -1 "" -1 -1 -1 "" ">>"
fstdfield read TAC FSTDIN -1 "" -1 -1 -1 "" "^^"
fstdfield write TIC FSTDOUT -32 False
fstdfield write TAC FSTDOUT -32 False
#----- Lire le champs de la grille de calcul
fstdfield read FLD FSTDIN -1 "" -1 -1 -1 "" "ELEV"
#----- Creer les champs de calculs
vexpr FLD FLD<<0
vexpr RIVERSUM FLD<<0
vexpr LAKESUM FLD<<0
vexpr LAKEAREA FLD<<0
vexpr MASK FLD<<0
#----- Lire la donnee des rivieres
set layers [ogrfile open FILE1 read $env(CI_DATA_IN)/noire_lines.shp]
ogrlayer read LINES FILE1 0
#----- Lire la donnee des lacs
set layers [ogrfile open FILE2 read $env(CI_DATA_IN)/noire_areas.shp]
ogrlayer read AREAS FILE2 0
#----- Lire la donnee du bassin (masque)
set layers [ogrfile open FILE3 read $env(CI_DATA_IN)/noire_sousbasssins.shp]
ogrlayer read BASSIN FILE3 0
#----- Interpolation (rasterisation) selon les longueurs et couvertures
fstdfield gridinterp RIVERSUM LINES LENGTH_CONSERVATIVE FEATURE_LENGTH
fstdfield gridinterp LAKESUM AREAS LENGTH_CONSERVATIVE FEATURE_LENGTH
fstdfield gridinterp LAKEAREA AREAS CONSERVATIVE FEATURE_AREA
fstdfield gridinterp MASK BASSIN FAST
#----- Effectuer le calculs de drainage
vexpr FLD ifelse(MASK,(RIVERSUM+LAKESUM)/(darea(FLD)-LAKEAREA),0)
#----- Sauvagerdons le tout
fstdfield define FLD -NOMVAR DRN
fstdfield write FLD FSTDOUT -32 False
fstdfield define RIVERSUM -NOMVAR RSUM
fstdfield write RIVERSUM FSTDOUT -32 False
fstdfield define LAKESUM -NOMVAR LSUM
fstdfield write LAKESUM FSTDOUT -32 False
fstdfield define LAKEAREA -NOMVAR LARE
fstdfield write LAKEAREA FSTDOUT -32 False
fstdfile close FSTDIN FSTDOUT
Log::End