# Generate command for available RAM otb_input_ram = generate_command('-ram ', False, input_ram, False) command_list.append(otb_input_ram) # Generate command for output confusion matrix if len(out_conf_matrix) > 0: otb_out_conf_matrix = generate_command('-io.confmatout ', True, out_conf_matrix, False) command_list.append(otb_out_conf_matrix) # Generate command for output model file otb_out_model = generate_command('-io.out ', True, out_model, False) command_list.append(otb_out_model) # Generate full command for OTB otb_write_output = execute_command('otbcli_TrainImagesClassifier ', command_list, workspace, otb_dir) # Save command to log with open(log_file, 'w') as f: f.write('Train Image Classifier (Bayes) Log') f.write('\nTimestamp: {}'.format(ts)) f.write('\nInput Images: {}'.format(input_images.split(';'))) f.write('\nTrain/Validation Sample Ratio: {}'.format( input_train_validation_ratio)) f.write( '\nBound sample number minimum: {}'.format(input_bound_sample_num_min)) f.write('\nDefault Elevation: {}'.format(input_default_elev)) f.write('\nMaximum Depth of the Tree: {}'.format(input_max_depth_tree)) f.write('\nMinimum Number of Samples in Each Node: {}'.format( input_min_samples_node)) f.write('\nTermination Criteria for Each Regression Tree: {}'.format(
command_list.append(otb_output_centroid_file) # Generate command for input mask value otb_input_mask_value = generate_command('-nodatalabel ', False, input_mask_value, False) command_list.append(otb_input_mask_value) # Generate user seed otb_input_seed = generate_command('-rand ', False, input_seed, False) command_list.append(otb_input_seed) otb_output_file = generate_command('-out ', True, output_file, False) command_list.append(otb_output_file) # Generate full command for OTB otb_write_output = execute_command('otbcli_KMeansClassification ', command_list, workspace, otb_dir) # Save command to log with open(log_file, 'w') as f: f.write('K Means Classification Log') f.write('\nTimestamp: {}'.format(ts)) f.write('\nImage Input: {}'.format(input_image)) f.write('\nValidity Mask: {}'.format(input_validity_mask)) f.write('\nTraining Set Size: {}'.format(input_training_set_size)) f.write('\nNumber of classes: {}'.format(input_number_of_classes)) f.write('\nMax Number of Iterations: {}'.format(input_max_num_iterations)) f.write('\nMask Value: {}'.format(input_mask_value)) f.write('\nSampler Type: {}'.format(input_sampler_type)) f.write('\nOutput centroid file: {}'.format(output_centroid_file)) f.write('\nOutput image: {}'.format(output_file)) f.write('\nOTB Command: {}'.format(otb_write_output))
# Generate command for input classified image otb_input_train_shp = generate_command('-in ', True, input_image, False) command_list.append(otb_input_train_shp) # Generate command for truth type otb_input_truth_type = generate_command('-ref ', False, 'raster', False) command_list.append(otb_input_truth_type) # Generate command for input ref image otb_input_ref_image = generate_command('-ref.raster.in ', True, input_ref_image, False) command_list.append(otb_input_ref_image) # Generate command for value for nodata pixels otb_input_value_for_nodata = generate_command('-ref.raster.nodata ', False, input_value_for_nodata, False) command_list.append(otb_input_value_for_nodata) # Generate command for matrix output otb_output_matrix_output = generate_command('-out ', False, output_matrix_output, False) command_list.append(otb_output_matrix_output) # Generate full command for OTB otb_write_output = execute_command('otbcli_ComputeConfusionMatrix ', command_list, workspace, otb_dir) # Save command to log with open(log_file, 'w') as f: f.write('Compute Confusion Matrix Log') f.write('\nTimestamp: {}'.format(ts)) f.write('\nInput image: {}'.format(input_image)) f.write('\nOTB Command: {}'.format(otb_write_output))
False) command_list.append(otb_input_before_image) # Generate command for input image (after) otb_input_after_image = generate_command('-in2 ', True, input_after_image, False) command_list.append(otb_input_after_image) # Generate command for ram usage otb_input_ram = generate_command('-ram ', False, input_ram, False) command_list.append(otb_input_ram) # Generate command for output change map otb_output_change_map = generate_command('-out ', True, output_change_map, False) command_list.append(otb_output_change_map) # Generate full command for OTB otb_write_output = execute_command('otbcli_MultivariateAlterationDetector ', command_list, workspace, otb_dir) # Save command to log with open(log_file, 'w') as f: f.write('Multivariate Alteration Detector Log') f.write('\nTimestamp: {}'.format(ts)) f.write('\nInput Before Image: {}'.format(input_before_image)) f.write('\nInput After Image: {}'.format(input_after_image)) f.write('\nInput RAM Limit: {}'.format(input_ram)) f.write('\nOutput Change Map: {}'.format(output_change_map)) f.write('\nOTB Command : {}'.format(otb_write_output))