

def earth_engine_classifier(domain, b, classifier_name, extra_args={
    
}):
    'Apply EE classifier tool using a ground truth image.'
    training_domain = None
    training_domain = domain.training_domain
    if (not training_domain):
        raise Exception('Cannot run classifier algorithm without a training domain!')
    training_image = _create_learning_image(training_domain, compute_modis_indices(training_domain))
    if training_domain.training_features:
        args = {
            'training_features': training_domain.training_features,
            'training_property': 'classification',
            'crs': 'EPSG:4326',
            'crs_transform': [8.983152841195213e-05, 0, (- 180), 0, (- 8.983152841195213e-05), 90],
        }
    elif training_domain.ground_truth:
        args = {
            'training_image': training_domain.ground_truth,
            'training_band': 'b1',
            'training_region': training_domain.bounds,
        }
    else:
        args = {
            'training_image': get_permanent_water_mask(),
            'training_band': 'b1',
            'training_region': training_domain.bounds,
        }
    common_args = {
        'image': training_image,
        'subsampling': 0.2,
        'max_classification': 2,
        'classifier_mode': 'classification',
        'classifier_name': classifier_name,
    }
    args.update(common_args)
    args.update(extra_args)
    classifier = ee.apply('TrainClassifier', args)
    classified = _create_learning_image(domain, b).classify(classifier).select(['classification'], ['b1'])
    try:
        try:
            skyboxSensor = domain.skybox
        except:
            skyboxSensor = domain.skybox_nir
        classified = classified.focal_min(13, 'circle', 'meters').focal_max(13, 'circle', 'meters')
    except:
        pass
    return classified

dataset/ETHPy150Open nasa/CrisisMappingToolkit/cmt/modis/ee_classifiers.py earth_engine_classifier/original