I have a NetCDF (CRU diurnal temperature data) for each year and month from 1901 to the 2016.

I would like to export individual rasters for a selection of the year and month options.

I would like to have rasters for 01/16/1982 to 12/16/2014. The band dimension is the variable "time" which is organized as above (01/16/1982). Each layer follows the same format except for February which is 02/15/YEAR.

I am not sure how to script this. I've seen other examples for getting only months for a certain year but never a time variable formatted they way mine is or for creating rasters that span multiple years.

Right now the dataset is global in coverage but I would only like a subset of African countries (I have a boundary shapefile).

Is there a way to loop through all the months of temperature data, extract the portion I want and export as new raster?

I've make the NetCDF, it is now called dtr_layer.

closed as off-topic by PolyGeo May 5 '18 at 21:56

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions seeking help to debug/write/improve code must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Providing a clear problem statement and evidence of a code attempt will help others to help you. See: How to create a Minimal, Complete, and Verifiable example." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

  • If you want to loop through a specific range of time, I recommand you run gdal_translate through a Python script, or something of the sorts. Also, start by creating your subset of african countries before anything, it will save you a lot of processing time. I know a way to loop through all the months and data, although currently my solution creates a separate raster file for each, would that work for you ? – GHRF Apr 26 '18 at 9:25
  • Thank you for this feedback. Yes I'd like a separate raster for each file. – Isabel M Apr 30 '18 at 20:46