import arcpy import glob, os import time from time import localtime from time import strftime import datetime tic = time.clock() #*********** PRINCIPALES VARIABLES ************* arcpy.env.overwriteOutput = True prefijo = "PruebaPronostico.SDE." variable = "pslv" inNetCDF = "C:\Datos_IIE\pruebasmosaico\SalidasNETCDF/DOMAIN1_2013070318.nc" outLoc = "Database Connections/Con_PruebaPronostico.sde/" outLoc2 = "C:\Datos_IIE\pruebasmosaico/raster/" # Process: Create Mosaic Dataset arcpy.CreateMosaicDataset_management(outLoc, variable, "PROJCS['Lambert_Conformal_Conic',GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Lambert_Conformal_Conic'],PARAMETER['False_Easting',0.0],PARAMETER['False_Northing',-27.0],PARAMETER['Central_Meridian',-124.17],PARAMETER['Standard_Parallel_1',0.0],PARAMETER['Standard_Parallel_2',0.0],PARAMETER['Scale_Factor',1.0],PARAMETER['Latitude_Of_Origin',0.0],UNIT['Kilometer',1000.0]];-20037.7 -30225.3 149134210447.956;1 1;1 1;0.000001;2;2;IsHighPrecision", "", "") nc_FP = arcpy.NetCDFFileProperties(inNetCDF) nc_Dim = nc_FP.getDimensions() #rr = outLoc2 + '*' #r = glob.glob(rr) #for e in r: # os.remove(e) test = outLoc + '*' r = glob.glob(test) list = [] for i in r: os.remove(i) for dimension in nc_Dim: top = nc_FP.getDimensionSize(dimension) for i in [0, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120]: if dimension == "time": dimension_values = nc_FP.getDimensionValue(dimension, i) daat = "time '"+str(dimension_values)+ "'" print dimension_values nowFile = str(i) testt = dimension_values.replace("/","").replace(":","").replace(".","").replace("'","").replace(' ','') rast = name6 + name5 + name4 + "_" + name7 list.append(dimension_values) rastt = "time" + nowFile print rast # Convierte todos los tiempos del NETCDF A LAYER arcpy.MakeNetCDFRasterLayer_md(inNetCDF, variable, "lon", "lat", testt, "", daat, "BY_VALUE") # CONVIERTE LAS LAYER A RASTER Y LOS GUARDA EN EL DIRECTORIO INDICADO arcpy.CopyRaster_management(testt, outLoc2 + rastt, "", "", "-3,402823e+038", "NONE", "NONE", "", "NONE", "NONE") #arcpy.MakeRasterLayer_management(outLoc2 + rastt, "rastt", "#", "feature.shp", "1") arcpy.MakeRasterLayer_management(outLoc2 + rastt, rastt, "", "0 706.764 5373 4729.764", "") # APLICAR SIMBOLOGÍA arcpy.ApplySymbologyFromLayer_management (rastt, "C:\Datos_IIE\pruebasmosaico\sombologia.lyr") # Process: Add Rasters To Mosaic Dataset arcpy.AddRastersToMosaicDataset_management(outLoc + variable, "Raster Dataset", rastt, "UPDATE_CELL_SIZES", "NO_BOUNDARY", "NO_OVERVIEWS", "", "0", "1500", "", "", "SUBFOLDERS", "ALLOW_DUPLICATES", "true", "true", "NO_THUMBNAILS", "") #Assign colormap using clr file ###arcpy.AddColormap_management(outLoc2 + rast, "#", "C:/Datos_IIE/pruebasmosaico/test3.clr") # Process: Add Field arcpy.AddField_management(outLoc + variable, "tiempo", "DATE", "", "", "", "T", "NULLABLE", "NON_REQUIRED", "") # Process: Calcular stadisticas arcpy.BatchCalculateStatistics_management(outLoc + variable) # Agregamos el tiempo a los raster dentro del mosaico mm = len(list) for j in range(1, mm): #******************************Funciona para una celda ********** with arcpy.da.UpdateCursor(outLoc + variable, ["tiempo", "OBJECTID"]) as cursor: for row in cursor: index = int(row[1]) print index row[0] = time.strftime(str(list[index-1])) cursor.updateRow(row) #******************************************************************* toc = time.clock() print toc - tic
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.