4

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.

4
  • i would use Python to parse through it and create a file that way
    – ziggy
    Commented Jun 29, 2017 at 14:13
  • You say its coming from a web service - can you copy the link and add it to QGIS? Or can you share the link here? Commented Jun 29, 2017 at 14:15
  • It comes from this web service: apicore.zpspraha.cz/CISIPRService/CISIPRService.svc/section/… However, I dont know what kind of a service it is, it is not WMS, WFS or ArcGIS MAp/Feature service (acutally 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. Cant discuss it with him anymore unfortunatelly. Commented Jun 30, 2017 at 12:17
  • The service is described by a WSDL. You could consider using Python suds, or SOAPpy to enable you to call the service within your GIS
    – nmtoken
    Commented Jul 3, 2017 at 8:01

1 Answer 1

2

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/

2
  • thank you. How do I add attributes from the original JSON file to the shapefile attribute table? especially the nested attributes like Code or Name inside "SectionCategory" Commented Jul 3, 2017 at 14:36
  • If you want to map the attributes you will probably need to script the problem. In pure Python you could either parse the geometry yourself or use Shapely to parse the WKT. The you could use PyShp to build your shapefile. Commented Jul 3, 2017 at 14:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.