Skip to content

Some applications are run twice

This is typically the case with PatchesExtraction:

    # patches extraction ----> RUN ONCE HERE
    patches = pyotb.PatchesExtraction(
      n_sources=3,  # Tells the OTB application to use 3 sources
      source1_il=pan,
      source1_patchsizex=patch_size,
      source1_patchsizey=patch_size,
      source1_nodata=0,
      source2_il=xs,
      source2_patchsizex=int(patch_size / 4),
      source2_patchsizey=int(patch_size / 4),
      source2_nodata=0,
      source3_il=labels,
      source3_patchsizex=patch_size,
      source3_patchsizey=patch_size,
      vec=vec_point,
      field=vec_points_field
    )
    
    # write
    out_dict = {
      "source1.out": os.path.join(out_dir, "pan.tif"),
      "source2.out": os.path.join(out_dir, "xs.tif"),
      "source3.out": os.path.join(out_dir, "tt.tif"),
    }
    pixel_type = {
      "source1.out": "int16",
      "source2.out": "int16",
      "source3.out": "uint8",
    }
    ext_fname = "gdal:co:COMPRESS=DEFLATE"

    #  ----> RUN ONCE HERE AGAIN
    patches.write(out_dict, pixel_type=pixel_type, ext_fname=ext_fname)

Can we do something about it?

We can provide sourceX.out but losing the cool features of write()