def download(stringDateNow, stringTimeNow, paramFN, paramDL): '''Download NetCDF data and add to mosaic dataset''' if DEBUG: print ("datetime to use: %s, %s" % (stringDateNow, stringTimeNow)) #Import required Multidimensional tools tbxMST = os.path.join(topFolder, tls, r"MultidimensionSupplementalTools\Multidimension Supplemental Tools.pyt") if DEBUG: print ("Importing %s" % tbxMST) arcpy.ImportToolbox(tbxMST) # Get target NetCDF data file names outputOpDataFile, outputWindDataFile = makeOutputFilePath(topFolder, NetCDFData, stringDateNow, paramFN) if os.path.exists(outputOpDataFile): print("removing existing %s" % outputOpDataFile) os.remove(outputOpDataFile) if os.path.exists(outputWindDataFile): print("removing existing %s" % outputWindDataFile) os.remove(outputWindDataFile) # Get source URL path in_url = makeSourceURLPath(stringDateNow, paramDL) #Run OPeNDAP to NetCDF tool if DEBUG: print("in_url: %s" % in_url) print("variable: %s" % opVariables) print("dimension: %s" % timeDimension ) print ("OPeNDAP Tool run for Operational Weather variables...") arcpy.OPeNDAPtoNetCDF_mds(in_url, opVariables, outputOpDataFile, geoExtent, timeDimension, "BY_VALUE") #Run OPeNDAP to NetCDF tool print ("OPeNDAP Tool run for Wind variables...") arcpy.OPeNDAPtoNetCDF_mds(in_url, windVariables, outputWindDataFile, geoExtent, timeDimension, "BY_VALUE") targetOpDataMosaic = os.path.join(topFolder, gdb, r"OperationalWeather.gdb\OperationalData") targetWindDataMosaic = os.path.join(topFolder, gdb, r"OperationalWeather.gdb\OperationalWind") # Remove Rasters From Mosaic Dataset if REMOVE_EXISTING_RASTERS: print ("Removing existing rasters from Operational Weather...") arcpy.RemoveRastersFromMosaicDataset_management(targetOpDataMosaic, "OBJECTID >=0", "NO_BOUNDARY", "NO_MARK_OVERVIEW_ITEMS", "NO_DELETE_OVERVIEW_IMAGES", "NO_DELETE_ITEM_CACHE", "REMOVE_MOSAICDATASET_ITEMS", "NO_CELL_SIZES") print ("Removing existing rasters from Wind...") arcpy.RemoveRastersFromMosaicDataset_management(targetWindDataMosaic, "OBJECTID >= 0", "UPDATE_BOUNDARY", "MARK_OVERVIEW_ITEMS", "DELETE_OVERVIEW_IMAGES", "DELETE_ITEM_CACHE", "REMOVE_MOSAICDATASET_ITEMS", "UPDATE_CELL_SIZES") # Add Rasters To Mosaic Dataset print ("Adding new rasters from Operational Weather...") arcpy.AddRastersToMosaicDataset_management(targetOpDataMosaic, "NetCDF", outputOpDataFile, "UPDATE_CELL_SIZES", "UPDATE_BOUNDARY", "NO_OVERVIEWS", "", "0", "1500", "", "*.nc", "SUBFOLDERS", "ALLOW_DUPLICATES", "NO_PYRAMIDS", "NO_STATISTICS", "NO_THUMBNAILS", "", "NO_FORCE_SPATIAL_REFERENCE") print ("Adding new rasters from Wind...") arcpy.AddRastersToMosaicDataset_management(targetWindDataMosaic, "NetCDF", outputWindDataFile, "UPDATE_CELL_SIZES", "UPDATE_BOUNDARY", "NO_OVERVIEWS", "", "0", "1500", "", "*.nc", "SUBFOLDERS", "ALLOW_DUPLICATES", "NO_PYRAMIDS", "NO_STATISTICS", "NO_THUMBNAILS", "", "NO_FORCE_SPATIAL_REFERENCE") return
def removeFromMosaics(data): ''' remove rasters from mosaic dataset ''' base = os.path.basename(data) print("Removing existing mosaics from: " + str(base)) try: if base == "OperationalData": arcpy.RemoveRastersFromMosaicDataset_management( data, "OBJECTID >=0", "NO_BOUNDARY", "NO_MARK_OVERVIEW_ITEMS", "NO_DELETE_OVERVIEW_IMAGES", "NO_DELETE_ITEM_CACHE", "REMOVE_MOSAICDATASET_ITEMS", "NO_CELL_SIZES") return True elif base == "OperationalWind": arcpy.RemoveRastersFromMosaicDataset_management( data, "OBJECTID >= 0", "UPDATE_BOUNDARY", "MARK_OVERVIEW_ITEMS", "DELETE_OVERVIEW_IMAGES", "DELETE_ITEM_CACHE", "REMOVE_MOSAICDATASET_ITEMS", "UPDATE_CELL_SIZES") return True else: return False except NAMDownloadException as e: print("Error in removeFromMosaics: \n" + str(e.tb))
def deleteOutOfDateRasters(mymosaicDS): try: earlier = datetime.datetime.now() - datetime.timedelta(days=90) query = "DateObtained < date '" + earlier.strftime('%Y-%m-%d') + "'" arcpy.RemoveRastersFromMosaicDataset_management(mymosaicDS, query, "UPDATE_BOUNDARY", "MARK_OVERVIEW_ITEMS", "DELETE_OVERVIEW_IMAGES") files = glob.glob(myConfig['finalTranslateFolder'] + "\*.tif") rasterses = [] for file in files: theName = file.rsplit('\\', 1)[-1] theDate = theName.rsplit('_')[1] dateObject = datetime.datetime.strptime(theDate, "%Y%m%d") if earlier > dateObject: rasterses.append(theName) arcpy.env.workspace = myConfig['finalTranslateFolder'] for oldraster in rasterses: arcpy.Delete_management(oldraster) except Exception, e: logging.error('### Error occurred in deleteOutOfDateRasters ###, %s' % e)
def ReloadMD(): # Empty the mosaic dataset prior to reloading it arcpy.AddMessage("Removing previous forecast data from mosaic dataset...") arcpy.RemoveRastersFromMosaicDataset_management(inputMD, "1=1") # Add the rasters to the mosaic dataset arcpy.AddMessage("Adding new forecast data to mosaic dataset...") arcpy.AddRastersToMosaicDataset_management(inputMD, "Raster Dataset", forecastGDBPath) # Check something was imported result = int(arcpy.GetCount_management(inputMD).getOutput(0)) if result > 0: # Re-calculate statistics on the mosaic dataset arcpy.AddMessage("Calculating statistics on the newly loaded mosaic dataset") arcpy.CalculateStatistics_management(inputMD) # Re-build overviews on the mosaic dataset #arcpy.AddMessage("Building overviews on the mosaic dataset") #arcpy.BuildOverviews_management(inputMD) # Calculate the time fields on the mosaic dataset arcpy.AddMessage("Calculating the time fields on the mosaic dataset") locale.setlocale(locale.LC_TIME, '') mdLayer = "mdLayer" arcpy.MakeMosaicLayer_management(inputMD, mdLayer, "Category = 1") # Leave out overviews - only calculate fields on primary rasters arcpy.CalculateField_management(mdLayer, dateForecastImportedField, """time.strftime("%c")""", "PYTHON","#") arcpy.CalculateField_management(mdLayer, dateForecastEffectiveFromField, """time.strftime("%c", time.strptime(!Name!,""" + "\"" + weatherName + """%Y%m%dT%H%M"))""", "PYTHON", "#") arcpy.CalculateField_management(mdLayer, dateForecastEffectiveToField, "!" + dateForecastEffectiveFromField + "!", "PYTHON", "#")
def download(paramFN, paramDL): #Import custom toolbox required arcpy.ImportToolbox( topFolder + os.sep + tls + "\MultidimensionSupplementalTools\Multidimension Supplemental Tools.pyt" ) print("Toolbox imported") #Get present date and time patternDate = '%Y%m%d' patternTime = '%H:%M:%S' utcdate = datetime.utcnow() - timedelta(hours=N) ## stringDateNow = datetime.utcnow().strftime(patternDate) ## stringTimeNow = datetime.utcnow().strftime(patternTime) stringDateNow = utcdate.strftime(patternDate) stringTimeNow = utcdate.strftime(patternTime) print("datetime returned") #Insert present date into string for out_file stringToChange = topFolder + os.sep + NetCDFData + r"\nam%s" + paramFN + ".nc" stringToChange4 = r"http://nomads.ncep.noaa.gov/dods/nam/nam%s/nam" + paramDL stringToInsert = stringDateNow stringFinal = stringToChange % stringToInsert stringFinal4 = stringToChange4 % stringToInsert filename = "nam%s1hr00z.nc" % stringToInsert #------------------------------------------------------------------------------------------------------------------------------------------ #Declare variables to be added into OPeNDAP to NetCDF tool for general data in_url = stringFinal4 out_file = stringFinal #Run OPeNDAP to NetCDF tool arcpy.OPeNDAPtoNetCDF_mds(in_url, variable, out_file, extent, dimension, "BY_VALUE") #------------------------------------------------------------------------------------------------------------------------------------------- finishDownload = str(datetime.utcnow()) print "OPeNDAp Tool run and data download finished at" + " " + finishDownload print out_file #____________________________________________________________________________________________________________________________________________ #Data loading into Mosaic datasets. Input_Data = out_file output = topFolder + os.sep + gdb + "\OperationalWeather.gdb\\OperationalData" output2 = topFolder + os.sep + gdb + "\OperationalWeather.gdb\\OperationalWind" Raster_Type = "NetCDF" Raster_Type2 = topFolder + os.sep + NetCDFData + os.sep + "NETCDF_type.art.xml" print Raster_Type2 #Check if the geodatabases stated above exist if arcpy.Exists(output): print output + " " + "exists" else: print output + " " + "does not exist" if arcpy.Exists(output2): print output2 + " " + "exists" else: print output2 + " " + "does not exist" # Process: Remove Rasters From Mosaic Dataset arcpy.RemoveRastersFromMosaicDataset_management( output, "OBJECTID >=0", "NO_BOUNDARY", "NO_MARK_OVERVIEW_ITEMS", "NO_DELETE_OVERVIEW_IMAGES", "NO_DELETE_ITEM_CACHE", "REMOVE_MOSAICDATASET_ITEMS", "NO_CELL_SIZES") arcpy.RemoveRastersFromMosaicDataset_management( output2, "OBJECTID >=0", "NO_BOUNDARY", "NO_MARK_OVERVIEW_ITEMS", "NO_DELETE_OVERVIEW_IMAGES", "NO_DELETE_ITEM_CACHE", "REMOVE_MOSAICDATASET_ITEMS", "NO_CELL_SIZES") # Process: Add Rasters To Mosaic Dataset arcpy.AddRastersToMosaicDataset_management( output, Raster_Type, Input_Data, "UPDATE_CELL_SIZES", "UPDATE_BOUNDARY", "NO_OVERVIEWS", "", "0", "1500", "", "*.nc", "SUBFOLDERS", "ALLOW_DUPLICATES", "NO_PYRAMIDS", "NO_STATISTICS", "NO_THUMBNAILS", "", "NO_FORCE_SPATIAL_REFERENCE") print("Rasters added to" + " " + output) ##arcpy.AddRastersToMosaicDataset_management(output2, Raster_Type2 ,Input_Data, "UPDATE_CELL_SIZES", "UPDATE_BOUNDARY","NO_OVERVIEWS", "", "0", "1500", "", "*.nc", "SUBFOLDERS", "ALLOW_DUPLICATES", "NO_PYRAMIDS", "NO_STATISTICS", "NO_THUMBNAILS", "","NO_FORCE_SPATIAL_REFERENCE", "NO_STATISTICS", "") arcpy.AddRastersToMosaicDataset_management(output2, Raster_Type2, Input_Data) print("Rasters added to" + " " + output2) finishDataLoad = str(datetime.utcnow()) print "Data loading finished at" + " " + finishDataLoad #_____________________________________________________________________________________________________________________________________________ ## #Sort out wind data ## #add to a multiband raster ## ## rasIn = env.workspace + "\Ugrd10m" + ";" + env.workspace + "\Vgrd10m" ## outcomp = env.workspace + "\OperationalWind" ## ## #Make composite band raster ## arcpy.CompositeBands_management(rasIn, outcomp) ## finishWindDataProcessing = str(datetime.utcnow()) print "Wind data processing finished at" + " " + finishWindDataProcessing print " " print " " print "The script finished at" + " " + finishWindDataProcessing
# Process: Calculate Field arcpy.CalculateField_management( gdbideam_raster_GOES16_C13, g_ESRI_variable_4, g_ESRI_variable_5, "PYTHON_9.3", "try: \\n def CalculoFecha(field):\\n Fecha=field[4:]\\n return Fecha;\\nexcept:\\n pass;" ) # Process: Calculate Field (2) arcpy.CalculateField_management( gdbideam_raster_GOES16_C13, g_ESRI_variable_6, g_ESRI_variable_7, "PYTHON_9.3", "from datetime import datetime, date, timedelta\\ndef CalculoDias(Fecha):\\n try:\\n FechaImagen = datetime.strptime(Fecha[0:4]+Fecha[4:6]+Fecha[6:8],'%Y%m%d').date();\\n Diferencia = datetime.now().date()-FechaImagen;\\n return Diferencia.days;\\n except:\\n pass" ) # Process: Remove Rasters From Mosaic Dataset arcpy.RemoveRastersFromMosaicDataset_management( gdbideam_raster_GOES16_C13, g_ESRI_variable_8, "UPDATE_BOUNDARY", "MARK_OVERVIEW_ITEMS", "DELETE_OVERVIEW_IMAGES", "DELETE_ITEM_CACHE", "REMOVE_MOSAICDATASET_ITEMS", "UPDATE_CELL_SIZES") # Process: Make Table View try: arcpy.MakeTableView_management(gdbideam_raster_GOES16_C13, raster_GOES16_C13_View, "", "", g_ESRI_variable_9) except: pass # Process: Delete Identical try: arcpy.DeleteIdentical_management(raster_GOES16_C13_View, g_ESRI_variable_10, "", "0") except: pass
def download(paramFN,paramDL): #Import custom toolbox required arcpy.ImportToolbox(topFolder + os.sep + tls + "\MultidimensionSupplementalTools\Multidimension Supplemental Tools.pyt") print ("Toolbox imported") #Get present date and time patternDate = '%Y%m%d' patternTime = '%H:%M:%S' stringDateNow = datetime.utcnow().strftime(patternDate) stringTimeNow = datetime.utcnow().strftime(patternTime) print ("datetime returned") #Insert present date into string for out_file stringToChange = topFolder + os.sep + NetCDFData + r"\nam%s" + paramFN + ".nc" stringToChange2 = topFolder + os.sep + NetCDFData + r"\nam%s" + paramFN + "Wind.nc" stringToChange3 = r"http://nomads.ncep.noaa.gov/dods/nam/nam%s/nam" + paramDL stringToInsert = stringDateNow stringFinal = stringToChange % stringToInsert stringFinal2 = stringToChange2 % stringToInsert stringFinal3 = stringToChange3 % stringToInsert filename = "nam%s1hr00z.nc" % stringToInsert #Declare variables to be added into OPeNDAP to NetCDF tool for general data in_url = stringFinal3 out_file = stringFinal #Run OPeNDAP to NetCDF tool arcpy.OPeNDAPtoNetCDF_mds( in_url, variable, out_file, extent, dimension, "BY_VALUE") print ("OPeNDAP Tool run") #Declare variables to be added into OPeNDAP to NetCDF tool for download of wind data in_url2 = stringFinal3 out_file2 = stringFinal2 #Run OPeNDAP to NetCDF tool arcpy.OPeNDAPtoNetCDF_mds( in_url2, variable2, out_file2, extent, dimension, "BY_VALUE") print ("OPeNDAP Tool run") #____________________________________________________________________________________________________________________________________________ Input_Data = out_file Input_Data2 = out_file2 Raster_Type = "NetCDF" output = topFolder + os.sep + gdb + "\MAOWdata.gdb\\MAOWData" output2 = topFolder + os.sep + gdb + "\MAOWdata.gdb\\MAOWWind" #Check if the geodatabases stated above exist if arcpy.Exists(topFolder + os.sep + gdb): print "output exist" else: print "outout does not exist" if arcpy.Exists(topFolder + os.sep + gdb): print "output2 exist" else: print "output2 does not exist" # Process: Remove Rasters From Mosaic Dataset arcpy.RemoveRastersFromMosaicDataset_management(output, "OBJECTID >=0", "NO_BOUNDARY", "NO_MARK_OVERVIEW_ITEMS", "NO_DELETE_OVERVIEW_IMAGES", "NO_DELETE_ITEM_CACHE", "REMOVE_MOSAICDATASET_ITEMS", "NO_CELL_SIZES") arcpy.RemoveRastersFromMosaicDataset_management(output2, "OBJECTID >= 0", "UPDATE_BOUNDARY", "MARK_OVERVIEW_ITEMS", "DELETE_OVERVIEW_IMAGES", "DELETE_ITEM_CACHE", "REMOVE_MOSAICDATASET_ITEMS", "UPDATE_CELL_SIZES") print ("Removed Raster from Mosaic Dataset") # Process: Add Rasters To Mosaic Dataset arcpy.AddRastersToMosaicDataset_management(output, Raster_Type, Input_Data, "UPDATE_CELL_SIZES", "UPDATE_BOUNDARY", "NO_OVERVIEWS", "", "0", "1500", "", "*.nc", "SUBFOLDERS", "ALLOW_DUPLICATES", "NO_PYRAMIDS", "NO_STATISTICS", "NO_THUMBNAILS", "", "NO_FORCE_SPATIAL_REFERENCE") arcpy.AddRastersToMosaicDataset_management(output2, Raster_Type, Input_Data2, "UPDATE_CELL_SIZES", "UPDATE_BOUNDARY", "NO_OVERVIEWS", "", "0", "1500", "", "*.nc", "SUBFOLDERS", "ALLOW_DUPLICATES", "NO_PYRAMIDS", "NO_STATISTICS", "NO_THUMBNAILS", "", "NO_FORCE_SPATIAL_REFERENCE") print ("Rasters added to Mosaic Datasets - "+ filename)
def CreateMasterMosaicDataset(master_fgdb_path, master_md_name, MDMasterFC_path, masterCellSize_meters): Utility.printArguments(["master_fgdb_path", "master_md_name", "MDMasterFC_path", "masterCellSize_meters"], [master_fgdb_path, master_md_name, MDMasterFC_path, masterCellSize_meters], "B02 CreateMasterMosaicDataset") # Ensure the Master gdb exists if os.path.exists(master_fgdb_path): master_md_path = os.path.join(master_fgdb_path, master_md_name) arcpy.AddMessage("Full Master Mosaic Name: {0}".format(master_md_path)) if not arcpy.Exists(master_md_path): # SpatRefMaster = "PROJCS['WGS_1984_Web_Mercator_Auxiliary_Sphere',GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Mercator_Auxiliary_Sphere'],PARAMETER['False_Easting',0.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',0.0],PARAMETER['Standard_Parallel_1',0.0],PARAMETER['Auxiliary_Sphere_Type',0.0],UNIT['Meter',1.0],AUTHORITY['EPSG',3857]]" SpatRefMaster = RasterConfig.SpatRef_WebMercator # Create the Master Mosaic Dataset arcpy.CreateMosaicDataset_management(master_fgdb_path, master_md_name, coordinate_system=SpatRefMaster, num_bands="1", pixel_type="32_BIT_FLOAT", product_definition="NONE", product_band_definitions="#") Utility.addToolMessages() # If a boundary is specified (it is optional)... # Write one record to the boundary so it can be subsequently replaced by the import Mosaic Dataset Geometry tool addMasterBoundary(master_fgdb_path, master_md_name, MDMasterFC_path) Raster.addStandardMosaicDatasetFields(md_path=master_md_path) # arcpy.AddField_management(master_md_path, field_name="ProjectID", field_type="TEXT", field_precision="#", field_scale="#", # field_length="100", field_alias="#", field_is_nullable="NULLABLE", field_is_required="NON_REQUIRED", field_domain="#") # Utility.addToolMessages() # arcpy.AddField_management(master_md_path, field_name="ProjectDate", field_type="DATE", field_precision="#", field_scale="#", # field_length="#", field_alias="#", field_is_nullable="NULLABLE", field_is_required="NON_REQUIRED", field_domain="#") # Utility.addToolMessages() # arcpy.AddField_management(master_md_path, field_name="RasterPath", field_type="TEXT", field_precision="#", field_scale="#", # field_length="512", field_alias="#", field_is_nullable="NULLABLE", field_is_required="NON_REQUIRED", field_domain="#") # # Utility.addToolMessages() # arcpy.AddField_management(master_md_path, field_name="ProjectSrs", field_type="TEXT", field_precision="#", field_scale="#", # field_length="100", field_alias="#", field_is_nullable="NULLABLE", field_is_required="NON_REQUIRED", field_domain="#") # Utility.addToolMessages() # arcpy.AddField_management(master_md_path, field_name="ProjectSrsUnits", field_type="TEXT", field_precision="#", field_scale="#", # field_length="20", field_alias="#", field_is_nullable="NULLABLE", field_is_required="NON_REQUIRED", field_domain="#") # Utility.addToolMessages() # arcpy.AddField_management(master_md_path, field_name="ProjectSrsUnitsZ", field_type="TEXT", field_precision="#", field_scale="#", # field_length="20", field_alias="#", field_is_nullable="NULLABLE", field_is_required="NON_REQUIRED", field_domain="#") # Utility.addToolMessages() # arcpy.AddField_management(master_md_path, field_name="ProjectSource", field_type="TEXT", field_precision="#", field_scale="#", # field_length="20", field_alias="#", field_is_nullable="NULLABLE", field_is_required="NON_REQUIRED", field_domain="#") # Utility.addToolMessages() # arcpy.AddField_management(master_md_path, field_name="PCSCode", field_type="TEXT", field_precision="#", field_scale="#", # field_length="20", field_alias="#", field_is_nullable="NULLABLE", field_is_required="NON_REQUIRED", field_domain="#") # Utility.addToolMessages() # arcpy.AddMessage("Creating Indexes on previously created fields in Master GDB...") # Create indexes on all metadata fields to facilitate query # arcpy.AddIndex_management(master_md_path, fields="ProjectID", index_name="ProjectID", unique="NON_UNIQUE", ascending="ASCENDING") # Utility.addToolMessages() # arcpy.AddIndex_management(master_md_path, fields="ProjectDate", index_name="ProjectDate", unique="NON_UNIQUE", ascending="ASCENDING") # Utility.addToolMessages() # arcpy.AddIndex_management(master_md_path, fields="ProjectSrs", index_name="ProjectSrs", unique="NON_UNIQUE", ascending="ASCENDING") # Utility.addToolMessages() # arcpy.AddIndex_management(master_md_path, fields="ProjectSrsUnits", index_name="ProjectSrsUnits", unique="NON_UNIQUE", ascending="ASCENDING") # Utility.addToolMessages() # arcpy.AddIndex_management(master_md_path, fields="ProjectSrsUnitsZ", index_name="ProjectSrsUnitsZ", unique="NON_UNIQUE", ascending="ASCENDING") # Utility.addToolMessages() # arcpy.AddIndex_management(master_md_path, fields="ProjectSource", index_name="ProjectSource", unique="NON_UNIQUE", ascending="ASCENDING") # Utility.addToolMessages() # arcpy.AddIndex_management(master_md_path, fields="PCSCode", index_name="PCSCode", unique="NON_UNIQUE", ascending="ASCENDING") # Utility.addToolMessages() # Set the desired Master MD properties (non-default parameters are listed below): # default mosaic method is "BYATTRIBUTE" w ProjectDate # order_base = 3000 (a year far into the future) # default_compression_type="LERC" # limited the transmission_fields # start_time_field="ProjectDate" (in case we decide to enable time later) # max_num_of_records_returned="2000" (default is 1000) # max_num_of_download_items="40" (default is 20) # max_num_per_mosaic = "40" (default is 20) # data_source_type="ELEVATION" # cell_size = 1 # rows_maximum_imagesize="25000" # columns_maximum_imagesize="25000" # metadata_level = "BASIC" transmissionFields = CMDRConfig.TRANSMISSION_FIELDS arcpy.AddMessage("transmissionFields: {0}".format(transmissionFields)) arcpy.AddRastersToMosaicDataset_management(in_mosaic_dataset=master_md_path, raster_type="Raster Dataset", input_path=RasterConfig.MasterTempRaster, update_cellsize_ranges="UPDATE_CELL_SIZES", update_boundary="UPDATE_BOUNDARY", update_overviews="NO_OVERVIEWS", maximum_pyramid_levels="", maximum_cell_size="0", minimum_dimension="1500", spatial_reference="", filter="#", sub_folder="SUBFOLDERS", duplicate_items_action="ALLOW_DUPLICATES", build_pyramids="NO_PYRAMIDS", calculate_statistics="NO_STATISTICS", build_thumbnails="NO_THUMBNAILS", operation_description="#", force_spatial_reference="NO_FORCE_SPATIAL_REFERENCE") Utility.addToolMessages() arcpy.SetMosaicDatasetProperties_management(master_md_path, rows_maximum_imagesize="25000", columns_maximum_imagesize="25000", allowed_compressions="LERC;JPEG;None;LZ77", default_compression_type="LERC", JPEG_quality="75", LERC_Tolerance="0.001", resampling_type="BILINEAR", clip_to_footprints="NOT_CLIP", footprints_may_contain_nodata="FOOTPRINTS_MAY_CONTAIN_NODATA", clip_to_boundary="NOT_CLIP", color_correction="NOT_APPLY", allowed_mensuration_capabilities="#", default_mensuration_capabilities="NONE", allowed_mosaic_methods="NorthWest;Center;LockRaster;ByAttribute;Nadir;Viewpoint;Seamline;None", default_mosaic_method="ByAttribute", order_field=CMDRConfig.PROJECT_DATE, order_base="3000", sorting_order="ASCENDING", mosaic_operator="FIRST", blend_width="0", view_point_x="600", view_point_y="300", max_num_per_mosaic="40", cell_size_tolerance="0.8", cell_size="{0} {0}".format(masterCellSize_meters), metadata_level="BASIC", transmission_fields=transmissionFields, use_time="DISABLED", start_time_field=CMDRConfig.PROJECT_DATE, end_time_field="#", time_format="#", geographic_transform="#", max_num_of_download_items="40", max_num_of_records_returned="2000", data_source_type="ELEVATION", minimum_pixel_contribution="1", processing_templates="None", default_processing_template="None") Utility.addToolMessages() # arcpy.SetMosaicDatasetProperties_management(in_mosaic_dataset="C:/temp/MDMaster/MDMaster_DSM.gdb/DSM", rows_maximum_imagesize="25000", columns_maximum_imagesize="25000", allowed_compressions="None;JPEG;LZ77;LERC", default_compression_type="None", JPEG_quality="75", LERC_Tolerance="0.001", resampling_type="BILINEAR", clip_to_footprints="NOT_CLIP", footprints_may_contain_nodata="FOOTPRINTS_MAY_CONTAIN_NODATA", clip_to_boundary="NOT_CLIP", color_correction="NOT_APPLY", allowed_mensuration_capabilities="#", default_mensuration_capabilities="NONE", allowed_mosaic_methods="ByAttribute;NorthWest;Center;LockRaster;Nadir;Viewpoint;Seamline;None", default_mosaic_method="ByAttribute", order_field="Project_Date", order_base="3000", sorting_order="ASCENDING", mosaic_operator="FIRST", blend_width="0", view_point_x="600", view_point_y="300", max_num_per_mosaic="40", cell_size_tolerance="0.8", cell_size="1 1", metadata_level="BASIC", transmission_fields="Name;MinPS;MaxPS;LowPS;HighPS;Tag;GroupName;ProductName;CenterX;CenterY;ZOrder;Shape_Length;Shape_Area;Project_ID;Project_Date;Porject_Source;Project_SR_XY;Project_SR_XY_Units;Project_SR_XY_Code;Project_SR_Z_Units", use_time="DISABLED", start_time_field="Project_Date", end_time_field="", time_format="", geographic_transform="", max_num_of_download_items="40", max_num_of_records_returned="2000", data_source_type="ELEVATION", minimum_pixel_contribution="1", processing_templates="None", default_processing_template="None") # set statistics Min = -300 and Max = 2000M # set nodata = default no data value arcpy.SetRasterProperties_management(master_md_path, data_type="ELEVATION", statistics="1 0 2000 # #", stats_file="#", nodata="1 {}".format(RasterConfig.NODATA_DEFAULT)) Utility.addToolMessages() arcpy.RemoveRastersFromMosaicDataset_management(in_mosaic_dataset=master_md_path, where_clause="1=1", update_boundary="UPDATE_BOUNDARY", mark_overviews_items="MARK_OVERVIEW_ITEMS", delete_overview_images="DELETE_OVERVIEW_IMAGES", delete_item_cache="DELETE_ITEM_CACHE", remove_items="REMOVE_MOSAICDATASET_ITEMS", update_cellsize_ranges="UPDATE_CELL_SIZES") Utility.addToolMessages() else: arcpy.AddWarning("Master Mosaic Dataset already exists: {0}. Cannot continue".format(master_md_path)) else: arcpy.AddError("Master Geodatabase doesn't exist {0}".format(master_fgdb_path)) arcpy.AddMessage("Operation complete")
def removerasters(self, **kwargs): arcpy.RemoveRastersFromMosaicDataset_management(self.lname, **kwargs) DisplayMessages()