counting pixel values within polygons

Michael Hearne Michael.Hearne at noaa.gov
Fri Jan 26 10:27:33 PST 2001


Mapserver users - We're in the midst of planning a project here dealing
with raster data analysis.

I wrote a quick (read: cheesy) C routine that counts the pixels in an
image that have the value X.  I can (and probably will) extend this to
be able to get some subset of that image and count the pixels in that
subset.  This all should be easy.  My users, however, would like to see
all of the pixels inside of a particular polygon (shapefile).  There is
an article on the web talking about various solutions to the
"point-in-a-polygon" problem - 

http://home.earthlink.net/~bobstein/inpoly/

and just stealing that code looks pretty easy.

What I am more uncertain about is the process of extracting all of the
nodes (is that the right word?) of a shapefile polygon and passing them
to one of these "point-in-a-polygon" routines.  Does the mapserver
source code include a routine that would make this simple, or is there
other stuff out there to simplify this process?

I have a fairly short amount of time that I'll be allowed to devote to
this process, so the easier the better.

Thanks!
-- 
Michael G. Hearne     	  	email: Michael.Hearne at noaa.gov  
Coastal Remote Sensing  		phone: 843 740-1281             
TPMC/NOAA Coastal Services Center	fax:   843 740-1312       
2234 S. Hobson Ave.,    Charleston, SC 29407



More information about the MapServer-users mailing list