Solved

JsonTempater Geometry template usage

  • 9 February 2024
  • 13 replies
  • 90 views

Userlevel 1
Badge +9

I have created a geojson file from nine features drawn from a postgis database. I have tried all the examples from the community pages with no success. Can anybody point me in the right direction?

icon

Best answer by daveatsafe 14 February 2024, 23:13

View original

13 replies

Userlevel 5
Badge +32

Hi @jurgenmack 

 

Do you have the geoson created? If yes, could you share us?

 

 

Thanks

Userlevel 1
Badge +9

I should have said I’m trying the create a geojson. It writes out but this geometry template doesn’t do anything.   
 

jurgen

Userlevel 5
Badge +32

I should have said I’m trying the create a geojson. It writes out but this geometry template doesn’t do anything.   
 

jurgen

Hi Jurgen, thanks your answer.

 

Please, could you share your workspace template.

Userlevel 1
Badge +9

I am trying but for some reason it will not let me upload the file.

 

Jurgen

Userlevel 1
Badge +9

Here is a screenshot of my JSONTemplater settings.

Userlevel 1
Badge +9

Finally, here is the workbench. Can someone have a look and see what i am doing wrong. I am trying to include the geometry in the output geojsn file but none of the examples i have tried when configuring the geometry template in the JSONTemplater have worked.

Userlevel 1
Badge +9

@danilo_fme I have posted the workbench template. 

 

Thanks Jurgen

Userlevel 5
Badge +32

Is there a reason you want/need to use the Templator as opposed to just the GeoJSON Writer? Does FME not create the correct structure from your featuers?

Userlevel 1
Badge +9

I have a dataset that has multiple features and I was hoping to generate one json file instead of one for each feature. 

Userlevel 3
Badge +17

You can do this with a simple PostGIS to GeoJSON workspace, with the GeoJSON writer option ‘File Structure’ set to ‘Array of FeatureCollection objects - one per feature type’.

 

Userlevel 3
Badge +17

Adding modified workspace to illustrate

Userlevel 1
Badge +9

@daveatsafe I had no idea it was that simple. I’m always looking for the most complicated workflows. I’m going to have to change the way i develop workbenches. Start with the simplest solution first. (Reader 2 Writer nothing between)

Thanks Dave,  

PS. For future reference is there anything wrong with the way i am setting up the Geometry Template?

 

 

Jurgen

Userlevel 3
Badge +17

Working with the geometry template can be quite complex. You can see more information on it at https://docs.safe.com/fme/html/FME-Form-Documentation/FME-Transformers/XQuery/XQuery_functions.htm. It would be a lot easier to use the GeometryExtractor to extract the geometry as GeoJSON, then insert that attribute into the template using:

"geometry" :fme:get-json-attribute("_geometry")

Reply