Demo entry 6365599

arcpyCode

   

Submitted by ankit on May 20, 2017 at 13:56
Language: Python. Code size: 1.4 kB.

# -*- coding: utf-8 -*-
"""
Created on Fri May 19 20:20:36 2017
@author: AnkitDeshmukh
"""
import arcpy

arcpy.env.workspace = r"D:\Google Drive\Database01\ProcNetCDF"
arcpy.env.overwriteOutput = True

inNetCDF = r"D:\Google Drive\Database01\ProcNetCDF\APHRO.1951\APHRO1951.nc"
Output_Folder = r"D:\Google Drive\Database01\ProcNetCDF\ncOutput\\"

nc_FP = arcpy.NetCDFFileProperties(inNetCDF)
nc_Dim = nc_FP.getDimensions()

variable             = "precip"
x_dimension          = "longitude"
y_dimension          = "latitude"
band_dimension       = ""
dimension            = "time"
valueSelectionMethod = "BY_VALUE"

for dimension in nc_Dim:
    top = nc_FP.getDimensionSize(dimension)
    for i in range(0, top):
        if dimension == "time":
            dimension_values = nc_FP.getDimensionValue(dimension, i)
            nowFile = 'Precip_'+ str(dimension_values)
            #THIS IS THE NEW CODE HERE
            dv1 = ["time", dimension_values]
            dimension_values = [dv1]
            #END NEW CODE

            arcpy.MakeNetCDFRasterLayer_md(inNetCDF, variable, x_dimension, y_dimension, nowFile, band_dimension, dimension_values, valueSelectionMethod)
            arcpy.CopyRaster_management(nowFile, Output_Folder + nowFile + ".tif", "", "", "", "NONE", "NONE", "")
            print dimension_values, i 
            

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).