I am working with raster data on a worldwide level with a resolution of 30 arc seconds.
I need to export the data into a table format but given the high resolution you can not run the "Sample" (Spatial Analyst) command for the entire dataset at once.

Therefore, I have created a mask for each country(with The Set Null command). I was trying to write a code in Python, using a loop where each time the mask will become
a different zone, i.e. env.mask = zone1, then zone2 and so on.
However, I suppose that within a python session one cannot keep on changing the mask using a loop. Could you kindly suggest a way loop the mask (so that I can just have one code for all the countries but my program still runs)?

1 Answer
1

One way to do it is to use a cursor, which lets you work through your data row by row. Since each row should represent a polygon (Country in your case) you can loop through running the Clip each time. Something to be aware of are countries that have islands (multiple polygons). You'll want to make sure that the data are in multipart polygons as opposed to separate features.

This example runs in the python window since it references a feature layer in the ArcMap active window as opposed to a path name.