1

I have generated two geodataframes:

    df1=gpd.read_file("~/rede_cicloviaria.shp") # A series of Linetrings of a cycling network
    df2=gpd.read_file("~/zonas.shp") # Each line represents a traffic zone as a polygon structure

My final objective is to calculate the total length of the cycling network in each line in df2. So I used the overlay function in a for loop to account for the cycling network (df1) overlaying each polygon (df2) and then sum the existing cycling network length for each polygon.

    df3={}
    for i in range(len(zonas)):
        df3[i]=geopandas.overlay(df1,df2[df2["index"]==i], how='intersection')
        df2.at[i,"cycling_length"]=df3[i]["length"].sum()

Then, I plotted a map to visually confirm the results, where Blue means zones with cycling infrastructure and white means no cycling infrastructure available. However, I realized that for one specific zone (in orange), the overlay function did not work. Visually we can see that there exists cycling infrastructure but its correspondent geodataframe (df3[178]) is empty, meaning that the overlay function did not find a linestring inside this polygon.

enter image description here

Do you have any idea what should happen?

Majid Hajibaba
  • 3,105
  • 6
  • 23
  • 55
Lucas Melo
  • 11
  • 1

0 Answers0