Welcome to the Harris Geospatial documentation center. Here you will find reference guides and help documents.
﻿

>  Docs Center  >  Libraries  >  Motley  >  MGH_PNPOLY

MGH_PNPOLY

MGH_PNPOLY

## Purpose

Determine whether a point or set of points is inside a polygon.

## Calling Sequence

result = mgh_pnpoly(x, y, xp, yp)
result = mgh_pnpoly(x, y, xyp)

## Positional Parameters

x, y (input, numeric scalar or array
X, Y position(s) defining the point(s) to be tested.
xp, yp (input, numeric vector)
xyp (input, numeric array)
The polygon vertices as 2 separate vectors (xp, yp) OR a single
[2,n] array.

## Return Value

The function returns an array of the same shape as X. Each element
is 0 if the point is outside the polygon, 1 if it is inside the
polygon. The comp.graphics.algorithms has the following to say
about points on the boundary:
"It returns 1 for strictly interior points, 0 for strictly
exterior, and 0 or 1 for points on the boundary. The boundary
behavior is complex but determined; in particular, for a
partition of a region into polygons, each point is "in"
exactly one polygon. (See p.243 of [O'Rourke (C)] for a
discussion of boundary behavior.)"

## Procedure

Ray-crossing technique of WR Franklin from
Comp.graphics.algorithms FAQ.

## References

- "Misc Notes - WR Franklin",
http://www.ecse.rpi.edu/Homepages/wrf/misc.html: includes a
reference (broken @ Jul 2001) to his point-in-polygon code.
- Comp.graphics.algorithms FAQ,
http://www.faqs.org/faqs/graphics/algorithms-faq/: See subject
2.03
###########################################################################
Copyright (c) 1999-2015 NIWA:
http://www.niwa.co.nz/
Licensed under the MIT open source license:
http://www.opensource.org/licenses/mit-license.php
###########################################################################

## Modification History

Mark Fardal, 1999-11:
Written as PNPOLY.
Mark Fardal, 2001-07:
Added header.
Mark Hadfield, 2001-07:
Renamed MGH_PNPOLY. Output now matches input in shape, not just
size.
Mark Hadfield, 2009-09:
- Changed order of parameters: points to be tested come before
polygon.
- Polygon can now be specified as a [2,n] array.

© 2019 Harris Geospatial Solutions, Inc. |  Legal
My Account    |    Store    |    Contact Us