1

I have have a JSON file of earthquake data. The data type within the JSON file is a MULTILINESTRING. For my further workflow I need the data type POLYGON. I am able to import the dataset as POLYGON through PostGIS, but have to change manually change the geometry to the POLYGON type in the JSON file.

How can I automate the process the geometry conversation from MULTILINESTRING to POLYGON in the JSON file?

Can I do this in ogr2ogr?

If yes, will this solution be the most useful way for me or is there any other way you can suggest?

The original JSON data are:

{
    "type": "FeatureCollection",
    "crs": {
        "type": "name",
        "properties": {
            "name": "urn:ogc:def:crs:OGC:1.3:CRS84"
        }
    },
    "features": [{
        "type": "Feature",
        "properties": {
            "value": 1.5,
            "units": "mmi",
            "color": "#dfe6ff",
            "weight": 4
        },
        "geometry": {
            "type": "MultiLineString",
            "coordinates": [
                [
                    [178.653888, 53.4],
                    [178.657187, 53.383372],
                    [178.673829, 53.366743],
                    [178.750048, 53.31791],
                    [178.775012, 53.309596]
                ],
                [
                    [178.775012, 50.023206],
                    [178.750048, 50.014667],
                    [178.625228, 49.927936],
                    [178.443172, 49.81659],
                    [178.422855, 49.791648]
                ],
                [
                    [173.144061, 49.791648],
                    [173.13574, 49.808276],
                    [173.066595, 49.850673],
                    [173.041631, 49.863927],
                    [173.016667, 49.867334]
                ]
            ]
        }
    },
3
  • 1
    Hi and welcome Simun! THis is standard JSON, so my take at this would be to write a python script to change "multilinestring" to "polygon" and do other adjustments you need- the problem is to be sure that anything that is a multilinestring is or can be converted to a valid polygon through the same transformation(s). Dec 21 '21 at 6:59
  • Could you edit your GeoJSON data so that it could be just copied to geojsonlint.com for inspection?
    – user30184
    Dec 21 '21 at 12:23
  • This isn't a full GeoJSON file, it's not a viable sample we use to test. Dec 22 '21 at 23:09