Skip to main content
Question

json templater conversion


gis2020
Contributor
Forum|alt.badge.img+5

Hi All,

I am trying to create json file using the json templater . input for this file has postGIS file with geometry in wkt format . i tried to convert using json templater but it not giving the desired output . can somebody help me with this ? i am uploading the json format file which is my desired output for this . file name examplebody.json

also i am attaching the screenshot of the out put which i am getting.

6 replies

david_r
Celebrity
  • July 16, 2020

Looks like you should be using the GeoJSON writer rather than the text writer. That way you can also leave out the JSONTemplater.

If needed, you should first use the GeometryReplacer to convert the WKT to an FME geometry.


gis2020
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • July 17, 2020
david_r wrote:

Looks like you should be using the GeoJSON writer rather than the text writer. That way you can also leave out the JSONTemplater.

If needed, you should first use the GeometryReplacer to convert the WKT to an FME geometry.

thank you david . i tried using geojson writer but still i get the different output. below is the screenshot of desired output.


david_r
Celebrity
  • July 17, 2020
gis2020 wrote:

thank you david . i tried using geojson writer but still i get the different output. below is the screenshot of desired output.

Can you show us what you got using the GeoJSON writer?


gis2020
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • July 17, 2020
david_r wrote:

Can you show us what you got using the GeoJSON writer?

sure . this is the output i am getting using the Geojson writer.

 

My input has two geometry columns as geometry 1 and geometry 2 which is a same geometry but with time stamps .


david_r
Celebrity
  • July 17, 2020

Any particular reason for storing the geometries as text attributes in addition to the regular GeoJSON geometry definition?

Also I'm not sure GeoJSON allows for multiple geometries such as this. Is there any chance that you create an aggregate geometry of geometry_1 and geometry_2 and use that instead?


takashi
Influencer
  • July 20, 2020

Hi @gis2020, I think this workflow generates your desired result if each input feature contains a line geometry.

JSONTemplater Root Expression:

{|
    fme:process-features("SUB")
|}

JSONTemplater SUB Expression:

{
    "geometry"||fme:get-attribute("_count") : fme:get-json-attribute("_geometry")
}

0684Q00000ArKN4QAN.png

 

Alternatively, this would work as well.

JSONTemplater Root Expression:

{|
    for $g at $i in fme:get-json-list-attribute("_list{}._geometry")
    return
    {
        "geometry"||$i : $g
    }
|}

0684Q00000ArKKeQAN.png


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