Uploaded image for project: 'Apache Sedona'
  1. Apache Sedona
  2. SEDONA-96

ST_MakeValid returning multiple geometries for polygons with holes

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 1.2.1

    Description

      When pass a polygon with holes, ST_MakeValid is returning new rows for each hole. This can lead to significant incorrectness when using ST_MakeValid prior to a spatial join.

      Example:

      polygon = spark.createDataFrame([['{"type": "Polygon", "coordinates": [[[3, 3], [3, -3], [-3, -3], [-3, 3], [3, 3]], [[1, 1], [1, -1], [-1, -1], [-1, 1], [1, 1]]]}']], ['geometry'])
      polygon = polygon.withColumn('geometry', F.expr('ST_MakeValid(ST_GeomFromGeoJSON(geometry), false)'))
      polygon = polygon.withColumn('geometry', F.expr('ST_AsGeoJSON(geometry)'))
      polygon
      
      geometry
      --------------------------------------------------------------------------------------------------------------------------------------------------
      {"type":"Polygon","coordinates":[[[3.0,3.0],[3.0,-3.0],[-3.0,-3.0],[-3.0,3.0],[3.0,3.0]],[[1.0,1.0],[-1.0,1.0],[-1.0,-1.0],[1.0,-1.0],[1.0,1.0]]]}
      {"type":"Polygon","coordinates":[[[-1.0,1.0],[1.0,1.0],[1.0,-1.0],[-1.0,-1.0],[-1.0,1.0]]]}

      Input:

      Output:

      Attachments

        Issue Links

          Activity

            People

              umartin Martin Andersson
              russellw Russell W
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m