Thanks Chris. Please see below. On Thu, Nov 4, 2010 at 7:42 AM, Chris Marshall <[email protected]> wrote: > (1) In pnpoly() your $c seems to use bad value > stuff but does not have badflag set as far as > I can tell.
I had inadvertently omitted the badflag statement in the version of the code to which I linked. On adding the badflag command, yes, $c->ngood() does indeed print "805" as you noted below. > > (2) Your pnpoly() routine is not calculating the > area of the polygon so I'm not sure I understand > why it should give the same result as the > determinant calculation. Actually, each element in the piddle represents 1 km^2, so the number of good elements is the area. Hence, $c->ngood() is the area, which does match with the coordinates entered (807.5 and 805 are close enough for my purpose). My problem is a bit different. $c is the mask representing the selection polygon entered by the user. However, the underlying area of interest I want can be different. I get the actual area I want by multiplying the input piddle with the mask. All the piddle elements outside the mask are turned into BAD. All the elements from the landscape (the input piddle) that are inside the mask and are GOOD are multiplied by 1 to carry through with their values. Everything else becomes BAD. Hence I perform $d = $pdl * $c Now, all I have to do is to sum up the GOOD with $d->sum() and count the GOOD with $d->ngood() to get the sum and the area. Well, it is this multiplication that was not coming out with the expected answers. Turns out, it was the old "video scan" problem. The y coordinates from the screen are upside down with respect to PDL's world. Flipping them around got me the correct answer. Many thanks again. .. -- Puneet Kishor http://www.punkish.org Carbon Model http://carbonmodel.org Charter Member, Open Source Geospatial Foundation http://www.osgeo.org Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor Nelson Institute, UW-Madison http://www.nelson.wisc.edu ----------------------------------------------------------------------- Assertions are politics; backing up assertions with evidence is science ======================================================================= _______________________________________________ Perldl mailing list [email protected] http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
