2

I have a multiband (1140) raster file in tiff format that I want to subset. Each band represents a prediction of monthly rainfall (12 bands for each year) over a 95 year period (12*95=1140). I need to subset the raster dataset into 10 year increments (120 bands), but cannot figure out how to do this with a multiband file. The output file would simply be a subset of the original raster dataset.

Do I first need to separate into individual bands? I have found a way to create a composite multiband raster file from individual bands (http://resources.arcgis.com/en/help/main/10.1/index.html#//00170000009p000000), but have been unable to find a method for subsetting a multiband raster file in ArcGIS 10.1 for Desktop.

3
  • 1
    You have a multiband raster with 1140 bands? What type of data does the multiband raster contain? What type of subset are you trying to produce? Finally, what does the final product look like? I am unclear about what you mean by "divide up the raster file by increments of 12". Thanks for clarifying these points.
    – Aaron
    Oct 14, 2014 at 20:11
  • OK, I think your question text is wrong. when you say each band is for a 95 year period but also that 120 bands is 10 years....makes me interpret that as 1 band per month, total of 95 years (1140 bands), and 120 bands per 10 year interval. Is this correct? And, if you were to chop up your raster into 9 or 10 chunks of 120 bands per chunk...do you want an aggregate of each of the 120 band chunks or just ~10 sets of 120 bands? Oct 14, 2014 at 23:07
  • You are correct and I was not clear in my question. I am basically wanting to take the 1140 bands and divide them into 10 multiband raster datasets with 120 bands (12 months * 10 years) in each dataset. Basically needing to know how to "deaggregate" multiband raster datasets.
    – user44796
    Oct 15, 2014 at 13:20

1 Answer 1

1

Basically you can treat each band as a separate raster and use it as input of the Composite Band tool. If you want to automate the process, there must be a structure in the name of the bands, like raster.tif\rainfall_year_month.

If you have such a structure (at least with the year mentioned) you could use this code (not fully tested):

arcpy.env.workspace = r'D:\raster.tif' # yes, you can use a raster dataset as workspace
for x in range (1900, 1994):           # range of years for which data is available
 listras = []
 year = "*{}*".format(x)               # turns year numeric value into string with wildcard
 for ras in arcpy.ListRasters(year):   # iterate over bands for a given year
  listras.append(ras)                  # add bands to a list 
 arcpy.CompositeBands_management(listras, r'D:\folder\rainfall_' + str(x)) # use this list as input of the Composite Bands tool

If you want to process the bands by decade, you should modify the range of values being iterated, for example:

for x in range (190, 199):

3
  • I am not sure what you mean by a structure in the name of the bands. the bands have names (band1, band2, etc). Is there a way to provide a naming convention after the creation of the multiband raster? Also, CompositeBands_management() appears to want individual raster files, not a list of files.
    – user44796
    Oct 16, 2014 at 16:18
  • With arcpy, it's easier to select bands if the year is included in their name, that's what I men by 'structure'. But if you know what band_1, band_2 etc correspond to, you can use another range, or wildcard, or whatever method to select the bands appropriately and feed them to the Composite Bands tool. Composite Bands DOES accept a list of rasters as input, and I don't think there is an easy way to rename raster bands (at least this property is not exposed with arcpy).
    – GISGe
    Oct 17, 2014 at 6:43
  • I accepted the answer, but don't think that I can get it to work for my situation, since I am not sure how to increment over the range of bands as you did in the example above. For those interested, I was able to do what I needed to do using R with one line of code (rasteroutput = subset(rasterinput,1:120), where 1:120 represents bands of interest and rasterinput is a rasterbrick object.
    – user44796
    Oct 17, 2014 at 14:31

Your Answer

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

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