I have 2 shape files one "country.shp" (containing the tiles geometry covering the whole country) & other "district.shp"(containing one particular district). Now I want to get the tiles information getting intersected with the district polygon (similar to search by location in ArcGIS) and the final intersected geodataframe should contain the attributes of "country.shp" (containing only intersected rows from "country.shp"). Up till now I have used the following code but it is working fine only for some district shape files (projections are same for both the shapefiles). Can someone help me what is wrong with the following code or suggest some other alternatives?
import geopandas as gpd f1 = "/home/geo/country.shp" f2 = "/home/geo/district.shp" data1 = gpd.read_file(f1) data2 = gpd.read_file(f2) import shapely.speedups shapely.speedups.enable() pip_mask = data1.within(data2.loc[0, 'geometry']) pip_data= data1.loc[pip_mask]