0

how we can check if feature has intersections or not with other features in one shapefile data, i wanna make sure if in that file there is no overlaps between polygon, i have read this approach https://medium.com/@achm.firmansyah/an-approach-for-checking-overlaps-and-gaps-in-polygons-using-geopandas-ebd6606e7f70 and i know that work, but is there any better solutions ? with these way the process take time because the loop.

data_overlaps=gpd.GeoDataFrame(crs=data_temp.crs)
for index, row in data_temp.iterrows():
    data_temp1=data_temp.loc[data_temp.ID!=row.ID,]
    overlaps=data_temp1[data_temp1.geometry.overlaps(row.geometry)]['ID'].tolist()
    if len(overlaps)>0:
        for j in overlaps:
            temp_area=gpd.overlay(data_temp.loc[data_temp.ID==row.ID,],data_temp.loc[data_temp.ID==row.ID,],how='intersection')
            temp_area=temp_area.loc[temp_area.geometry.area>=9e-9]
            if temp_area.shape[0]>0:
                data_overlaps=gpd.GeoDataFrame(pd.concat([temp_area,data_overlaps],ignore_index=True),crs=data_temp.crs)
0

I have found a solution, although the speed of processing depends on the size of the file, i'm using [maup][1] python library with some modification on maup.close_gaps(geometries) and maup.resolve_overlaps(geometries) where geometry are GeoSeries data type from goepandas

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.