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 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676
| // Ce script utilise les coordonnées NW et SE d'un cadrage pour copier les images brutes qui le composent,
// les dézipper, les détarer, changer leur projection, intégrer le 15 m en Lab et créer les fichiers de travail photoshop 2s puis les blocs à 0s5.
//Crée la fenêtre calculs pour entrer les paramètres NW, SE et les dossiers
copie_calculs = new Window('dialog',"Copie - Calculs",[0,0,650,630])
//Contenu de la fenêtre copie_calculs
cadre_1 = copie_calculs.add('panel',[5,5,645,130],"1 - Choix d'une zone",{borderStyle:"etched"})
cadre_2 = copie_calculs.add('panel',[5,135,645,310],"2 - Sélection des dossiers de données",{borderStyle:"etched"})
cadre_3 = copie_calculs.add('panel',[5,320,645,530],"3 - Possibilité de faire les étapes une à une ",{borderStyle:"etched"})
cadre_4 = copie_calculs.add('panel',[5,540,320,620],"4 - Ou de faire toutes les étapes 3 en 1 fois",{borderStyle:"etched"})
cadre_5 = copie_calculs.add('panel',[330,540,645,620],"5",{borderStyle:"etched"})
//Fichier Images Pompées
bouton_images_pompees = cadre_1.add('button',[10,10,135,40],"Fichier gmw")
fichier_images_pompees = File("//Herculepoirot/E/Villes_L8/Images_Villes_L8.gmw")
//fichier_images_pompees = File("//Telepompe/E/Telepompage/Pointage_images_pompees.gmw")
texte_fichier_images_pompees = cadre_1.add('statictext',[10,45,355,65],fichier_images_pompees)
bouton_images_pompees.onClick = function () {images_pompees()}
//Coordonnées Lat-Long
cadre_1_1 = cadre_1.add('panel',[370,5,630,110],"Coordonnées des coins NW et SE du cadrage",{borderStyle:"etched"})
cadre_1_1.add('statictext',[20,20,45,40],"Nord")
cadre_1_1.add('statictext',[185,20,220,40],"Ouest")
cadre_1_1.add('statictext',[50,50,75,70],"Sud")
cadre_1_1.add('statictext',[215,50,260,70],"Est")
cadre_1_1.add('statictext',[40,70,110,90],"Négatif si Sud")
cadre_1_1.add('statictext',[150,70,240,90],"Négatif si Ouest")
Nord = cadre_1_1.add('edittext',[50,20,110,40])
Nord.text = 36
Lat_N=Nord.text*1
Nord.onChange = function () {Lat_N=Nord.text*1}
Ouest = cadre_1_1.add('edittext',[120,20,180,40])
Ouest.text = -10
Lon_W=Ouest.text*1
Ouest.onChange = function () {Lon_W=Ouest.text*1}
Sud = cadre_1_1.add('edittext',[80,50,140,70])
Sud.text = 30
Lat_S=Sud.text*1
Sud.onChange = function () {Lat_S=Sud.text*1}
Est = cadre_1_1.add('edittext',[150,50,210,70])
Est.text = -6
Lon_E=Est.text*1
Est.onChange = function () {Lon_E=Est.text*1}
//Emplacement des fichiers bruts
bouton_images_brutes = cadre_2.add('button',[10,10,135,40],"Dossier Images Brutes")
dossier_images_brutes = Folder("//Telepompe/F/Telepompage/Landsat_8/Villes_L8/")
bouton_images_brutes.onClick = function () {dossier_images_brutes = Folder.selectDialog("Dossier Images Brutes",dossier_images_brutes);texte_dossier_images_brutes.text=dossier_images_brutes}
texte_dossier_images_brutes = cadre_2.add('statictext',[10,45,300,65],dossier_images_brutes)
//Emplacement des blocs 2x2° existants
bouton_blocs_2x2degres = cadre_2.add('button',[10,80,135,125],"Dossier Blocs 2x2°\nexistants")
dossier_blocs_2x2degres = Folder("//Nasser/Volume_2/")
bouton_blocs_2x2degres.onClick = function () {dossier_blocs_2x2degres = Folder.selectDialog("Dossier Blocs 2x2°",dossier_blocs_2x2degres);texte_dossier_blocs_2x2degres.text=dossier_blocs_2x2degres}
texte_dossier_blocs_2x2degres = cadre_2.add('statictext',[10,130,300,150],dossier_blocs_2x2degres)
//Zone à traiter
bouton_disque_1 = cadre_2.add('button',[310,10,435,50],"Dossier Zone à traiter")
dossier_disque_1 = Folder("E:/Villes_L8/AFR1/")
bouton_disque_1.onClick = function () {dossier_disque_1 = Folder.selectDialog("Dossier Zone à traiter",dossier_disque_1);texte_dossier_disque_1.text=dossier_disque_1}
texte_dossier_disque_1 = cadre_2.add('statictext',[310,55,600,75],dossier_disque_1)
//Couche eau
bouton_couche_eau = cadre_2.add('button',[310,90,435,130],"Dossier Couche eau")
dossier_couche_eau = Folder("E:/Eau/Eau_SRTM")
bouton_couche_eau.onClick = function () {dossier_couche_eau = Folder.selectDialog("Dossier Couche eau",dossier_couche_eau);texte_dossier_couche_eau.text=dossier_couche_eau}
texte_dossier_couche_eau = cadre_2.add('statictext',[310,135,600,155],dossier_couche_eau)
//Bouton Selection_OK
bouton_selection_ok = cadre_3.add('button',[10,20,130,50],"Sélection fichiers")
bouton_selection_ok.onClick = function () {selection_ok()}
//Bouton Copie
bouton_copie = cadre_3.add('button',[10,60,130,110],"Copie\ndes fichiers")
bouton_copie.onClick = function () {copie_fichiers()}
cadre_3.add('statictext',[140,20,315,35],"- Sélection des fichiers")
cadre_3.add('statictext',[140,60,315,75],"- Copie")
cadre_3.add('statictext',[140,120,315,135],"- Dézippage")
cadre_3.add('statictext',[140,140,315,155],"- Détarage")
cadre_3.add('statictext',[140,160,315,175],"- Nettoyage")
//Bouton TarZip
bouton_tarzip = cadre_3.add('button',[10,120,130,170],"Détarzip\ndes images brutes")
bouton_tarzip.onClick = function () {tarzip()}
//Bouton Calculs
bouton_calculs_1 = cadre_3.add('button',[330,20,460,50],"1 - Photoshop")
bouton_calculs_1.onClick = function () {calculs_1()}
bouton_calculs_2 = cadre_3.add('button',[330,60,460,90],"2 - GlobalMapper")
bouton_calculs_2.onClick = function () {calculs_2()}
bouton_calculs_3 = cadre_3.add('button',[330,100,460,130],"3 - Photoshop")
bouton_calculs_3.onClick = function () {calculs_3()}
cadre_3.add('statictext',[470,20,645,35],"- PanSharpening")
cadre_3.add('statictext',[470,60,645,75],"- 2s (L8+Blocs+Eau) ET 0s5 (L8)")
cadre_3.add('statictext',[470,100,645,115],"- Assemblage fichier à 2 s")
//Bouton Phase 3 en 1 fois
bouton_etapes = cadre_4.add('button',[10,20,200,70],"Toutes les étapes 3 en une fois")
bouton_etapes.onClick = function () {etapes()}
//Bouton Appliquer Réglages
bouton_reglages = cadre_5.add('button',[10,20,230,70],"Application des réglages sur les blocs 0s5")
bouton_reglages.onClick = function () {reglages()}
// Afficher la fenêtre copie_calculs
copie_calculs.center();copie_calculs.show()
//==============================================================================================================================================================================================
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Fonction bouton images pompées
function images_pompees() {
fichier_images_pompees = File.openDialog("Images Pompées","Fichier GMW:*.GMW",fichier_images_pompees);texte_fichier_images_pompees.text=fichier_images_pompees
fichier_images_pompees.execute()
//
}//fin fonction
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Fonction selection_ok qui sélectionne les images brutes du cadrage
function selection_ok() {
//Extrait le fichier SIMPLE_ASCII de GlobalMapper selon le cadrage et récupère les path-row
//Crée le dossier Batchs et les lignes du script
dossier_batchs = Folder(dossier_disque_1.fsName+'\\Batchs\\')
if (dossier_batchs.exists==true) { } else {dossier_batchs.create()}
script_ascii = new File(dossier_disque_1+'/Batchs/script_ascii.gmw')
script_ascii.open("w")
script_ascii.writeln('GLOBAL_MAPPER_SCRIPT VERSION="1.00" FILENAME="'+dossier_disque_1.fsName+'\\Batchs\\script_ascii.gmw"')
script_ascii.writeln('DEFINE_PROJ PROJ_NAME="GEO_WGS84"')
script_ascii.writeln('Projection GEOGRAPHIC')
script_ascii.writeln('Datum WGS84')
script_ascii.writeln('Zunits NO')
script_ascii.writeln('Units DD')
script_ascii.writeln('Xshift 0.000000')
script_ascii.writeln('Yshift 0.000000')
script_ascii.writeln('Parameters')
script_ascii.writeln('0 0 0.000')
script_ascii.writeln('END_DEFINE_PROJ')
script_ascii.writeln('')
script_ascii.writeln('UNLOAD_ALL')
script_ascii.writeln('EMBED_SCRIPT FILENAME="'+fichier_images_pompees.fsName+'"')
script_ascii.writeln('')
script_ascii.writeln('EXPORT_VECTOR FILENAME="'+dossier_disque_1.fsName+'\\Batchs\\simple_ascii.txt" TYPE="SIMPLE_ASCII" LAT_LON_BOUNDS="'+Lon_W+','+Lat_S+','+Lon_E+','+Lat_N+'" \\')
script_ascii.writeln('')
script_ascii.close()
batch_ascii = new File(dossier_disque_1+'/Batchs/batch_ascii.bat')
batch_ascii.open("w")
batch_ascii.writeln('set PATH=%PATH%;C:\\Program Files\\GlobalMapper13')
batch_ascii.writeln('set PATH=%PATH%;C:\\Program Files (x86)\\GlobalMapper13')
batch_ascii.writeln('global_mapper13.exe '+script_ascii.fsName)
batch_ascii.close()
batch_ascii.execute()
fichier_ascii = File(dossier_disque_1+'/Batchs/simple_ascii.txt')
//
}//fin fonction
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Fonction copie_fichier qui copie les images brutes sur une lame, ainsi que les blocs existants et les blocs eau
function copie_fichiers() {
//le détail de ma fonction ici
//
}//fin fonction
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Fonction Détare, Dézipe et nettoie les fichiers copiés
function tarzip() {
//le détail de ma fonction ici
}//fin fonction
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Fonction calculs sur les images brutes
// Passage en projection géographique, mosaïque à 2s
function calculs_1() {
//Photoshop : Pan Sharpening, enregistrer sous le nom _B8432, appliquer un alv général, passer en 8 bits
// La cible du programme est Photoshop
#target photoshop
// Mettre l'application (Photoshop) au premier plan
app.bringToFront()
// Définir le pixel comme unité par défaut
app.preferences.rulerUnits = Units.PIXELS
// Lui dire de ne pas ouvrir visant à interagir avec l'utilisateur
DialogModes.NO
displayDialogs = DialogModes.NO
fichier_images = File(dossier_disque_1+'/Batchs/liste.txt')
fichier_images.open("r")
fichier_images.seek(0,0)
image = fichier_images.readln()
while (fichier_images.eof == false) {
chemin_image = dossier_disque_1.fsName+"\\ImagesBrutes\\"+image+"\\"
// détail de mon code Photoshop ici
}//fin fonction
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//Global Mapper : Fichiers de travail à 2s (blocs + eau + images) ET Images L8 (changement de projection, enregistrer en blocs 2x2° pour le 0s5°)
function calculs_2() {
fichier_images = File(dossier_disque_1+'/Batchs/liste.txt')
fichier_images.open("r")
fichier_images.seek(0,0)
script_projgeo = File(dossier_disque_1+'/Batchs/script_projgeo.gmw')
script_projgeo.open("w")
script_projgeo.writeln('GLOBAL_MAPPER_SCRIPT VERSION="1.00" FILENAME="'+dossier_disque_1.fsName+'\\Batchs\\script_projgeo.gmw"')
script_projgeo.writeln('DEFINE_PROJ PROJ_NAME="GEO_WGS84_DD"')
script_projgeo.writeln('Projection GEOGRAPHIC')
script_projgeo.writeln('Datum WGS84')
script_projgeo.writeln('Zunits NO')
script_projgeo.writeln('Units DD')
script_projgeo.writeln('Xshift 0.000000')
script_projgeo.writeln('Yshift 0.000000')
script_projgeo.writeln('Parameters')
script_projgeo.writeln('0 0 0.000')
script_projgeo.writeln('END_DEFINE_PROJ')
script_projgeo.writeln('')
script_projgeo.writeln('DEFINE_PROJ PROJ_NAME="GEO_WGS84_DS"')
script_projgeo.writeln('Projection GEOGRAPHIC')
script_projgeo.writeln('Datum WGS84')
script_projgeo.writeln('Zunits NO')
script_projgeo.writeln('Units DS')
script_projgeo.writeln('Xshift 0.000000')
script_projgeo.writeln('Yshift 0.000000')
script_projgeo.writeln('Parameters')
script_projgeo.writeln('0 0 0.000')
script_projgeo.writeln('END_DEFINE_PROJ')
script_projgeo.writeln('')
script_projgeo.writeln('SET_BG_COLOR COLOR="RGB(0,0,0)"')
script_projgeo.writeln('UNLOAD_ALL')
script_projgeo.writeln('')
//Enregistrement des images à 2s puis à 0s5 ====================
image = fichier_images.readln()
while (fichier_images.eof == false) {
chemin_image = dossier_disque_1.fsName+"\\ImagesBrutes\\"+image+"\\"
script_projgeo.writeln('IMPORT FILENAME="'+dossier_disque_1.fsName+'\\ImagesBrutes\\'+image+'\\'+image+'_B8432.TIF"')
script_projgeo.writeln('LOAD_PROJECTION PROJ_NAME="GEO_WGS84_DS"')
script_projgeo.writeln('')
//Export du bloc 2s au cadrage de la zone de travail
script_projgeo.writeln('EXPORT_RASTER FILENAME="'+dossier_disque_1.fsName+'\\ImagesBrutes_ProjGeo\\2s\\'+image+'_2s.TIF" \\')
script_projgeo.writeln('SAMPLING_METHOD="DEFAULT" SPATIAL_RES="2,2" LAT_LON_BOUNDS="'+Lon_W+','+Lat_S+','+Lon_E+','+Lat_N+'" TYPE="GEOTIFF" GEN_WORLD_FILE="YES" GEN_PRJ_FILE="YES"')
script_projgeo.writeln('')
//Export des blocs 2x2° 0s5
// Export des blocs 0s5 dans le quart NW, si c'est utile
if ((Lat_N > 0)&&(Lon_W < 0)) {
y_max = Lat_N
if (Lat_S > 0) {y_min = Lat_S} else {y_min = 0}
x_min = Lon_W
if (Lon_E < 0) {x_max = Lon_E} else {x_max = 0}
// Entête latitude N
if ((Lat_N <= 90)&&(Lat_N >= 10)) {Entete_NS = "N"} else { }
if (Lat_N < 10) {Entete_NS = "N0"} else { }
// Entête longitude W
if ((Lon_W >= -180)&&(Lon_W <=-100)) {Entete_WE = "W"} else { }
if ((Lon_W > -100)&&(Lon_W <=-10)) {Entete_WE = "W0"} else { }
if (Lon_W > -10) {Entete_WE = "W00"} else { }
script_projgeo.writeln('/* Export quart NW')
script_projgeo.writeln('EXPORT_RASTER FILENAME="'+dossier_disque_1.fsName+'\\ImagesBrutes_ProjGeo\\0s5\\'+image+'_0s5_.TIF" \\')
script_projgeo.writeln(' SAMPLING_METHOD="BICUBIC" SPATIAL_RES="0.5,0.5" LAT_LON_BOUNDS="'+x_min+','+y_min+','+x_max+','+y_max+'" TYPE="GEOTIFF" GEN_WORLD_FILE="YES" GEN_PRJ_FILE="YES" \\')
script_projgeo.writeln(' GRID_TYPE_PIXEL_SIZE="14400,14400" GRID_NAMING="SEPARATE" GRID_NAMING_ROWS="NUM,'+Math.abs(y_max)+','+Entete_NS+',-2" GRID_NAMING_COLS="NUM,'+Math.abs(x_min)+','+Entete_WE+',-2" \\')
script_projgeo.writeln(' GRID_NAMING_PREPEND_ZEROES="YES" GRID_NAMING_SEPARATOR=""')
script_projgeo.writeln('')
} else { }
// Export des blocs 0s5 dans le quart NE, si c'est utile
if ((Lat_N > 0)&&(Lon_E >= 0)) {
y_max = Lat_N
if (Lat_S > 0) {y_min = Lat_S} else {y_min = 0}
x_max = Lon_E
if (Lon_W >= 0) {x_min = Lon_W} else {x_min = 0}
// Entête latitude N
if ((Lat_N <= 90)&&(Lat_N >= 10)) {Entete_NS = "N"} else { }
if (Lat_N < 10) {Entete_NS = "N0"} else { }
// Entête longitude E
if ((Lon_E <= 180)&&(Lon_E >100)) {Entete_WE = "E"} else { }
if ((Lon_E < 100)&&(Lon_E >10)) {Entete_WE = "E0"} else { }
if (Lon_E <= 10) {Entete_WE = "E00"} else { }
script_projgeo.writeln('/* Export quart NE')
script_projgeo.writeln('EXPORT_RASTER FILENAME="'+dossier_disque_1.fsName+'\\ImagesBrutes_ProjGeo\\0s5\\'+image+'_0s5_.TIF" \\')
script_projgeo.writeln(' SAMPLING_METHOD="BICUBIC" SPATIAL_RES="0.5,0.5" LAT_LON_BOUNDS="'+x_min+','+y_min+','+x_max+','+y_max+'" TYPE="GEOTIFF" GEN_WORLD_FILE="YES" \\')
script_projgeo.writeln(' GRID_TYPE_PIXEL_SIZE="14400,14400" GRID_NAMING="SEPARATE" GRID_NAMING_ROWS="NUM,'+Math.abs(y_max)+','+Entete_NS+',-2" GRID_NAMING_COLS="NUM,'+Math.abs(x_min)+','+Entete_WE+',2" \\')
script_projgeo.writeln(' GRID_NAMING_PREPEND_ZEROES="YES" GRID_NAMING_SEPARATOR=""')
script_projgeo.writeln('')
} else { }
// Export des blocs 0s5 dans le quart SW, si c'est utile
if ((Lat_S <= 0)&&(Lon_W < 0)) {
y_min = Lat_S
if (Lat_N <= 0) {y_max = Lat_N} else {y_max = 0}
x_min = Lon_W
if (Lon_E < 0) {x_max = Lon_E} else {x_max = 0}
// Entête latitude S
if ((Lat_S >= -90)&&(Lat_S < -10)) {Entete_NS = "S"} else { }
if (Lat_S >= -10) {Entete_NS = "S0"} else { }
// Entête longitude W
if ((Lon_W >= -180)&&(Lon_W <=-100)) {Entete_WE = "W"} else { }
if ((Lon_W > -100)&&(Lon_W <=-10)) {Entete_WE = "W0"} else { }
if (Lon_W > -10) {Entete_WE = "W00"} else { }
script_projgeo.writeln('/* Export quart SW')
script_projgeo.writeln('EXPORT_RASTER FILENAME="'+dossier_disque_1.fsName+'\\ImagesBrutes_ProjGeo\\0s5\\'+image+'_0s5_.TIF" \\')
script_projgeo.writeln(' SAMPLING_METHOD="BICUBIC" SPATIAL_RES="0.5,0.5" LAT_LON_BOUNDS="'+x_min+','+y_min+','+x_max+','+y_max+'" TYPE="GEOTIFF" GEN_WORLD_FILE="YES" \\')
script_projgeo.writeln(' GRID_TYPE_PIXEL_SIZE="14400,14400" GRID_NAMING="SEPARATE" GRID_NAMING_ROWS="NUM,'+Math.abs(y_max)+','+Entete_NS+',2" GRID_NAMING_COLS="NUM,'+Math.abs(x_min)+','+Entete_WE+',-2" \\')
script_projgeo.writeln(' GRID_NAMING_PREPEND_ZEROES="YES" GRID_NAMING_SEPARATOR=""')
script_projgeo.writeln('')
} else { }
// Export des blocs 0s5 dans le quart SE, si c'est utile
if ((Lat_S <= 0)&&(Lon_E >= 0)) {
y_min = Lat_S
if (Lat_N <= 0) {y_max = Lat_N} else {y_max = 0}
x_max = Lon_E
if (Lon_W >= 0) {x_min = Lon_W} else {x_min = 0}
// Entête latitude S
if ((Lat_S >= -90)&&(Lat_S < -10)) {Entete_NS = "S"} else { }
if (Lat_S >= -10) {Entete_NS = "S0"} else { }
// Entête longitude E
if ((Lon_E <= 180)&&(Lon_E >100)) {Entete_WE = "E"} else { }
if ((Lon_E <= 100)&&(Lon_E >10)) {Entete_WE = "E0"} else { }
if (Lon_E <= 10) {Entete_WE = "E00"} else { }
script_projgeo.writeln('/* Export quart SE')
script_projgeo.writeln('EXPORT_RASTER FILENAME="'+dossier_disque_1.fsName+'\\ImagesBrutes_ProjGeo\\0s5\\'+image+'_0s5_.TIF" \\')
script_projgeo.writeln(' SAMPLING_METHOD="BICUBIC" SPATIAL_RES="0.5,0.5" LAT_LON_BOUNDS="'+x_min+','+y_min+','+x_max+','+y_max+'" TYPE="GEOTIFF" GEN_WORLD_FILE="YES" \\')
script_projgeo.writeln(' GRID_TYPE_PIXEL_SIZE="14400,14400" GRID_NAMING="SEPARATE" GRID_NAMING_ROWS="NUM,'+Math.abs(y_max)+','+Entete_NS+',2" GRID_NAMING_COLS="NUM,'+Math.abs(x_min)+','+Entete_WE+',2" \\')
script_projgeo.writeln(' GRID_NAMING_PREPEND_ZEROES="YES" GRID_NAMING_SEPARATOR=""')
script_projgeo.writeln('')
} else { }
script_projgeo.writeln('UNLOAD_ALL')
image = fichier_images.readln()
}//fin while
//Enregistrement des blocs à 2s====================
script_projgeo.writeln('')
script_projgeo.writeln('/* Export Blocs 2s quart NE')
// Ouvre le fichier liste_Blocs_2x2deg.txt et le copie dans un tableau
liste_Blocs_2x2deg = File(dossier_disque_1+"/Batchs/liste_Blocs_2x2deg.txt")
liste_Blocs_2x2deg.open("r")
liste_Blocs_2x2deg.seek (0, 0)
contenu_liste_Blocs_2x2deg = new Array()
nblignes=0
while (liste_Blocs_2x2deg.eof == false) {
contenu_liste_Blocs_2x2deg[nblignes] = liste_Blocs_2x2deg.readln()
nblignes++
}
// Boucle sur toutes les lignes du fichier liste_Blocs_2x2deg
for (i = 0 ; i < nblignes-1 ; i++){
script_projgeo.writeln('IMPORT FILENAME="'+dossier_disque_1.fsName+'\\Blocs_2x2deg\\Landsat\\'+contenu_liste_Blocs_2x2deg[i]+'" \\')
script_projgeo.writeln(' TYPE="GEOTIFF" PROJ_NAME="GEO_WGS84_DD" SAMPLING_METHOD="BICUBIC" CONTRAST_MODE="NONE"')
}
// Export du bloc 2s
Lat = Lat_N
Lat > Lat_S
Lon = Lon_W
Lon < Lon_E
script_projgeo.writeln('')
script_projgeo.writeln('LOAD_PROJECTION PROJ_NAME="GEO_WGS84_DS"')
script_projgeo.writeln('EXPORT_RASTER FILENAME="'+dossier_disque_1.fsName+'\\'+'Images_Travail\\Monde_L7_2s_'+Latitude(Lat)+Longitude(Lon)+'.tif" \\')
script_projgeo.writeln(' TYPE="GEOTIFF" SPATIAL_RES="2,2" LAT_LON_BOUNDS="'+Lon_W+','+Lat_S+','+Lon_E+','+Lat_N+'" GEN_WORLD_FILE="YES" COMPRESSION="NONE" \\')
script_projgeo.writeln('UNLOAD_ALL')
liste_Blocs_2x2deg.close()
//Enregistrement de la couche eau à 2s==============
script_projgeo.writeln('')
script_projgeo.writeln('/* Eau a 2s')
// Ouvre le fichier liste_Blocs_2x2deg.txt et le copie dans un tableau
liste_couche_eau = File(dossier_disque_1+"/Batchs/liste_couche_eau.txt")
liste_couche_eau.open("r")
liste_couche_eau.seek (0, 0)
contenu_liste_couche_eau = new Array()
nblignes=0
while (liste_couche_eau.eof == false) {
contenu_liste_couche_eau[nblignes] = liste_couche_eau.readln()
nblignes++
}
// Boucle sur toutes les lignes du fichier liste_Blocs_2x2deg
for (i = 0 ; i < nblignes-1 ; i++){
script_projgeo.writeln('IMPORT FILENAME="'+dossier_disque_1.fsName+'\\Blocs_2x2deg\\Eau\\'+contenu_liste_couche_eau[i]+'.tif"\\')
script_projgeo.writeln(' TYPE="GEOTIFF" PROJ_NAME="GEO_WGS84_DD" SAMPLING_METHOD="BOX_3X3" CONTRAST_MODE="NONE"')
}
// Export couche eau 2s
script_projgeo.writeln('')
script_projgeo.writeln('LOAD_PROJECTION PROJ_NAME="GEO_WGS84_DS"')
script_projgeo.writeln('EXPORT_RASTER FILENAME="'+dossier_disque_1.fsName+'\\'+'Images_Travail\\CoucheEau_SRTM_2s_'+dossier_disque_1.fsName.substring(13)+'.tif" \\')
script_projgeo.writeln(' TYPE="GEOTIFF" SPATIAL_RES="2,2" FORCE_SQUARE_PIXELS="YES" LAT_LON_BOUNDS="'+Lon_W+','+Lat_S+','+Lon_E+','+Lat_N+'" \\')
script_projgeo.writeln(' GEN_WORLD_FILE="YES" PALETTE="GRAYSCALE" COMPRESSION="NONE" ')
script_projgeo.writeln('')
script_projgeo.writeln('UNLOAD_ALL')
liste_couche_eau.close()
script_projgeo.close()
//ECRITURE DU BATCH GENERAL =====================
//Ecrit le script gms et les commandes zip dans le fichier batch_etape_1.bat
//Ajout des paths 7-Zip et Global Mapper
batch_etape_1 = File(dossier_disque_1+"/Batchs/batch_etape_1.bat")
if (batch_etape_1.exists==true) {batch_etape_1.remove()} else { }
batch_etape_1 = new File(dossier_disque_1+"/Batchs/batch_etape_1.bat")
batch_etape_1.open("e")
batch_etape_1.seek (0, 0)
batch_etape_1.writeln('set PATH=%PATH%;C:\\Program Files\\7-Zip')
batch_etape_1.writeln('set PATH=%PATH%;C:\\Program Files\\GlobalMapper13')
batch_etape_1.writeln()
//Ecriture du dézippage des couches eau
//Calcul des noms de fichiers à ouvrir (c'est la meme chose que pour ecrire l'import des couches eau dans le gms)
// Ouvre le fichier liste_Blocs_2x2deg.txt et le copie dans un tableau
liste_couche_eau = File(dossier_disque_1+"/Batchs/liste_couche_eau.txt")
liste_couche_eau.open("r")
liste_couche_eau.seek (0, 0)
contenu_liste_couche_eau = new Array()
nblignes=0
while (liste_couche_eau.eof == false) {
contenu_liste_couche_eau[nblignes] = liste_couche_eau.readln()
nblignes++
}
for (i = 0 ; i < nblignes-1 ; i++){
batch_etape_1.writeln('7z e '+dossier_disque_1.fsName+'\\Blocs_2x2deg\\Eau\\'+contenu_liste_couche_eau[i]+'.zip -o'+dossier_disque_1.fsName+'\\Blocs_2x2deg\\Eau')
}
//Ecriture du Script gms et suppression des tif Eau
batch_etape_1.writeln()
batch_etape_1.writeln('global_mapper13.exe '+dossier_disque_1.fsName+'\\Batchs\\script_projgeo.gmw')
batch_etape_1.writeln()
batch_etape_1.writeln('del '+dossier_disque_1.fsName+'\\Blocs_2x2deg\\Eau\\*.tif')
batch_etape_1.writeln()
batch_etape_1.close()
liste_couche_eau.close()
batch_etape_1.execute()
}//fin fonction
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//Photoshop : créer le bloc de travail à 2s
function calculs_3() {
// Assemble le bloc tif, la couche eau et les images à 2s
// La cible du programme est Photoshop
#target photoshop
// Mettre l'application (Photoshop) au premier plan
app.bringToFront()
// Définir le pixel comme unité par défaut
app.preferences.rulerUnits = Units.PIXELS
// Lui dire de ne pas ouvrir visant à interagir avec l'utilisateur
DialogModes.NO
displayDialogs = DialogModes.NO
// Détermine le dossier des blocs 2s et le fichier eau
Lat = Lat_N
Lat > Lat_S
Lon = Lon_W
Lon < Lon_E
blocs_2s = File(dossier_disque_1+"/Images_Travail/Monde_L7_2s_"+Latitude(Lat)+Longitude(Lon)+".tif")
eau_2s = File(dossier_disque_1+"/Images_Travail/CoucheEau_SRTM_2s_"+dossier_disque_1.fsName.substring(13)+".tif")
//détail du programme Photoshop ici
}//fin fonction
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Fonction Phase 3 en 1 fois
function etapes() {
// Un objet JS contenant les fonctions
var ObjMonPropbleme = {
"btn1" : function ObjMonProbleme_btn1( event ){
// debug, console, touche F12
// Date.now() donne le temps en millisecondes
console.log( Date.now(), "btn1 : event id = ", event.target.id );
// Cette boucle de calcul ne sert qu'à perdre du temps pour mettre
// en évidence avec Date.now() que les fonctions s'exécutent bien
// une par une.
for( var k = 0; k < 999999999; k++ ){ var r = k/999; }
// indispensable pour pouvoir chaîner les appels
return this;
},
"btn2" : function ObjMonProbleme_btn2( event ){
console.log( Date.now(), "btn2 : event timestamp = ", event.timeStamp );
for( var k = 0; k < 999999999; k++ ){ var r = k/999; }
return this;
},
"btn3" : function ObjMonProbleme_btn3( event ){
console.log( Date.now(), "btn3 : event type = ", event.type );
for( var k = 0; k < 999999999; k++ ){ var r = k/999; }
return this;
},
"btn4" : function ObjMonProbleme_btn4( event ){
console.log( Date.now(), "btn4 : event target innerText = ", event.target.innerText );
for( var k = 0; k < 999999999; k++ ){ var r = k/999; }
return this;
},
"btn5" : function ObjMonProbleme_btn5( event ){
console.log( Date.now(), "btn5 : event target local name = ", event.target.localName );
for( var k = 0; k < 999999999; k++ ){ var r = k/999; }
return this;
},
"btn6" : function ObjMonProbleme_btn6( event ){
console.log( Date.now(), "btn6 : event x et y = ", event.x, event.y );
for( var k = 0; k < 999999999; k++ ){ var r = k/999; }
return this;
}
};
// on sélectionne les boutons
var btns = document.querySelectorAll( "[id^='btn']" ),
btnsLength = btns.length;
// la fonction qui gère l'événement
function handlerBtnEventClick( event ){
// debug, console, touche F12
console.log( event );
// les fonctions s'exécutent une par une
// c'est return this qui permet de chaîner les appels
ObjMonPropbleme.btn1( event ).btn2( event ).btn3( event ).btn4( event ).btn5( event ).btn6( event );
};
// on ajoute un gestionnaire d'événement sur chaque bouton,
for( var i = 0; i < btnsLength; i++ ){
btns[ i ].addEventListener( "click", handlerBtnEventClick, false );
}
//Pour info le nom de mes function :
//selection_ok()
//copie_fichiers()
//tarzip()
//calculs_1()
//calculs_2()
//calculs_3()
}//fin fonction
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Fonction application des réglages sur les blocs à 0s5
function reglages() {
// La cible du programme est Photoshop
#target photoshop
// Mettre l'application (Photoshop) au premier plan
app.bringToFront()
// Définir le pixel comme unité par défaut
app.preferences.rulerUnits = Units.PIXELS
// Lui dire de ne pas ouvrir visant à interagir avec l'utilisateur
DialogModes.NO
displayDialogs = DialogModes.NO
//détail de mon code Photoshop
} //Fin boucle i
alert('Fin du programme. Vérifier les blocs sur Global Mapper (+sutures avec les blocs autour) et remplacer les tif initiaux (+couche eau si besoin)')
}//fin fonction
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Fonction Latitude qui écrit les latitudes en texte
function Latitude(Lat) {
//Entête latitude
if ((Lat <= 90)&&(Lat >= 10)) {NS = "N"}
if ((Lat < 10)&&(Lat > 0)) {NS = "N0"}
if ((Lat <= 0)&&(Lat > -10)) {NS = "S0"}
if ((Lat <= -10)&&(Lat >= -90)) {NS = "S"}
return NS + Math.abs(Lat)
//
}//fin fonction
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Fonction Longitude qui écrit les longitudes en texte
function Longitude(Lon) {
//Entête longitude
if ((Lon >= -180)&&(Lon <= -100)) {WE = "W"}
if ((Lon > -100)&&(Lon <= -10)) {WE = "W0"}
if ((Lon > -10)&&(Lon < 0)) {WE = "W00"}
if ((Lon >= 0)&&(Lon < 10)) {WE = "E00"}
if ((Lon >= 10)&&(Lon < 100)) {WE = "E0"}
if ((Lon >= 100)&&(Lon <= 180)) {WE = "E"}
return WE + Math.abs(Lon)
//
}//fin fonction
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
Partager