Solved

JsonTempater Geometry template usage


Badge +6

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 3
Badge +28

Hi @jurgenmack 

 

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

 

 

Thanks

Badge +6

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

jurgen

Userlevel 3
Badge +28

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.

Badge +6

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

 

Jurgen

Badge +6

Here is a screenshot of my JSONTemplater settings.

Badge +6

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.

Badge +6

@danilo_fme I have posted the workbench template. 

 

Thanks Jurgen

Userlevel 4
Badge +25

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?

Badge +6

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

Userlevel 1
Badge +15

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 1
Badge +15

Adding modified workspace to illustrate

Badge +6

@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 1
Badge +15

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