I have an interface to the GPC polygon clipping library for PDL. Unfortunately, GPU isn't GPL. We've had to buy a commercial license to use it, so it's not really a candidate for the PDL core...
-Judd ____________________________ Judd Taylor Software Engineer Orbital Systems, Ltd. 3807 Carbon Rd. Irving, TX 75038-3415 [email protected] (972) 915-3669 x127 ________________________________________ From: Chris Marshall [[email protected]] Sent: Wednesday, May 02, 2012 1:55 PM To: Steven Lembark Cc: [email protected] Subject: Re: [Perldl] Geometry, anyone? PDL-2.4.10 and later include a pnpoly routine which may be of use: pdldoc pnpoly Module PDL::Image2D pnpoly 'points in a polygon' selection from a 2-D piddle $mask = pnpoly($x, $y, $px, $py); For a closed polygon determined by the sequence of points in {$py,$py} the output of pnpoly is a mask corresponding to whether or not each coordinate (x,y) in the set of test points, {$x,$y}, is in the interior of the polygon. This is the 'points in a polygon' algorithm from <http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html> and vectorized for PDL by Karl Glazebrook. # define a 3-sided polygon (a triangle) $px = pdl( 3, 20, 34 ); $py = pdl( 3, 20, 3 ); $img = zeros(40, 40); # create test image $x = $img->xvals; # get x pixel coords $y = $img->yvals; # get y pixel coords # $tri is 0 everywhere except for points in polygon interior $tri = pnpoly($x,$y,$px,$py); As for more, PDL has a lot of tools to make such computations work (implementable and with good performance). The PDL home page is a good place to start for more information: http://pdl.perl.org --Chris On Wed, May 2, 2012 at 2:49 PM, Craig DeForest <[email protected]> wrote: > There is a very nice algorithm in Preparata and Shamos ("Computational > Geometry"). I, for one, would love to have a PDL::PlanarGeometry package > built, to treat 2xN PDLs as collections of points on the plane. Nice > algorithms to start with would include: > > - area > - hull > - Voronoi > - delaunay > - polygon union > - polygon intersection > - polygon clean > > > > On May 2, 2012, at 12:33 PM, Steven Lembark wrote: > >> >> The nice people at Oracle implement all of their OpenGIS >> "contained within" geometry operators using bounding boxes >> only. This makes it impossible to select non-rectangular >> areas from a map. >> >> Google has gotten me nowhere looking for a PDL geometric >> operator library that (ideally) works on OpenGIS format >> data (WKB, WKT) or at least implements a "contains" >> operator suitable for a point and polygon. >> >> I am not trying to plot anything, just get a boolean >> outcome for, say, which state contains a given lat+long >> or which hospital is closesest to a given point. >> >> Checking CPAN for PDL+GIS gives me PDL::GIS::Proj, which >> isn't about GIS and is also pretty much dead. >> >> Q: Any suggestions for an implemention for selecting >> which of a (largeish) list of polygons contain a >> given point? >> >> thanks >> >> -- >> Steven Lembark 3646 Flora Pl >> Workhorse Computing St Louis, MO 63110 >> [email protected] +1 888 359 3508 >> >> _______________________________________________ >> Perldl mailing list >> [email protected] >> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl >> > > > _______________________________________________ > Perldl mailing list > [email protected] > http://mailman.jach.hawaii.edu/mailman/listinfo/perldl _______________________________________________ Perldl mailing list [email protected] http://mailman.jach.hawaii.edu/mailman/listinfo/perldl _______________________________________________ Perldl mailing list [email protected] http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
