Skip to main content
Solved

Convert json-file to ESRI line feature class


ireen
Contributor
Forum|alt.badge.img+5
  • Contributor

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?

Best answer by nielsgerrits

ireen wrote:

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

View original
Did this help you find an answer to your question?

10 replies

nielsgerrits
VIP
Forum|alt.badge.img+54

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


ireen
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • March 27, 2023
nielsgerrits wrote:

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!!


nielsgerrits
VIP
Forum|alt.badge.img+54
ireen wrote:

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

cheers:)


ireen
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • March 28, 2023
ireen wrote:

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)?


ireen
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • March 28, 2023
nielsgerrits wrote:

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?


nielsgerrits
VIP
Forum|alt.badge.img+54
ireen wrote:

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.


nielsgerrits
VIP
Forum|alt.badge.img+54
  • Best Answer
  • March 28, 2023
ireen wrote:

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


ireen
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • March 28, 2023
ireen wrote:

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


nielsgerrits
VIP
Forum|alt.badge.img+54
ireen wrote:

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


ireen
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • March 28, 2023
ireen wrote:

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

Thank s a lot, Niels. Works fine.


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