Retrieving a subset of the points effectively depends on the exact format you are using. Assuming you store your raster array as an integer array of integers, you can extract the following points:
from numpy import *
def points_in_circle(circle, arr):
"A generator to return all points whose indices are within given circle."
i0,j0,r = circle
def intceil(x):
return int(ceil(x))
for i in xrange(intceil(i0-r),intceil(i0+r)):
ri = sqrt(r**2-(i-i0)**2)
for j in xrange(intceil(j0-ri),intceil(j0+ri)):
yield arr[i][j]
points_in_circle , . , yield return. , , . . . Python , yield.
, . , , . , , .
points_in_circle:
N, M = 3200, 3200
i0, j0, r = 70, 20, 12.3
raster = fromfunction(lambda i,j: 100+10*i+j, (N, M), dtype=int)
print "raster is ready"
print raster
pts_iterator = points_in_circle((i0,j0,r), raster)
pts = array(list(pts_iterator))
print pts.size, "points extracted, sum = ", sum(pts)
10 .
, -, .