DOI-USGS / ghsc-esi-shakemap

ShakeMap
Other
17 stars 7 forks source link

Rupture GeoJSON files don't conform to RFC 7946 polygon specificiation, lists additional segments as "holes" instead of new polygons #10

Open kevinmilner opened 1 year ago

kevinmilner commented 1 year ago

I believe that the ShakeMap GeoJSON rupture geometry files, documented here, don't strictly conform to the GeoJSON specification (RFC 7946).

ShakeMap uses the MultiPolygon geometry type, and formats the geometry array this way:

{
  "type": "MultiPolygon",
  "coordinates": [
    [
      [
        [-117.3707820945, 35.5741994328, 0.0],
        [-117.3980967662, 35.5927834531, 0.0]
      ],
     [
        [-117.4768565955, 35.647137561, 0.0],
        [-117.5140293653, 35.673709514, 0.0]
      ]
    ]
  ]
}

Even though this is a MultiPolygon, the coordinates array only contains a single Polygon coordinate array:

    [
      [
        [-117.3707820945, 35.5741994328, 0.0],
        [-117.3980967662, 35.5927834531, 0.0]
      ],
     [
        [-117.4768565955, 35.647137561, 0.0],
        [-117.5140293653, 35.673709514, 0.0]
      ]
    ]

That single Polygon coordinate array lists multiple linear rings; according to the Polygon specification, that 2nd array is (and any after are) actually a hole meant as a cutout from the first listed linear ring:

For Polygons with more than one of these rings, the first MUST be the exterior ring, and any others MUST be interior rings. The exterior ring bounds the surface, and the interior rings (if present) bound holes within the surface.

Instead, I believe it should be specified this way with multiple Polygon arrays within the coordinates array, each with a single linear ring:

{
  "type": "MultiPolygon",
  "coordinates": [
    [
      [
        [-117.3707820945, 35.5741994328, 0.0],
        [-117.3980967662, 35.5927834531, 0.0]
      ]
    ],
    [
     [
        [-117.4768565955, 35.647137561, 0.0],
        [-117.5140293653, 35.673709514, 0.0]
      ]
    ]
  ]
}

For a real world example with this issue, see the Ridgecrest M7.1 ShakeMap: https://earthquake.usgs.gov/product/shakemap/ci38457511/atlas/1594160054783/download/rupture.json

I have attached it (after reformatting for readability) here: rupture_original_reformatted.json

And here is a modified version that I believe conforms to the GeoJSON spec: rupture_fixed.json

I think that correcting this issue will help users to more easily use these files in existing codes without having to write special cases. Thanks!