0

I have a NetCDF file in ArcMap that I created using the Make NetCDF Raster Layer tool. The band dimension of interest is the variable "time", which has 316 grids. I need each individual grid as its own raster. However I cannot find any way to do this other than individually displaying each date, and exporting it to a raster. Is there a way to iterate through the grids and export each as a raster? Or am I stuck manually exporting each and every one?

4
  • What have you tried? Most of the GUI tools have an ArcPy analog.
    – Vince
    Commented Nov 14, 2019 at 20:28
  • Mainly displaying each date in the "time" variable, and then exporting it as a raster. Wouldn't be terrible with 10 dates, but 316 isn't practical.
    – Wincow
    Commented Nov 14, 2019 at 23:41
  • No one here is likely to question the wisdom of scripting more than a dozen of anything, but we don't want to start getting a reputation as a coding service, either, so we ask that scripting questions provide a best effort at solving the problem.
    – Vince
    Commented Nov 15, 2019 at 2:03
  • I agree, I was wondering if there was a tool in Arcmap to expedite this. That being said, I did figure out how to do this in R. I will provide the code I wrote as a comment in case anyone else wants to replicate it. Tragically, accomplishing this in ArcGIS will remain a mystery
    – Wincow
    Commented Nov 15, 2019 at 16:01

1 Answer 1

-1

I figured out an alternative solution, however it is using R, rather than ArcGIS. I figure I'd post the code here in case anyone is trying to do the same thing.

#This script iterates through dimensions of a .nc file
#(in this case, sea surface temperatures of 316 separate
#dates), and writes them out as individual rasters.

#Import libraries
library(ncdf4)
library(raster)

#Introduce .nc file as a brick. Varname is the dimension
#of interest. All other dimensions are not included
#in the brick
b <- brick("/path/filename.nc", varname="sst")

#Get the names of the individual sst bands, 
#this will be important for iterating through the
#brick and exporting individual rasters
names1<- names(b)

#Begin iteration
for(i in names1){
  #Create string of sst band i
  paste1<- paste(i)

  #subset brick to sst band i
  b0<- b[[paste1]] 

  #write out raster
  writeRaster(b0, file = "file_path/file_name.tif", format = 'GTiff', overwrite = TRUE)

}
4
  • 1
    This doesn't answer the question, as posed.
    – Vince
    Commented Nov 15, 2019 at 18:38
  • It accomplishes the goal of exporting dimensions of a .nc file as individual rasters, albeit not in ArcMap. As far as I know, the only way to accomplish this using ArcMap is to individually select and export each one.
    – Wincow
    Commented Nov 16, 2019 at 0:48
  • That's almost certainly not the case. Playing with raster bands in Python can be quirky, but there's code samples in the documentation to work it out.
    – Vince
    Commented Nov 16, 2019 at 3:48
  • I meant using ArcMap tools so I can avoid coding using arcpy. I find R to be superior to Python when working with rasters anyway. Just my opinion
    – Wincow
    Commented Nov 16, 2019 at 19:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.