I am struggling to make the GeoDataFrame functions: intersects/contains work between GeoDataFrames instances.
Let t be a GeoDataFrame with contents:
id geom
0 230 POINT (154860.3254511474 -468176.1141802836)
1 231 POINT (149247.4170036312 -436634.9002944119)
2 232 POINT (192530.4468407042 -465274.3331522844)
3 233 POINT (138125.4083732415 -419237.1333624315)
4 234 POINT (195314.0952219047 -468429.8881146177)
5 235 POINT (196320.0493430012 -479448.5877129403)
6 236 POINT (199780.1489409541 -446899.1169124786)
7 237 POINT (161437.1203666388 -440485.6615666826)
8 238 POINT (192413.1253873391 -465423.3888242305)
9 239 POINT (196039.9555616449 -473696.9492107867)
I extract the 5 last points in another GeoDataFrame named prt:
id geom
5 235 POINT (196320.0493430012 -479448.5877129403)
6 236 POINT (199780.1489409541 -446899.1169124786)
7 237 POINT (161437.1203666388 -440485.6615666826)
8 238 POINT (192413.1253873391 -465423.3888242305)
9 239 POINT (196039.9555616449 -473696.9492107867)
executing the command:
t.intersects(prt)
Out:
0 False
1 False
2 False
3 False
4 False
5 True
6 True
7 True
8 True
9 True
However when I create a polygon from the points of prt and repeat the process it fails:
import shapely.geometry as sh
polygon = sh.polygon.Polygon([[p.x, p.y] for p in prt.geometry.tolist()])
import geopandas as gpd
pds = gpd.GeoDataFrame([polygon], columns=['geom'], geometry = 'geom', crs = {'init':'epsg:3309'})
pds.geom_equals(polygon)
Out[873]:
0 True
dtype: bool
t.intersects(polygon)
Out[875]:
0 False
1 False
2 True
3 False
4 True
5 True
6 True
7 True
8 True
9 True
dtype: bool
t.intersects(pds)
Out[874]:
0 False
1 False
2 False
3 False
4 False
5 False
6 False
7 False
8 False
9 False
dtype: bool
Can you please provide me some help/guidelines? I am pretty new in Python, so any advice is welcome.