Commit 3ae3dbd501ea60591f2a4fec1214f3efbfd140bc

Authored by Jordi Inglada
1 parent 4ecbec2d
Exists in master

exploration des jointures

Showing 1 changed file with 466 additions and 1823 deletions   Show diff stats
notebook/zonal_stats.org
... ... @@ -6,17 +6,35 @@
6 6  
7 7 Petit bout de python vide pour initialiser la session. Ca permet d'avoir la version de python utilisée
8 8 #+begin_src python :results output :session :exports code
  9 +import geopandas as gp
  10 +import pandas as pd
9 11 #+end_src
10 12  
11 13 #+RESULTS:
12   -: Python 3.7.1 (default, Oct 23 2018, 19:19:42)
13   -: [GCC 7.3.0] :: Anaconda, Inc. on linux
14   -: Type "help", "copyright", "credits" or "license" for more information.
15   -: >>> python.el: native completion setup loaded
16 14  
17 15  
18 16 * Import des fichiers dans des DF
19 17  
  18 +Le fichier TERLAB qui contient le dept 31 est:
  19 +
  20 +#+begin_src python :results output :session :exports code
  21 +terlabdir = '/work/OT/theia/oso/shapes/TERLAB/'
  22 +terlab31 = terlabdir+'SURFACES-2017-PARCELLES-GRAPHIQUES-CONSTATEES_031_20180210.shp'
  23 +df_terlab = gp.read_file(terlab31)
  24 +print(df_terlab.head())
  25 +#+end_src
  26 +
  27 +#+RESULTS:
  28 +: CODE_CULTU SURF_ADM PRECISION SEMENCE DEST_ICHN CULTURE_D1 CULTURE_D2 ... TLENQ CODUTISOL LIBCULTURE SURUTISOL RENDNORME MMEAU geometry
  29 +: 0 ORH 1.42 None 0 None None None ... 1 03 03_ORGE_HIVER NaN NaN NaN POLYGON ((506016.382600002 6234988.195600003, ...
  30 +: 1 PPH 0.00 None 0 None None None ... 0 00 00_XXXXXXXXXX NaN NaN NaN POLYGON ((506032.0680000037 6235002.251000002,...
  31 +: 2 PPH 0.00 None 0 None None None ... 0 00 00_XXXXXXXXXX NaN NaN NaN POLYGON ((506108.3540000021 6234766.824000001,...
  32 +: 3 ORH 1.87 None 0 None None None ... 1 03 03_ORGE_HIVER NaN NaN NaN POLYGON ((506107.6996000037 6234765.226100001,...
  33 +: 4 PPH 0.00 None 0 None None None ... 0 00 00_XXXXXXXXXX NaN NaN NaN POLYGON ((506874.6119000018 6234495.103300001,...
  34 +:
  35 +: [5 rows x 18 columns]
  36 +
  37 +
20 38 Les fichiers shape avec les stats sont
21 39  
22 40 #+begin_src python :results none :session :exports code
... ... @@ -30,10 +48,9 @@ zs_mask=zs_dir+'/zonal_stats_mask.shp'
30 48 Lire les fichiers dans un DF pandas
31 49  
32 50 #+begin_src python :results output :session :exports code
33   -import geopandas as gp
34 51 df_rf1 = gp.read_file(zs_rf1)
35 52 df_rf2 = gp.read_file(zs_rf2)
36   -df_dem = gp.read_file(zs_dem)
  53 +df_dem = gp.read_file(zs_dem).to_crs
37 54 df_mask = gp.read_file(zs_mask)
38 55 print(len(df_rf1))
39 56 print(len(df_rf2))
... ... @@ -49,1852 +66,478 @@ print(len(df_mask))
49 66  
50 67 Il paraît que le fichier de DEM a perdu quelques polygones?
51 68  
52   -* Fusion dans un seul DF
  69 +Vérification des projections :
53 70  
54   -On utilise overlay avec intersection
  71 +#+begin_src python :results output :session :exports code
  72 +print(df_dem.crs)
  73 +print(df_mask.crs)
  74 +print(df_rf1.crs)
  75 +print(df_rf1.crs)
  76 +#+end_src
  77 +
  78 +#+RESULTS:
  79 +: {'init': 'epsg:32631'}
  80 +: {'init': 'epsg:2154'}
  81 +: {'init': 'epsg:2154'}
  82 +: {'init': 'epsg:2154'}
  83 +
  84 +Reprojection du DEM
55 85  
56 86 #+begin_src python :results output :session :exports code
57   -res_intersection = gp.overlay(df_rf1, df_mask, how='identity')
  87 +df_dem = df_dem.to_crs(df_mask.crs)
  88 +print(df_dem.crs)
58 89 #+end_src
59 90  
60 91 #+RESULTS:
  92 +: {'init': 'epsg:2154'}
  93 +
  94 +
  95 +* Fusion dans un seul DF
61 96  
62 97 #+begin_src python :results output :session :exports code
63   -print(len(df_rf1.columns))
64   -print(len(df_mask.columns))
65   -print(len(res_intersection.columns))
  98 +for c in df_terlab.columns:
  99 + print(c)
66 100 #+end_src
67 101  
68 102 #+RESULTS:
69   -: 1446
70   -: 298
71   -: 1743
  103 +#+begin_example
  104 +CODE_CULTU
  105 +SURF_ADM
  106 +PRECISION
  107 +SEMENCE
  108 +DEST_ICHN
  109 +CULTURE_D1
  110 +CULTURE_D2
  111 +BIO
  112 +ENGAGEMENT
  113 +MARAICHAGE
  114 +AGROFOREST
  115 +TLENQ
  116 +CODUTISOL
  117 +LIBCULTURE
  118 +SURUTISOL
  119 +RENDNORME
  120 +MMEAU
  121 +geometry
  122 +#+end_example
72 123  
73   -Pandas renomme les colonnes qui ont le mm nom dans les 2 DF
74 124 #+begin_src python :results output :session :exports code
75   -for c in res_intersection.columns:
  125 +for c in df_mask.columns:
76 126 print(c)
77 127 #+end_src
78 128  
79 129 #+RESULTS:
80 130 #+begin_example
81   -CODE_CULTU_1
82   -SURF_ADM_1
83   -SEMENCE_1
84   -BIO_1
85   -MARAICHAGE_1
86   -TLENQ_1
87   -CODUTISOL_1
88   -LIBCULTURE_1
89   -count_1
90   -mean_0_1
91   -stdev_0_1
92   -min_0_1
93   -max_0_1
94   -mean_1_1
95   -stdev_1_1
96   -min_1_1
97   -max_1_1
98   -mean_2_1
99   -stdev_2_1
100   -min_2_1
101   -max_2_1
102   -mean_3_1
103   -stdev_3_1
104   -min_3_1
105   -max_3_1
106   -mean_4_1
107   -stdev_4_1
108   -min_4_1
109   -max_4_1
110   -mean_5_1
111   -stdev_5_1
112   -min_5_1
113   -max_5_1
114   -mean_6_1
115   -stdev_6_1
116   -min_6_1
117   -max_6_1
118   -mean_7_1
119   -stdev_7_1
120   -min_7_1
121   -max_7_1
122   -mean_8_1
123   -stdev_8_1
124   -min_8_1
125   -max_8_1
126   -mean_9_1
127   -stdev_9_1
128   -min_9_1
129   -max_9_1
130   -mean_10_1
131   -stdev_10_1
132   -min_10_1
133   -max_10_1
134   -mean_11_1
135   -stdev_11_1
136   -min_11_1
137   -max_11_1
138   -mean_12_1
139   -stdev_12_1
140   -min_12_1
141   -max_12_1
142   -mean_13_1
143   -stdev_13_1
144   -min_13_1
145   -max_13_1
146   -mean_14_1
147   -stdev_14_1
148   -min_14_1
149   -max_14_1
150   -mean_15_1
151   -stdev_15_1
152   -min_15_1
153   -max_15_1
154   -mean_16_1
155   -stdev_16_1
156   -min_16_1
157   -max_16_1
158   -mean_17_1
159   -stdev_17_1
160   -min_17_1
161   -max_17_1
162   -mean_18_1
163   -stdev_18_1
164   -min_18_1
165   -max_18_1
166   -mean_19_1
167   -stdev_19_1
168   -min_19_1
169   -max_19_1
170   -mean_20_1
171   -stdev_20_1
172   -min_20_1
173   -max_20_1
174   -mean_21_1
175   -stdev_21_1
176   -min_21_1
177   -max_21_1
178   -mean_22_1
179   -stdev_22_1
180   -min_22_1
181   -max_22_1
182   -mean_23_1
183   -stdev_23_1
184   -min_23_1
185   -max_23_1
186   -mean_24_1
187   -stdev_24_1
188   -min_24_1
189   -max_24_1
190   -mean_25_1
191   -stdev_25_1
192   -min_25_1
193   -max_25_1
194   -mean_26_1
195   -stdev_26_1
196   -min_26_1
197   -max_26_1
198   -mean_27_1
199   -stdev_27_1
200   -min_27_1
201   -max_27_1
202   -mean_28_1
203   -stdev_28_1
204   -min_28_1
205   -max_28_1
206   -mean_29_1
207   -stdev_29_1
208   -min_29_1
209   -max_29_1
210   -mean_30_1
211   -stdev_30_1
212   -min_30_1
213   -max_30_1
214   -mean_31_1
215   -stdev_31_1
216   -min_31_1
217   -max_31_1
218   -mean_32_1
219   -stdev_32_1
220   -min_32_1
221   -max_32_1
222   -mean_33_1
223   -stdev_33_1
224   -min_33_1
225   -max_33_1
226   -mean_34_1
227   -stdev_34_1
228   -min_34_1
229   -max_34_1
230   -mean_35_1
231   -stdev_35_1
232   -min_35_1
233   -max_35_1
234   -mean_36_1
235   -stdev_36_1
236   -min_36_1
237   -max_36_1
238   -mean_37_1
239   -stdev_37_1
240   -min_37_1
241   -max_37_1
242   -mean_38_1
243   -stdev_38_1
244   -min_38_1
245   -max_38_1
246   -mean_39_1
247   -stdev_39_1
248   -min_39_1
249   -max_39_1
250   -mean_40_1
251   -stdev_40_1
252   -min_40_1
253   -max_40_1
254   -mean_41_1
255   -stdev_41_1
256   -min_41_1
257   -max_41_1
258   -mean_42_1
259   -stdev_42_1
260   -min_42_1
261   -max_42_1
262   -mean_43_1
263   -stdev_43_1
264   -min_43_1
265   -max_43_1
266   -mean_44_1
267   -stdev_44_1
268   -min_44_1
269   -max_44_1
270   -mean_45_1
271   -stdev_45_1
272   -min_45_1
273   -max_45_1
274   -mean_46_1
275   -stdev_46_1
276   -min_46_1
277   -max_46_1
278   -mean_47_1
279   -stdev_47_1
280   -min_47_1
281   -max_47_1
282   -mean_48_1
283   -stdev_48_1
284   -min_48_1
285   -max_48_1
286   -mean_49_1
287   -stdev_49_1
288   -min_49_1
289   -max_49_1
290   -mean_50_1
291   -stdev_50_1
292   -min_50_1
293   -max_50_1
294   -mean_51_1
295   -stdev_51_1
296   -min_51_1
297   -max_51_1
298   -mean_52_1
299   -stdev_52_1
300   -min_52_1
301   -max_52_1
302   -mean_53_1
303   -stdev_53_1
304   -min_53_1
305   -max_53_1
306   -mean_54_1
307   -stdev_54_1
308   -min_54_1
309   -max_54_1
310   -mean_55_1
311   -stdev_55_1
312   -min_55_1
313   -max_55_1
314   -mean_56_1
315   -stdev_56_1
316   -min_56_1
317   -max_56_1
318   -mean_57_1
319   -stdev_57_1
320   -min_57_1
321   -max_57_1
322   -mean_58_1
323   -stdev_58_1
324   -min_58_1
325   -max_58_1
326   -mean_59_1
327   -stdev_59_1
328   -min_59_1
329   -max_59_1
330   -mean_60_1
331   -stdev_60_1
332   -min_60_1
333   -max_60_1
334   -mean_61_1
335   -stdev_61_1
336   -min_61_1
337   -max_61_1
338   -mean_62_1
339   -stdev_62_1
340   -min_62_1
341   -max_62_1
342   -mean_63_1
343   -stdev_63_1
344   -min_63_1
345   -max_63_1
346   -mean_64_1
347   -stdev_64_1
348   -min_64_1
349   -max_64_1
350   -mean_65_1
351   -stdev_65_1
352   -min_65_1
353   -max_65_1
354   -mean_66_1
355   -stdev_66_1
356   -min_66_1
357   -max_66_1
358   -mean_67_1
359   -stdev_67_1
360   -min_67_1
361   -max_67_1
362   -mean_68_1
363   -stdev_68_1
364   -min_68_1
365   -max_68_1
366   -mean_69_1
367   -stdev_69_1
368   -min_69_1
369   -max_69_1
370   -mean_70_1
371   -stdev_70_1
372   -min_70_1
373   -max_70_1
374   -mean_71_1
375   -stdev_71_1
376   -min_71_1
377   -max_71_1
378   -mean_72
379   -stdev_72
380   -min_72
381   -max_72
382   -mean_73
383   -stdev_73
384   -min_73
385   -max_73
386   -mean_74
387   -stdev_74
388   -min_74
389   -max_74
390   -mean_75
391   -stdev_75
392   -min_75
393   -max_75
394   -mean_76
395   -stdev_76
396   -min_76
397   -max_76
398   -mean_77
399   -stdev_77
400   -min_77
401   -max_77
402   -mean_78
403   -stdev_78
404   -min_78
405   -max_78
406   -mean_79
407   -stdev_79
408   -min_79
409   -max_79
410   -mean_80
411   -stdev_80
412   -min_80
413   -max_80
414   -mean_81
415   -stdev_81
416   -min_81
417   -max_81
418   -mean_82
419   -stdev_82
420   -min_82
421   -max_82
422   -mean_83
423   -stdev_83
424   -min_83
425   -max_83
426   -mean_84
427   -stdev_84
428   -min_84
429   -max_84
430   -mean_85
431   -stdev_85
432   -min_85
433   -max_85
434   -mean_86
435   -stdev_86
436   -min_86
437   -max_86
438   -mean_87
439   -stdev_87
440   -min_87
441   -max_87
442   -mean_88
443   -stdev_88
444   -min_88
445   -max_88
446   -mean_89
447   -stdev_89
448   -min_89
449   -max_89
450   -mean_90
451   -stdev_90
452   -min_90
453   -max_90
454   -mean_91
455   -stdev_91
456   -min_91
457   -max_91
458   -mean_92
459   -stdev_92
460   -min_92
461   -max_92
462   -mean_93
463   -stdev_93
464   -min_93
465   -max_93
466   -mean_94
467   -stdev_94
468   -min_94
469   -max_94
470   -mean_95
471   -stdev_95
472   -min_95
473   -max_95
474   -mean_96
475   -stdev_96
476   -min_96
477   -max_96
478   -mean_97
479   -stdev_97
480   -min_97
481   -max_97
482   -mean_98
483   -stdev_98
484   -min_98
485   -max_98
486   -mean_99
487   -stdev_99
488   -min_99
489   -max_99
490   -mean_100
491   -stdev_100
492   -min_100
493   -max_100
494   -mean_101
495   -stdev_101
496   -min_101
497   -max_101
498   -mean_102
499   -stdev_102
500   -min_102
501   -max_102
502   -mean_103
503   -stdev_103
504   -min_103
505   -max_103
506   -mean_104
507   -stdev_104
508   -min_104
509   -max_104
510   -mean_105
511   -stdev_105
512   -min_105
513   -max_105
514   -mean_106
515   -stdev_106
516   -min_106
517   -max_106
518   -mean_107
519   -stdev_107
520   -min_107
521   -max_107
522   -mean_108
523   -stdev_108
524   -min_108
525   -max_108
526   -mean_109
527   -stdev_109
528   -min_109
529   -max_109
530   -mean_110
531   -stdev_110
532   -min_110
533   -max_110
534   -mean_111
535   -stdev_111
536   -min_111
537   -max_111
538   -mean_112
539   -stdev_112
540   -min_112
541   -max_112
542   -mean_113
543   -stdev_113
544   -min_113
545   -max_113
546   -mean_114
547   -stdev_114
548   -min_114
549   -max_114
550   -mean_115
551   -stdev_115
552   -min_115
553   -max_115
554   -mean_116
555   -stdev_116
556   -min_116
557   -max_116
558   -mean_117
559   -stdev_117
560   -min_117
561   -max_117
562   -mean_118
563   -stdev_118
564   -min_118
565   -max_118
566   -mean_119
567   -stdev_119
568   -min_119
569   -max_119
570   -mean_120
571   -stdev_120
572   -min_120
573   -max_120
574   -mean_121
575   -stdev_121
576   -min_121
577   -max_121
578   -mean_122
579   -stdev_122
580   -min_122
581   -max_122
582   -mean_123
583   -stdev_123
584   -min_123
585   -max_123
586   -mean_124
587   -stdev_124
588   -min_124
589   -max_124
590   -mean_125
591   -stdev_125
592   -min_125
593   -max_125
594   -mean_126
595   -stdev_126
596   -min_126
597   -max_126
598   -mean_127
599   -stdev_127
600   -min_127
601   -max_127
602   -mean_128
603   -stdev_128
604   -min_128
605   -max_128
606   -mean_129
607   -stdev_129
608   -min_129
609   -max_129
610   -mean_130
611   -stdev_130
612   -min_130
613   -max_130
614   -mean_131
615   -stdev_131
616   -min_131
617   -max_131
618   -mean_132
619   -stdev_132
620   -min_132
621   -max_132
622   -mean_133
623   -stdev_133
624   -min_133
625   -max_133
626   -mean_134
627   -stdev_134
628   -min_134
629   -max_134
630   -mean_135
631   -stdev_135
632   -min_135
633   -max_135
634   -mean_136
635   -stdev_136
636   -min_136
637   -max_136
638   -mean_137
639   -stdev_137
640   -min_137
641   -max_137
642   -mean_138
643   -stdev_138
644   -min_138
645   -max_138
646   -mean_139
647   -stdev_139
648   -min_139
649   -max_139
650   -mean_140
651   -stdev_140
652   -min_140
653   -max_140
654   -mean_141
655   -stdev_141
656   -min_141
657   -max_141
658   -mean_142
659   -stdev_142
660   -min_142
661   -max_142
662   -mean_143
663   -stdev_143
664   -min_143
665   -max_143
666   -mean_144
667   -stdev_144
668   -min_144
669   -max_144
670   -mean_145
671   -stdev_145
672   -min_145
673   -max_145
674   -mean_146
675   -stdev_146
676   -min_146
677   -max_146
678   -mean_147
679   -stdev_147
680   -min_147
681   -max_147
682   -mean_148
683   -stdev_148
684   -min_148
685   -max_148
686   -mean_149
687   -stdev_149
688   -min_149
689   -max_149
690   -mean_150
691   -stdev_150
692   -min_150
693   -max_150
694   -mean_151
695   -stdev_151
696   -min_151
697   -max_151
698   -mean_152
699   -stdev_152
700   -min_152
701   -max_152
702   -mean_153
703   -stdev_153
704   -min_153
705   -max_153
706   -mean_154
707   -stdev_154
708   -min_154
709   -max_154
710   -mean_155
711   -stdev_155
712   -min_155
713   -max_155
714   -mean_156
715   -stdev_156
716   -min_156
717   -max_156
718   -mean_157
719   -stdev_157
720   -min_157
721   -max_157
722   -mean_158
723   -stdev_158
724   -min_158
725   -max_158
726   -mean_159
727   -stdev_159
728   -min_159
729   -max_159
730   -mean_160
731   -stdev_160
732   -min_160
733   -max_160
734   -mean_161
735   -stdev_161
736   -min_161
737   -max_161
738   -mean_162
739   -stdev_162
740   -min_162
741   -max_162
742   -mean_163
743   -stdev_163
744   -min_163
745   -max_163
746   -mean_164
747   -stdev_164
748   -min_164
749   -max_164
750   -mean_165
751   -stdev_165
752   -min_165
753   -max_165
754   -mean_166
755   -stdev_166
756   -min_166
757   -max_166
758   -mean_167
759   -stdev_167
760   -min_167
761   -max_167
762   -mean_168
763   -stdev_168
764   -min_168
765   -max_168
766   -mean_169
767   -stdev_169
768   -min_169
769   -max_169
770   -mean_170
771   -stdev_170
772   -min_170
773   -max_170
774   -mean_171
775   -stdev_171
776   -min_171
777   -max_171
778   -mean_172
779   -stdev_172
780   -min_172
781   -max_172
782   -mean_173
783   -stdev_173
784   -min_173
785   -max_173
786   -mean_174
787   -stdev_174
788   -min_174
789   -max_174
790   -mean_175
791   -stdev_175
792   -min_175
793   -max_175
794   -mean_176
795   -stdev_176
796   -min_176
797   -max_176
798   -mean_177
799   -stdev_177
800   -min_177
801   -max_177
802   -mean_178
803   -stdev_178
804   -min_178
805   -max_178
806   -mean_179
807   -stdev_179
808   -min_179
809   -max_179
810   -mean_180
811   -stdev_180
812   -min_180
813   -max_180
814   -mean_181
815   -stdev_181
816   -min_181
817   -max_181
818   -mean_182
819   -stdev_182
820   -min_182
821   -max_182
822   -mean_183
823   -stdev_183
824   -min_183
825   -max_183
826   -mean_184
827   -stdev_184
828   -min_184
829   -max_184
830   -mean_185
831   -stdev_185
832   -min_185
833   -max_185
834   -mean_186
835   -stdev_186
836   -min_186
837   -max_186
838   -mean_187
839   -stdev_187
840   -min_187
841   -max_187
842   -mean_188
843   -stdev_188
844   -min_188
845   -max_188
846   -mean_189
847   -stdev_189
848   -min_189
849   -max_189
850   -mean_190
851   -stdev_190
852   -min_190
853   -max_190
854   -mean_191
855   -stdev_191
856   -min_191
857   -max_191
858   -mean_192
859   -stdev_192
860   -min_192
861   -max_192
862   -mean_193
863   -stdev_193
864   -min_193
865   -max_193
866   -mean_194
867   -stdev_194
868   -min_194
869   -max_194
870   -mean_195
871   -stdev_195
872   -min_195
873   -max_195
874   -mean_196
875   -stdev_196
876   -min_196
877   -max_196
878   -mean_197
879   -stdev_197
880   -min_197
881   -max_197
882   -mean_198
883   -stdev_198
884   -min_198
885   -max_198
886   -mean_199
887   -stdev_199
888   -min_199
889   -max_199
890   -mean_200
891   -stdev_200
892   -min_200
893   -max_200
894   -mean_201
895   -stdev_201
896   -min_201
897   -max_201
898   -mean_202
899   -stdev_202
900   -min_202
901   -max_202
902   -mean_203
903   -stdev_203
904   -min_203
905   -max_203
906   -mean_204
907   -stdev_204
908   -min_204
909   -max_204
910   -mean_205
911   -stdev_205
912   -min_205
913   -max_205
914   -mean_206
915   -stdev_206
916   -min_206
917   -max_206
918   -mean_207
919   -stdev_207
920   -min_207
921   -max_207
922   -mean_208
923   -stdev_208
924   -min_208
925   -max_208
926   -mean_209
927   -stdev_209
928   -min_209
929   -max_209
930   -mean_210
931   -stdev_210
932   -min_210
933   -max_210
934   -mean_211
935   -stdev_211
936   -min_211
937   -max_211
938   -mean_212
939   -stdev_212
940   -min_212
941   -max_212
942   -mean_213
943   -stdev_213
944   -min_213
945   -max_213
946   -mean_214
947   -stdev_214
948   -min_214
949   -max_214
950   -mean_215
951   -stdev_215
952   -min_215
953   -max_215
954   -mean_216
955   -stdev_216
956   -min_216
957   -max_216
958   -mean_217
959   -stdev_217
960   -min_217
961   -max_217
962   -mean_218
963   -stdev_218
964   -min_218
965   -max_218
966   -mean_219
967   -stdev_219
968   -min_219
969   -max_219
970   -mean_220
971   -stdev_220
972   -min_220
973   -max_220
974   -mean_221
975   -stdev_221
976   -min_221
977