Index Ai Academy
Glossary · Phase 3 · Machine learning

Point in polygon

Also written: point-in-polygon, ray casting

Testing whether a point lies inside a shape, often by counting how many edges a ray from the point crosses: odd means inside.

Deciding whether a delivery address is inside a zone is the point-in-polygon test. The classic method casts a ray: draw a line from the point straight east, and count how many of the polygon's edges it crosses. An odd count means inside (you crossed in and never out), even means outside. For small zones you can treat longitude and latitude as plain x and y, because the shape distortion is the same for the point and the edges.

Try it now

Most location questions are one of four: how far, what's nearest, which zone, or which way around.

Learn it properly

Location data · Haversine distances, nearest places, GeoJSON, point in polygon and simple maps. About 40 minutes.

Create a free account See what's in the lesson

Other terms from the same lesson

Never trained an AI?

Teach a small one to write, right in your browser. It takes about 20 seconds and needs no account.

Teach it to write