3

I have two irregular shaped polygons that overlap each other at least in at two points. I want to first find the intersection area between all of them, then for the polygon pair that intersects I want to find the centerline of each intersection, which should not be a straight line. I thought of using the Centerline module in python that uses Voronoi daigram, but it doesn't seem to work well. Is there another library that can quickly calculate the centerline of an intersection that starts at one intersection point and ends at another?

I have the following code:

import geopandas as gdp 
from shapely.geometry import Polygon
from centerline.geometry import Centerline

crs = {'init': 'epsg:4326'}
attributes = {"id": 1, "name": "polygon", "valid": True}

# find the intersection of polygons
intersection_list = []
for x in range (0, len(list_of_polygons)):
    if len(list_of_polygons) > 1:
          # check if the last polygon in the list intersect with the current polygon
         if list_of_polygons[-1].intersects(list_of_polygons[x]):
                        polygon_last = gdp.GeoDataFrame(index=[0], crs=crs, geometry=[list_of_polygons[-1]])
                        polygon_current = gdp.GeoDataFrame(index=[0], crs=crs, geometry=[list_of_polygons[x]]) 
                        # get the intersection geometry
                        intersection = gdp.overlay(polygon_last, polygon_current, how = "intersection")
                        intersection_geom = Polygon(intersection.geometry)
                        # find the centreline of the intersction
                        centreline = Centerline(intersection_geom, **attributes)
  • Try to density polygon vertices, it will help with Voronoi points. – FelixIP Oct 31 '19 at 2:39
  • Should I add more vertices to the intersection polygons to help with triangulation? – goodgeo3 Oct 31 '19 at 12:28
  • Yes, this is what I am suggesting. – FelixIP Oct 31 '19 at 18:19
  • The Centreline module already densifies the polygon vertices, but this still doesn't seem to work. – goodgeo3 Nov 1 '19 at 17:41

Your Answer

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

Browse other questions tagged or ask your own question.