Point in polygon
Whether points are inside a polygon with geodesic edges, by the winding rule and the even-odd rule, with holes, on the boundary within 1 mm, and how far each is from the edge.
2 of the points are inside the polygon by the winding rule. The first is inside.
| Point | Winding number | Winding rule | Even-odd rule | To the boundary |
|---|---|---|---|---|
| 1 | 1 | inside | inside | 111.027 m |
| 2 | 0 | outside | outside | 85.390 m |
| 3 | 1 | on-boundary | on-boundary | 0.000 m |
- First point
Provenance
- Computed by
- geometry.predicate.point-in-polygon 1.0.0, core 0.1.0
- Model
- Winding number = Σ over geodesic edges of the signed turn in azimuth seen from the point, ÷ 360° (azimuths by the geodesic inverse problem, Karney 2013); holes are turned opposite the outline first. Winding rule: inside when the number is not 0. Even-odd: inside when it is odd. On the boundary when the geodesic distance to an edge is under 1 mm
- Accuracy
- Exact on the ellipsoid for rings smaller than a hemisphere around the point; on-boundary within 1 mm
- Notes
- None
- Cites
- Karney, C. F. F., Journal of Geodesy, Algorithms for geodesics
Something look off?
How we got thisFormula, worked example, sources, and proof
Model: Winding number = Σ over geodesic edges of the signed turn in azimuth seen from the point, ÷ 360° (azimuths by the geodesic inverse problem, Karney 2013); holes are turned opposite the outline first. Winding rule: inside when the number is not 0. Even-odd: inside when it is odd. On the boundary when the geodesic distance to an edge is under 1 mm
Accuracy: Exact on the ellipsoid for rings smaller than a hemisphere around the point; on-boundary within 1 mm
When to use this: Use this to ask whether positions fall inside an area: aircraft in a restricted zone, vehicles in a geofence, sightings in a survey block, addresses in a district. Many points can be asked about at once. It answers by both of the rules in common use — the winding rule and the even-odd rule, which differ for a self-overlapping outline — and gives each point's distance to the nearest edge, so a point that is nearly in can be told from one that is comfortably in.
Limitations: Inside is decided on the ellipsoid with geodesic edges, which is not the same question as inside a polygon drawn on a projected map: near a boundary the two can differ, and the difference grows with the length of the edges. A point within a millimetre of an edge is reported as on the boundary rather than forced to one side, because at that range the answer belongs to the data rather than to the arithmetic. An outline that crosses itself has no single meaning of inside, which is why both rules are reported rather than one; where they differ, the shape is the problem. The ring must be smaller than a hemisphere around the point.
Worked example: A field with a pond, and three points. Source: inside, in a hole, and on the boundary. The verdicts are checked against GEOS 3.11.4 through shapely on PROJ's azimuthal equidistant plane over 51 points and five shapes — a planar test against a geodesic winding number, agreeing on every point — with the edge distances matching to 7.4e-6 relative.
You enter
- Points to test
- 40.001, -104.998 40.003, -104.995 40.003, -105
- Polygon
- 40, -105 40, -104.99 40.006, -104.99 40.006, -105 40.002, -104.997, 1 40.004, -104.997, 1 40.004, -104.994, 1 40.002, -104.994, 1
You get
- Points inside
- 2
- First point
- inside
Review: Not yet independently reviewed by a GIS professional.
Last verified: 2026-09-18, when a maintainer last confirmed this tool's sources at the issuer. See the sources ledger.
Status: version 1.0.0, core 0.1.0. See this tool in the verification report.
Checked against: 22 golden test vectors (download the test vectors, each with its source and tolerance). See how results are checked and every source.
Sources
- Algorithms for geodesics, Karney, C. F. F., Journal of Geodesy, Vol. 87, No. 1. pp. 43-55 (the inverse problem: azimuths from the test point).