[gdal-dev] count unique combination in 2 tifs
Rutger
kassies at gmail.com
Fri Aug 10 06:34:21 PDT 2012
Hey,
If youre example data is realistic, or if you know the range of values on
forehand, this might work:
/a = np.random.randint(0,5,(5,5)) # generate some example data between 0 and
5
b = np.random.randint(0,5,(5,5)) # generate some example data between 0 and
5
# create a new array with the unique combinations, if your maximum value is
above 10, raise the multiplier accordingly
c = np.where(np.logical_and(a!=0,b!=0),a * 10 + b,0)
bins, hist = np.histogram(c,bins=56, range=(0,56))/
View the results with something like:
/for i in np.arange(len(hist)):
combo = str(i).rjust(2,'0')
print combo[0],combo[1], hist[i]/
Regards,
Rutger
--
View this message in context: http://osgeo-org.1560.n6.nabble.com/gdal-dev-count-unique-combination-in-2-tifs-tp4993978p4994407.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.
More information about the gdal-dev
mailing list