![]() #Make a separate raster *.img file for each dimension value (time) in a netcdf file I got a better code now but it's not really perfect yet PS - I can't find the 'green checkmark' that is supposed to indicate this answered my question so I'll just say, "This answered my question!". I noticed you had a different method elsewhere in this thread. I used an inner loop with Select by Dimension to evaluate each month in each netcdf file. Thank you! I meant to write earlier that this script idea worked like a charm. ![]() But we should leave some of the fun stuff for you. For example, you'll need to make sure each output raster is given a unique, meaningful name. Note that this is only the start of the script. # now you can loop through your list and process each file one at a timeĪp.md.MakeNetCDFRasterLayer(cdf, ) # just insert the path to your folder holding the netCDF filesĬdfList = glob.glob('C:\\examplefolder\\*.nc') # this will give you a Python list object that you can use to batch process all of your files Your first step should be to read the documentation and make sure you understand what information you need to run the MakeNetCDFRasterLayer tool. This type of task is very common in GIS work and, fortunately, requires only a very simple script. Obviously you can't just copy-and-paste this code, but this should give you an idea of how to set it up. # this will convert the THIRD time step in your netCDF file to a raster layerĪrcpy.MakeNetCDFRasterLayer_md(inNCfiles, "precipitation_amount", "lon", "lat", TempLayerFile3, "#", "TIME 2", "BY_INDEX") # this will convert the SECOND time step in your netCDF file to a raster layerĪrcpy.MakeNetCDFRasterLayer_md(inNCfiles, "precipitation_amount", "lon", "lat", TempLayerFile2, "#", "TIME 1", "BY_INDEX") # this will convert the FIRST time step in your netCDF file to a raster layerĪrcpy.MakeNetCDFRasterLayer_md(inNCfiles, "precipitation_amount", "lon", "lat", TempLayerFile1, "#", "TIME 0", "BY_INDEX") Let's assume that your data are in time series, so the "dimension value" is "TIME": I would try to use "BY_INDEX" instead of "BY_VALUE". You're looping through your files fine, but you need to add another 'inner' loop to go through an individual file. Note that you need to call arcpy.MakeNetCDFRasterLayer_md() for each time step in each netCDF file. OutRaster = OutputFolder + "/" + filerootĪrcpy.MakeNetCDFRasterLayer_md(inNCfiles, "precipitation_amount", "lon", "lat", TempLayerFile, "", "", "BY_VALUE")Īrcpy.CopyRaster_management(TempLayerFile, outRaster + ".tif", "", "", "", "NONE", "NONE", "") # Loop through a list of files in the workspace OutputFolder = "S:/PM_data/Climate_Idaho/Output/pr_raster" so it reads individual value.Ī = "S:/PM_data/Climate_Idaho/Raw/pr" I have been trying to modify the code from this forum. ![]() I haven't figured out how to loop through each individual value in the netCDF file yet. The problem is that it only reads the first value. I got it to loop through every file in a folder. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |