Solved

Convert json-file to ESRI line feature class


Badge

I have a json-file (see attachment) that contains the coördinates of a circular route. It looks like this:

{

 "segments": [{

  "geometry": {

   "type": "LineString",

   "coordinates": [

    [50.814103, 4.521174],

    [50.81309, 4.521811],

    [50.80626, 4.536902],

    [50.80482, 4.538866],

    [50.80573, 4.541452],

    [50.80621, 4.543173],

    [50.80705, 4.545501],

    [50.80755, 4.546541],

    [50.80777, 4.546841],

    [50.80919, 4.547739],

    [50.8096, 4.548199],

    [50.81052, 4.550243],

    [50.810663, 4.551096]

   ]

  },

  {

  "geometry": {

   "type": "LineString",

   "coordinates": [

    [50.810663, 4.551096],

    [50.81065, 4.555264],

    [50.81071, 4.555622]

   ]

  },

...

 

I want to convert it to an ESRI line feature class, but I'm stuck. The geojsonreader gives no error, but also no result as reader. 

 

Json-fragmenter gives me the list of vertices in an attribute, but I can't fix it to convert these points to vertices/line.

imageSomeone who can help me out?

icon

Best answer by nielsgerrits 28 March 2023, 10:16

View original

10 replies

Userlevel 6
Badge +33

Use a JSONFragmenter with the query  

json["segments"][*]["geometry"]

to get the individual geometry per segment, then use a GeometryReplacer set to GeoJSON to get the geometry from it.

2023-03-27_13h33_12

Badge

Use a JSONFragmenter with the query  

json["segments"][*]["geometry"]

to get the individual geometry per segment, then use a GeometryReplacer set to GeoJSON to get the geometry from it.

2023-03-27_13h33_12

This is what I was looking for. Thanks a lot!!

Userlevel 6
Badge +33

This is what I was looking for. Thanks a lot!!

cheers:)

Badge

This is what I was looking for. Thanks a lot!!

Niels,

To extract the nodes from the json-file, I did the following:

imageThis works fine, but I assume there is an easier way to get the points (including their attributes)?

Badge

Use a JSONFragmenter with the query  

json["segments"][*]["geometry"]

to get the individual geometry per segment, then use a GeometryReplacer set to GeoJSON to get the geometry from it.

2023-03-27_13h33_12

Looking at the result, I see that the spatial location is not correct. The GeometryReplacer translates the [Lat,Long] to [X,Y] instead of [Y,X]. The GeoJSON Geometry encoding has no possibility to change the axis order. Anybody an idea to solve this?

Userlevel 6
Badge +33

Looking at the result, I see that the spatial location is not correct. The GeometryReplacer translates the [Lat,Long] to [X,Y] instead of [Y,X]. The GeoJSON Geometry encoding has no possibility to change the axis order. Anybody an idea to solve this?

Yes I just found the same :) The CoordinateSwapper can fix this.

Userlevel 6
Badge +33

This is what I was looking for. Thanks a lot!!

As always the are different approaches to solve these things. I attached a workspace which solves the segments in a more elegant way. The geometry in the nodes and unpaved segments is not in a default format, so this still need to be done manually.

2023-03-28_10h17_24

Badge

This is what I was looking for. Thanks a lot!!

Where exactly in the FeatureReader do you define the queries for the output ports?

imageI did this, but no succes:

image

Userlevel 6
Badge +33

This is what I was looking for. Thanks a lot!!

This is correct, then under Parameters set Geometry Format to GeoJSON and set Geometry Key Name = "geometry".

2023-03-28_11h05_26

Badge

This is what I was looking for. Thanks a lot!!

Thank s a lot, Niels. Works fine.

Reply