Extract polygon name if the geo-point is inside polygon ?. I have two dataset one with polygon name and polygon and other with location name and latitude and longitude.
Data 1 (Geopandas Dataframe)
COMMUNITY NAME POLYGON
New York MULTIPOLYGON (((55.1993358199345 25.20971347951325,
55.19385836251354 25.20134197109752.... 25.20971347951325)))
Chennai MULTIPOLYGON (((65.1993358199345 22.20871347951325,
55.19325836251354 15.20132197109752 .... 15.20971347951325)))
Data 2 (Data Frame)
STOP NAME LONGITUDE LANGITUDE
Chennai main stop 55.307228 25.248844
Cabra stop 55.278824 25.205862
USA stop NY 55.069368 24.973946
If the data 2 (stop_name) is inside in the data 1 (polygon) need to extract the name of the polygon. ie. if the USA Stop NY is present in any "New York" need to add the name in the new column in data2.
Sample code :
from shapely.geometry import Point, Polygon
# Create Point objects
p1 = Point(55.230830, 25.128038)
p2 = Point(24.976567, 60.1612500)
# Create a Polygon
coords = [(55.199335819934504,25.209713479513255),(55.193858362513538,25.20134197109752),(55.187450889885667,25.195407028080979 )]
poly = Polygon(coords)
p1.within(poly)
Update 1
Data 1 (KML converted into Json, Json converted into Dataframe)
import geopandas as gpd data_poly = gpd.read_file(path + "Data_community_file.geojson")