Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Re: Splitting raster cells.

$
0
0
Quote:

Originally Posted by wesrockin View Post
I have a raster with a resolution of .47-meters, it contains one field that defines the presence or absence of forest canopy (1 or 0).

I need to use a 5-meter fishnet, (or 5-meter raster) to average the coverage within each each cell. The 5-meter raster obviously doesn't line up perfectly with the .47-meter raster. How do I get the exact percent coverage of the underlying forest canopy coverage into the 5-meter raster or fishnet.

The tool you are looking for is Aggregate. You can't get an "exact" aggregation - as .47 does not equally divide into 5 -- but it will be very close if you resample on the fly at a smaller cell size (.2) that equally divides into 5 meters.

Code:

from arcpy.sa import *
arcpy.env.cellSize = 0.2
# .2m * 25 = 5m (you could also use other values, say 0.1 and 50)
fiveMeterMean = Aggregate("p47rast",25,"MEAN")
# to get 0-100 percents:
fiveMeterPct = Aggregate("p47rast",5,"MEAN") * 100


Viewing all articles
Browse latest Browse all 2485

Trending Articles