Commit 63b82e99a45c9f714e2b96f1954645fc85f305f0
1 parent
e83a2116
Exists in
master
wip add id to file
Showing
1 changed file
with
81 additions
and
18 deletions
Show diff stats
notebook/zonal_stats.org
... | ... | @@ -14,37 +14,100 @@ import pandas as pd |
14 | 14 | |
15 | 15 | |
16 | 16 | * Simplification du fichier TERLAB |
17 | -- Eliminer les géométries qui ne contiennent pas d'information de rendement. | |
18 | -#+BEGIN_SRC bash | |
19 | -source /home/inglada/OTB/SuperBuild/config_otb_py3.5.sh | |
20 | -ogrinfo -sql "select COUNT(*) from SURFACES-2017-PARCELLES-GRAPHIQUES-CONSTATEES_031_20180210" /work/OT/theia/oso/shapes/TERLAB/ SURFACES-2017-PARCELLES-GRAPHIQUES-CONSTATEES_031_20180210.shp SURFACES-2017-PARCELLES-GRAPHIQUES-CONSTATEES_031_20180210 | |
17 | + Eliminer les géométries qui ne contiennent pas d'information de rendement. | |
18 | + | |
19 | +Combien de polygones en tout? | |
20 | +#+BEGIN_SRC bash :results output | |
21 | +source /work/OT/theia/oso/jordi/OTB/otb_superbuild/otb_superbuild-otb_develop-Release-install/config_otb_tf_py35.sh | |
22 | +ogrinfo -sql "select COUNT(*) from \"SURFACES-2017-PARCELLES-GRAPHIQUES-CONSTATEES_031_20180210\"" /work/OT/theia/oso/shapes/TERLAB/SURFACES-2017-PARCELLES-GRAPHIQUES-CONSTATEES_031_20180210.shp | |
23 | +#+END_SRC | |
24 | + | |
25 | +#+RESULTS: | |
26 | +#+begin_example | |
27 | +INFO: Open of `/work/OT/theia/oso/shapes/TERLAB/SURFACES-2017-PARCELLES-GRAPHIQUES-CONSTATEES_031_20180210.shp' | |
28 | + using driver `ESRI Shapefile' successful. | |
29 | + | |
30 | +Layer name: SURFACES-2017-PARCELLES-GRAPHIQUES-CONSTATEES_031_20180210 | |
31 | +Geometry: None | |
32 | +Feature Count: 1 | |
33 | +Layer SRS WKT: | |
34 | +(unknown) | |
35 | +COUNT_*: Integer (0.0) | |
36 | +OGRFeature(SURFACES-2017-PARCELLES-GRAPHIQUES-CONSTATEES_031_20180210):0 | |
37 | + COUNT_* (Integer) = 131246 | |
38 | + | |
39 | +#+end_example | |
40 | + | |
41 | +Combien contiennent du rendement? | |
42 | +#+BEGIN_SRC bash :results output | |
43 | +source /work/OT/theia/oso/jordi/OTB/otb_superbuild/otb_superbuild-otb_develop-Release-install/config_otb_tf_py35.sh | |
44 | +ogrinfo -sql "select COUNT(*) from \"SURFACES-2017-PARCELLES-GRAPHIQUES-CONSTATEES_031_20180210\" where RENDNORME > 0" /work/OT/theia/oso/shapes/TERLAB/SURFACES-2017-PARCELLES-GRAPHIQUES-CONSTATEES_031_20180210.shp | |
45 | +#+END_SRC | |
46 | + | |
47 | +#+RESULTS: | |
48 | +#+begin_example | |
49 | +INFO: Open of `/work/OT/theia/oso/shapes/TERLAB/SURFACES-2017-PARCELLES-GRAPHIQUES-CONSTATEES_031_20180210.shp' | |
50 | + using driver `ESRI Shapefile' successful. | |
51 | + | |
52 | +Layer name: SURFACES-2017-PARCELLES-GRAPHIQUES-CONSTATEES_031_20180210 | |
53 | +Geometry: None | |
54 | +Feature Count: 1 | |
55 | +Layer SRS WKT: | |
56 | +(unknown) | |
57 | +COUNT_*: Integer (0.0) | |
58 | +OGRFeature(SURFACES-2017-PARCELLES-GRAPHIQUES-CONSTATEES_031_20180210):0 | |
59 | + COUNT_* (Integer) = 4713 | |
60 | + | |
61 | +#+end_example | |
62 | + | |
63 | +Eliminer ceux qui n'en contiennent pas et créer un nouveau fichier | |
64 | +#+BEGIN_SRC bash :results output | |
65 | +source /work/OT/theia/oso/jordi/OTB/otb_superbuild/otb_superbuild-otb_develop-Release-install/config_otb_tf_py35.sh | |
66 | +ogr2ogr -sql "select * from \"SURFACES-2017-PARCELLES-GRAPHIQUES-CONSTATEES_031_20180210\" where RENDNORME > 0" -f SQLite /work/OT/theia/oso/shapes/TERLAB/terlab31_rend.shp /work/OT/theia/oso/shapes/TERLAB/SURFACES-2017-PARCELLES-GRAPHIQUES-CONSTATEES_031_20180210.shp | |
21 | 67 | #+END_SRC |
22 | 68 | |
23 | 69 | #+RESULTS: |
24 | 70 | |
25 | -#+BEGIN_SRC bash | |
26 | -ogr2ogr -sql "SELECT * FROM ne_50m_populated_places_simple WHERE featurecla IN ('Admin-1 capital', 'Admin-1 region capital')" ne_50m_pop_place_admin1_cap.shp ne_50m_populated_places_simple.shp | |
71 | +#+BEGIN_SRC bash :results output | |
72 | +source /work/OT/theia/oso/jordi/OTB/otb_superbuild/otb_superbuild-otb_develop-Release-install/config_otb_tf_py35.sh | |
73 | +ogrinfo -sql "select COUNT(*) from \"surfaces_2017_parcelles_graphiques_constatees_031_20180210\" where RENDNORME > 0" /work/OT/theia/oso/shapes/TERLAB/terlab31_rend.shp | |
27 | 74 | #+END_SRC |
28 | 75 | |
76 | +#+RESULTS: | |
77 | +#+begin_example | |
78 | +INFO: Open of `/work/OT/theia/oso/shapes/TERLAB/terlab31_rend.shp' | |
79 | + using driver `SQLite' successful. | |
80 | + | |
81 | +Layer name: SELECT | |
82 | +Geometry: None | |
83 | +Feature Count: 1 | |
84 | +Layer SRS WKT: | |
85 | +(unknown) | |
86 | +COUNT(*): Integer (0.0) | |
87 | +OGRFeature(SELECT):0 | |
88 | + COUNT(*) (Integer) = 4713 | |
89 | + | |
90 | +#+end_example | |
91 | + | |
92 | +Il faut faire attention au fait que les fichiers shx et prj n'existent pas pour le fichier qui ne contient que les polys de renement. Peut-être qu'il faut donner la projection pour le fichier généré par ogr2ogr? | |
93 | + | |
29 | 94 | * Génération des fichiers de stats zonales |
95 | +On pourrait commencer par ajouter un identifiant unique à chaque polygone du fichier TERLAB de façon à pouvoir faire le lien entre les différents fichiers de stats locales (reflectances, DEM, masques) générés à partir du même fichier TERLAB. | |
96 | + | |
97 | +[[file:/work/OT/theia/oso/jordi/src/maassp/jobs/addid.pbs]] | |
98 | + | |
99 | +[2019-02-05 Tue] le job add id tourne | |
100 | +*Attention* : j'ai dû modifier le script dans vectortools. Il vaudra mieux le copier ici. | |
101 | + | |
102 | + | |
30 | 103 | Le code est ici [[file:/work/OT/theia/oso/jordi/src/maassp/jobs/zonal_stats.pbs]] |
31 | 104 | |
105 | + | |
106 | +** A voir si cette partie sera nécessaire une fois que les polygones sans rendement sont éliminés. | |
32 | 107 | Comme l'image pour les stats zonales contient 720 bandes, le fichier vecteur contient > 720 * 4 attributs, ce qui dépasse le nb de colonnes dans un fichier sqlite. Le shapefile n'a pas ce problème, mais est limité à 4GB, ce qui est trop petit. |
33 | 108 | |
34 | 109 | J'ai ensuite séparé la série en 2 demi-séries pour pouvoir générer 2 shapefiles, mais on a ensuite le pb de faire le lien entre les polygones des 2 shapefiles générés, parce qu'on perd l'identifiant. |
35 | 110 | |
36 | -On pourrait commencer par ajouter un identifiant unique à chaque polygone du fichier TERLAB de façon à pouvoir faire le lien entre les différents fichiers de stats locales (reflectances, DEM, masques) générés à partir du même fichier TERLAB. | |
37 | - | |
38 | -#+begin_src bash :results output :exports code | |
39 | -export ${iota2dir}= | |
40 | -export terlabdir='/work/OT/theia/oso/shapes/TERLAB/' | |
41 | -export terlab31=${terlabdir}'SURFACES-2017-PARCELLES-GRAPHIQUES-CONSTATEES_031_20180210' | |
42 | -cp ${terlab31}.shp ${terlabdir}'terlab31.shp' | |
43 | -cp ${terlab31}.dbf ${terlabdir}'terlab31.dbf' | |
44 | -cp ${terlab31}.shx ${terlabdir}'terlab31.shx' | |
45 | -cp ${terlab31}.prj ${terlabdir}'terlab31.prj' | |
46 | -python ${iota2dir}/scripts/VectorTools/AddFieldID.py ${terlabdir}'terlab31.shp' | |
47 | -#+end_src | |
48 | 111 | |
49 | 112 | |
50 | 113 | * Import des fichiers dans des DF | ... | ... |