I have a big dataset with geo data. I want to extact data only related to the part of the city. So I need to create a shape and check whether or not my point is there.
I tried to work with this answer:
POINTS
1)
turin.head() =
latitude longitude
0 44.9125 7.7432
21 45.0764 7.5249
22 45.0764 7.5249
23 45.0755 7.5248
24 45.0718 7.5236
2)
geometry = [Point(xy) for xy in zip(turin.longitude,turin.latitude)]
turin_point = gpd.GeoDataFrame(turin,crs=crs,geometry=geometry)
turin_point.head()
latitude longitude geometry
0 44.9125 7.7432 POINT (7.74320 44.91250)
21 45.0764 7.5249 POINT (7.52490 45.07640)
22 45.0764 7.5249 POINT (7.52490 45.07640)
23 45.0755 7.5248 POINT (7.52480 45.07550)
24 45.0718 7.5236 POINT (7.52360 45.07180)
BORDERS
1)
border.head()
longitude latitude
0 7.577835 45.041828
1 7.579849 45.039877
2 7.580106 45.039628
3 7.580852 45.038576
4 7.580866 45.038556
2)
geometry2 = [Point(xy) for xy in zip(border.longitude,border.latitude)]
border_point = gpd.GeoDataFrame(border,crs=crs,geometry=geometry2)
border_point.head() =
longitude latitude geometry
0 7.577835 45.041828 POINT (7.57783 45.04183)
1 7.579849 45.039877 POINT (7.57985 45.03988)
2 7.580106 45.039628 POINT (7.58011 45.03963)
3 7.580852 45.038576 POINT (7.58085 45.03858)
4 7.580866 45.038556 POINT (7.58087 45.03856)
Then according to reply:
turin_final= border_point.geometry.unary_union
within_turin = turin_point[turin_point.geometry.within(turin_final)]
IndexError: too many indices for array