예제 #1
0
def update_reclass_function(lossyearmosaic, year_remap_function):
    print "removing function"
    arcpy.EditRasterFunction_management(lossyearmosaic, "EDIT_MOSAIC_DATASET",
                                        "REMOVE", year_remap_function)
    print "inserting function"
    arcpy.EditRasterFunction_management(lossyearmosaic, "EDIT_MOSAIC_DATASET",
                                        "INSERT", year_remap_function)
예제 #2
0
def remapmosaic(mosaic_location, forest_loss, biomass_weight, remapfunction,
                loss_tcd_function):

    path = os.path.dirname(os.path.abspath(__file__))
    arcpy.AddMessage("updating raster function paths")
    mosaic_path.mosaic_path(loss_tcd_function, mosaic_location, path)
    loss_tcd_function = os.path.join(
        os.path.dirname(os.path.abspath(__file__)), "loss_tcd2.rft.xml")
    # remove potential existing function
    tcdmosaic = os.path.join(mosaic_location, 'tcd')
    lossyr = os.path.join(mosaic_location, 'loss')

    arcpy.AddMessage("removing existing raster functions")
    arcpy.EditRasterFunction_management(tcdmosaic, "EDIT_MOSAIC_DATASET",
                                        "REMOVE", remapfunction)

    arcpy.EditRasterFunction_management(lossyr, "EDIT_MOSAIC_DATASET",
                                        "REMOVE", remapfunction)

    arcpy.AddMessage("inserting functions")
    arcpy.EditRasterFunction_management(tcdmosaic, "EDIT_MOSAIC_DATASET",
                                        "INSERT", remapfunction)

    arcpy.EditRasterFunction_management(lossyr, "EDIT_MOSAIC_DATASET",
                                        "INSERT", loss_tcd_function)
def createRefDTMMosaic(in_md_path, out_md_path, v_unit):
    a = datetime.now()
    if arcpy.Exists(out_md_path):
        arcpy.AddMessage("Referenced mosaic dataset exists " + out_md_path)
    else:
        arcpy.CreateReferencedMosaicDataset_management(in_dataset=in_md_path, out_mosaic_dataset=out_md_path, where_clause="TypeID = 1")
        
        raster_function_path = Raster.Contour_Meters_function_chain_path
        v_unit = str(v_unit).upper()
        if v_unit.find("FEET") >= 0 or v_unit.find("FOOT") >= 0 or  v_unit.find("FT") >= 0:
            raster_function_path = Raster.Contour_IntlFeet_function_chain_path
            #if v_unit.find("INTL") >= 0 or v_unit.find("INTERNATIONAL") >= 0 or v_unit.find("STANDARD") >= 0 or v_unit.find("STD") >= 0:
            #    raster_function_path = Raster.Contour_IntlFeet_function_chain_path
            if v_unit.find("US") >= 0 or v_unit.find("SURVEY") >= 0:
                arcpy.AddMessage("Using US FOOT Raster Function")
                raster_function_path = Raster.Contour_Feet_function_chain_path
            else:
                arcpy.AddMessage("Using INT FOOT Raster Function")
        else:
            arcpy.AddMessage("Using METER Raster Function")
                
        arcpy.EditRasterFunction_management(in_mosaic_dataset=out_md_path, edit_mosaic_dataset_item="EDIT_MOSAIC_DATASET", edit_options="REPLACE", function_chain_definition=raster_function_path, location_function_name="")
        Utility.addToolMessages()
        
        arcpy.CalculateStatistics_management(in_raster_dataset=out_md_path, x_skip_factor=SKIP_FACTOR, y_skip_factor=SKIP_FACTOR, ignore_values="", skip_existing="OVERWRITE", area_of_interest="Feature Set")
    
        doTime(a, "Created referenced mosaic dataset " + out_md_path)
예제 #4
0
def createReferenceddMosaicDataset(in_md_path, out_md_path, spatial_ref,
                                   raster_v_unit):
    a = datetime.datetime.now()
    arcpy.CreateReferencedMosaicDataset_management(
        in_dataset=in_md_path,
        out_mosaic_dataset=out_md_path,
        coordinate_system=spatial_ref,
        number_of_bands="1",
        pixel_type="32_BIT_SIGNED",
        where_clause="",
        in_template_dataset="",
        extent="",
        select_using_features="SELECT_USING_FEATURES",
        lod_field="",
        minPS_field="",
        maxPS_field="",
        pixelSize="",
        build_boundary="BUILD_BOUNDARY")

    raster_function_path = Raster.Canopy_Density_function_chain_path

    arcpy.EditRasterFunction_management(
        in_mosaic_dataset=out_md_path,
        edit_mosaic_dataset_item="EDIT_MOSAIC_DATASET",
        edit_options="REPLACE",
        function_chain_definition=raster_function_path,
        location_function_name="")
    Utility.addToolMessages()

    # arcpy.CalculateStatistics_management(in_raster_dataset=out_md_path, x_skip_factor="1", y_skip_factor="1", ignore_values="", skip_existing="OVERWRITE", area_of_interest="Feature Set")

    arcpy.AddMessage(
        "\tNOTE: !!! Please edit the MR Point Density function. Change to replace input to 'Multiply LAST by 100' with this project's POINT_COUNT_LAST mosaic dataset.\n\n\t{}\n"
        .format(out_md_path))
    doTime(a, "Created DHM '{}'".format(out_md_path))
예제 #5
0
def remap_threshold(geodatabase, threshold):

    # Apply a remap function to the tcd mosaic. Turns values of TCD into bins recoded to
    # values of 40, 80, etc.
    print("remaping mosaics in {} to {}".format(geodatabase, threshold))
    this_dir = os.path.dirname(os.path.abspath(__file__))
    remap_func = os.path.join(this_dir, "remap_gt" + str(threshold) + ".rft.xml")
    tcd_mosaic = os.path.join(geodatabase, "tcd")

    arcpy.EditRasterFunction_management(tcd_mosaic, "EDIT_MOSAIC_DATASET", "REPLACE", remap_func)
예제 #6
0
    def createReferencedMD(self):
        self.log("Creating reference mosaic datasets:",
                 self.const_general_text)

        for k in self.dic_derive_lst.keys():

            for r in self.dic_derive_lst[k]['ref'].keys():

                try:
                    mdPath = os.path.join(self.m_base.m_geoPath, r)

                    inMosaic = self.dic_derive_lst[k]['key']
                    refMosaic = os.path.join(self.m_base.m_geoPath, r)

                    self.log("Creating MD:" + r, self.const_general_text)

                    if not arcpy.Exists(mdPath):
                        try:
                            if (len(self.dic_ref_info) > 0):

                                in_dataset = self.m_base.getInternalPropValue(
                                    self.dic_ref_info, 'in_dataset')
                                _p, _f = os.path.split(in_dataset)
                                if (_p == '' and _f != ''):
                                    in_dataset = os.path.join(
                                        self.m_base.m_geoPath, _f)

                                arcpy.CreateReferencedMosaicDataset_management(
                                    in_dataset, refMosaic, self.srs,
                                    self.m_numBands, self.pixel_type,
                                    self.m_base.getInternalPropValue(
                                        self.dic_ref_info, 'where_clause'),
                                    self.m_base.getInternalPropValue(
                                        self.dic_ref_info,
                                        'in_template_dataset'),
                                    self.m_base.getInternalPropValue(
                                        self.dic_ref_info, 'extent'),
                                    self.m_base.getInternalPropValue(
                                        self.dic_ref_info,
                                        'select_using_features'),
                                    self.m_base.getInternalPropValue(
                                        self.dic_ref_info, 'lod_field'),
                                    self.m_base.getInternalPropValue(
                                        self.dic_ref_info, 'minPS_field>'),
                                    self.m_base.getInternalPropValue(
                                        self.dic_ref_info, 'maxPS_field>'),
                                    self.m_base.getInternalPropValue(
                                        self.dic_ref_info, 'pixelSize'),
                                    self.m_base.getInternalPropValue(
                                        self.dic_ref_info, 'build_boundary'))
                            else:
                                arcpy.CreateReferencedMosaicDataset_management(
                                    inMosaic, refMosaic, self.srs, "",
                                    self.pixel_type, "", "", "", "", "", "",
                                    "", "", "NO_BOUNDARY")
                        except:
                            self.log("\tFailed to create refrence MD  " + r,
                                     self.const_warning_text)
                            self.log(arcpy.GetMessages(),
                                     self.const_warning_text)

                    first_time = True
                    for fnc in self.dic_derive_lst[k]['ref'][r]:
                        self.log(
                            "\t\tAdding raster function: " + r + '->' +
                            os.path.basename(fnc), self.const_general_text)
                        try:
                            arcpy.EditRasterFunction_management(
                                refMosaic, "EDIT_MOSAIC_DATASET",
                                "REPLACE" if first_time else "INSERT", fnc)
                            first_time = False
                        except:
                            self.log(
                                "\t\t\tFailed to add raster function  " + fnc,
                                self.const_warning_text)
                            self.log(arcpy.GetMessages(),
                                     self.const_warning_text)
                except Exception as inst:
                    self.log(
                        "Failed to create/edit raster function reference mosaic dataset: "
                        + r, self.const_critical_text)
                    self.log(arcpy.GetMessages(), self.const_critical_text)
                    return False

        return True
예제 #7
0
        'endTimeField', 'footprintMayContainNoData', 'GCSTransforms',
        'isMultidimensional', 'JPEGQuality', 'LERCTolerance',
        'maxDownloadImageCount', 'maxDownloadSizeLimit', 'maxRastersPerMosaic',
        'maxRecordsReturned', 'maxRequestSizeX', 'maxRequestSizeY',
        'minimumPixelContribution', 'mosaicOperator', 'multidimensionalInfo',
        'orderBaseValue', 'orderField', 'processingTemplates',
        'rasterMetadataLevel', 'referenced', 'sortAscending', 'startTimeField',
        'timeValueFormat', 'useTime', 'variableAttributes', 'variableNames',
        'viewpointSpacingX', 'viewpointSpacingY'
    ]

    metadata = {}
    for propGroup in props:
        for prop in props[propGroup]:
            try:
                value = getattr(descObj, prop)
                metadata.update({propGroup + ': ' + prop: value})
            except:
                pass
    # print(type(metadata))
    return metadata


print("Adding raster function template.")
arcpy.EditRasterFunction_management(mosaic, "EDIT_MOSAIC_DATASET", "INSERT",
                                    rft, 'GPM_Stretch')
print("Added raster function.")

objMetaDict = scrapeMosaicMetadata(mosaic)
for attribute, value in objMetaDict.items():
    print('{} : {}'.format(attribute, value))