Hy. How are you guys?
I am also using the same code to import .nc files to raster (.tif). But when I open the converted raster in ENVI, its spatial reference is distorted. Its longitude (x-axis) is from 0 to 360. which should be -180 to 180.
However, the latitudes are ok and showing data from -50 to 50.
I think I need to georefrence the raster. But i am not sure.
Below is my code. "I AM REALLY IN A TROUBLE. ANY HELP WOULD REALLY BE APPRECIATED."
import arcpy, os, time, datetime, calendar, glob
from arcpy import env
from arcpy.sa import *
arcpy.env.workspace = "C:/Users/UmairPC/Desktop/TRMM"
arcpy.env.overwriteOutput = True
arcpy.env.scratchWorkspace = "C:/Users/UmairPC/Desktop/TRMM"
InMemory_netcdf_raster = "r"
NetCDFfiles = arcpy.ListFiles("*.nc")
for filename in NetCDFfiles:
print("Processing: " + filename)
inNetCDF = arcpy.env.workspace + "/" + filename
# Process: Make NetCDF Raster Layer
arcpy.MakeNetCDFRasterLayer_md(inNetCDF, "r", "longitude", "latitude", InMemory_netcdf_raster, "", "", "BY_VALUE")
outRasterFolder = "C:/Users/UmairPC/Desktop/TRMM/check1"
fileroot = filename[0:(len(filename)-3)]
outTIFF = outRasterFolder + "/" + filename + ".tif"
# Process: Copy Raster
arcpy.CopyRaster_management(InMemory_netcdf_raster, outTIFF, "", "", "", "NONE", "NONE", "")
print "DONE"
#Make a separate raster *.img file for each dimension value (time) in a netcdf file import arcpy from arcpy import env from arcpy.sa import * import os # Set local variables inNetCDF = r"D:/DSE_work/FFDInetcdf/FEB2009FFDI/IDZ00026_VIC_ADFD_FFDI_SFC.nc" env.workspace="D:/DSE_work/FFDInetcdf/FEB2009FFDI" outRasterFolder = "D:/data/FFDInetcdf/OutputRasters" variable = "FFDI_SFC" XDimension = "longitude" YDimension = "latitude" bandDimension = "" dimensionValues = "time" valueSelectionMethod = "BY_VALUE" # loop through all dimension and show the values ncFP = arcpy.NetCDFFileProperties(inNetCDF) ncDim = ncFP.getDimensions() for dim in ncDim: print "dimension name is:", dim dimsize = ncFP.getDimensionSize(dim) for i in range(0,dimsize): dimvalues=ncFP.getDimensionValue(dim,i) print dimvalues # Execute MakeNetCDFRasterLayer arcpy.MakeNetCDFRasterLayer_md(inNetCDF, variable, XDimension, YDimension, (outRasterFolder,dimvalues), #output folder named by dimension value bandDimension, (dimensionValues,dimvalues), #need to feed in each day (value from the time dimension e.g time 2/02/2009) valueSelectionMethod) #export raster layer (from scratch workspace) to raster output folder as *.img Rasters_List=[] for Rasters in arcpy.ListRasters(): Rasters_List.append(Rasters) arcpy.CopyRaster_management(outRasterFolder, ((os.path.join(outRasterFolder, "netcdf_"+rasters))), "", "", "NONE", "NONE", "") print "end of processing"
import arcpy InNetCDF = r"C:\temp\tos_O1_2001-2002.nc" try: ncFP = arcpy.NetCDFFileProperties(InNetCDF) ncDim = ncFP.getDimensions() # loop through all dimension and show the value for dim in ncDim: print dim top = ncFP.getDimensionSize(dim) for i in range(0,top): print ncFP.getDimensionValue(dim,i) except: print arcpy.GetMessages(2)
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.