[GIS] How to convert JSON from web service into shapefile

jsonshapefile

I have a JSON data in a text file. It contains some GIS data in form of WKT geometry and its attributes. I want to view this file in GIS and save it as shapefile, so I can work with the data. There are tools in ArcGIS that convert JSON to feature class (JSON to Feature), but my JSON is not in the standard ESRI format (), nor is it a GeoJSON or TopoJSON, so no GIS or online conversion tool can read it. The JSON file was generated by some web service. I guess I have to parse it somehow, or extract the important data, but I don't know where to start. Do I need to write a Python script? Is there an ArcPy function that parses raw JSON file? I am quite new to this format and its use in GIS.

Any ideas?

Here is the file:

{
"BorderPolygon":[
    {
        "Points":[
            {
                "Latitude":50.0848527027202,
                "Longitude":14.3433288676297
            },
            {
                "Latitude":50.0846995307187,
                "Longitude":14.3446421202828
            },
            {
                "Latitude":50.0847861746278,
                "Longitude":14.3448521702545
            },
            {
                "Latitude":50.0853115978675,
                "Longitude":14.3452308586668
            },
            {
                "Latitude":50.0856219793441,
                "Longitude":14.3449545937579
            },
            {
                "Latitude":50.0857306463445,
                "Longitude":14.3445904744911
            },
            {
                "Latitude":50.0856213001745,
                "Longitude":14.344515321968
            },
            {
                "Latitude":50.0851438479227,
                "Longitude":14.3431047456068
            },
            {
                "Latitude":50.0848527027202,
                "Longitude":14.3433288676297
            }
        ]
    }
],
"BorderText":"MULTIPOLYGON (((14.3433288676297 50.0848527027202, 14.3446421202828 50.0846995307187, 14.3448521702545 50.0847861746278, 14.3452308586668 50.0853115978675, 14.3449545937579 50.0856219793441, 14.3445904744911 50.0857306463445, 14.344515321968 50.0856213001745, 14.3431047456068 50.0851438479227, 14.3433288676297 50.0848527027202)))",
"Code":"P6-0371",
"Id":"68bb96d3-0118-4068-ba0a-6ea08fd7fa39",
"ProjectedCapacity":54,
"SectionCategory":{
    "Id":"17f7dc10-119d-4129-83b8-775fd73eedbc",
    "ModifiedBy":null,
    "Code":"RES",
    "Name":"Rezidentní"
},
"Tariff":[
    {
        "Day":0,
        "Tariff":[

        ]
    },
    {
        "Day":1,
        "Tariff":[
            {
                "Divisibility":"PT15M",
                "DivisibilityMiliseconds":900000,
                "MaxParkingTime":"PT3H",
                "MaxParkingTimeMiliseconds":10800000,
                "PricePerHour":40.0000,
                "TimeFrom":"PT8H",
                "TimeFromText":"08:00",
                "TimeTo":"PT5H59M",
                "TimeToText":"05:59"
            }
        ]
    },
    {
        "Day":2,
        "Tariff":[
            {
                "Divisibility":"PT15M",
                "DivisibilityMiliseconds":900000,
                "MaxParkingTime":"PT3H",
                "MaxParkingTimeMiliseconds":10800000,
                "PricePerHour":40.0000,
                "TimeFrom":"PT8H",
                "TimeFromText":"08:00",
                "TimeTo":"PT5H59M",
                "TimeToText":"05:59"
            }
        ]
    },
    {
        "Day":3,
        "Tariff":[
            {
                "Divisibility":"PT15M",
                "DivisibilityMiliseconds":900000,
                "MaxParkingTime":"PT3H",
                "MaxParkingTimeMiliseconds":10800000,
                "PricePerHour":40.0000,
                "TimeFrom":"PT8H",
                "TimeFromText":"08:00",
                "TimeTo":"PT5H59M",
                "TimeToText":"05:59"
            }
        ]
    },
    {
        "Day":4,
        "Tariff":[
            {
                "Divisibility":"PT15M",
                "DivisibilityMiliseconds":900000,
                "MaxParkingTime":"PT3H",
                "MaxParkingTimeMiliseconds":10800000,
                "PricePerHour":40.0000,
                "TimeFrom":"PT8H",
                "TimeFromText":"08:00",
                "TimeTo":"PT5H59M",
                "TimeToText":"05:59"
            }
        ]
    },
    {
        "Day":5,
        "Tariff":[
            {
                "Divisibility":"PT15M",
                "DivisibilityMiliseconds":900000,
                "MaxParkingTime":"PT3H",
                "MaxParkingTimeMiliseconds":10800000,
                "PricePerHour":40.0000,
                "TimeFrom":"PT8H",
                "TimeFromText":"08:00",
                "TimeTo":"PT5H59M",
                "TimeToText":"05:59"
            }
        ]
    },
    {
        "Day":6,
        "Tariff":[

        ]
    }
]
}

The data comes from the web service:

https://apicore.zpspraha.cz/CISIPRService/CISIPRService.svc

However, I don't know what kind of a service it is, it is not WMS, WFS or ArcGIS Map/Feature service (actually I have never never seen a GIS service in this (.svc file) format) and can't open it with ArcGIS or QGIS anyhow. So I got the exported JSON from a colleague in the end.

Best Answer

If you just need to convert that file, take a look in the JSON for the BorderText attribute. That's the Well Known Text version of the border:

MULTIPOLYGON (((14.3433288676297 50.0848527027202, 14.3446421202828 50.0846995307187, 14.3448521702545 50.0847861746278, 14.3452308586668 50.0853115978675, 14.3449545937579 50.0856219793441, 14.3445904744911 50.0857306463445, 14.344515321968 50.0856213001745, 14.3431047456068 50.0851438479227, 14.3433288676297 50.0848527027202)))

You can then copy that and go to Geometry Inspector and paste it in the WKT textbox. Click any other textbox and it will convert it to GeoJSON and EsriJSON.

You can convert the EsriJSON with Esri tools, or copy the GeoJSON, paste it in GeoJSON.io, and then under the Save menu there's an option to download the data as a shapefile.

If you want something a bit more streamlined, you could chain together cURL, JQ, and ogr2ogr to something like:

curl http:/your/url | jq ".BorderText" | ogr2ogr outfile.shp /vsistdin/