This post will detail how to determine if a point with a longitude and a latitude resides within a polygon – an area comprised of multiple coordinates. There are two ways to accomplish the task, either in Python or in Javascript.
In Javacript – Turf package
In order to accomplish the task in Javacript, I used turf package. The first thing to do is to add this line to the HTML where the task takes place
<script src='https://npmcdn.com/@turf/turf/turf.min.js'></script>
Then, this is how the task is completed:
point = turf.point([longitude,latitude]); #the point in question
polygon = turf.polygon(#the polygon in question); #the polygon should come in the form of an array of points
turf.booleanPointInPolygon(point,poly) #return either True or False
In Python
First, install the following:
from shapely.geometry import shape, Point
Then, this is how the task is accomplished:
coord = Point([longitude, latitude]) #this is the point in question
polygon = shape(property['geometry']) #the geometry part of a typical GEOJSON
polygon.contains(coord) #should return either True or False
Hope it is helpful to whoever is looking for an answer to this issue