Skip to main content
Question

JSON into shape?

  • February 16, 2024
  • 1 reply
  • 111 views

alfons
Contributor
Forum|alt.badge.img+7

Hello, 

I have received a GEOJSON file from a data supplier, which I would like to convert into a shapefile. Unfortunately, I am not able to extract the geometries with their corresponding attributes from this file. If I use the standard reader for JSON files, I can look at all attributes in the Inspector, but I have no geometries, only an object (?). If I integrate a ListExploder after the reader, I at least have all the objects that are integrated in the file, but I only ever see the first point of the object.
My question now is how I can extract both the geometries and the corresponding attributes from the file and save them in a ShapeFile or similar?

I attached a small sample.

 

Thanks a lot

ctredinnick
Supporter
Forum|alt.badge.img+18

It’s not a standard geometry format, so you’ll have to parse it yourself. The json describes “changes” for each “id”, and separately describes the vertices of each id changes. I assume these points together describe a line?

To break up the json into individual features that represent each “id”, first you can use a JsonFragmenter, fragmenting on json[“changes”][*]. Expose the id attribute for each changes to remerge on it later.

Then, to get the geometry, you need to go down the tree to where it is. JsonFragmenter again on json[“structure”][“points”][*]. This should result in each feature having the json for each point geometry.

JsonExtractor on the result for json[“geometry”][“latitude”] and json[“geometry”][“longitude”]

VertexCreator to turn each lat/long into a geometry

PointConnector to join the set of points into lines (grouping by the “id” extracted earlier)

I might not have the json queries exactly right, but you’ll get the idea.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings