Skip to main content
Solved

JsonTempater Geometry template usage

  • Feb 9, 2024 7:00 PM UTC
  • 13 replies
  • 264 views

jurgenmack
Contributor
Forum|alt.badge.img+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?

Best answer by daveatsafe

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’.

 

View original
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

13 replies

danilo_fme
Celebrity
Forum|alt.badge.img+58
  • Celebrity
  • Feb 10, 2024 7:35 PM UTC

Hi @jurgenmack 

 

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

 

 

Thanks


jurgenmack
Contributor
Forum|alt.badge.img+9
  • Author
  • Contributor
  • Feb 10, 2024 8:40 PM UTC

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

jurgen


danilo_fme
Celebrity
Forum|alt.badge.img+58
  • Celebrity
  • Feb 11, 2024 1:40 PM UTC

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.


jurgenmack
Contributor
Forum|alt.badge.img+9
  • Author
  • Contributor
  • Feb 12, 2024 7:21 PM UTC

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

 

Jurgen


jurgenmack
Contributor
Forum|alt.badge.img+9
  • Author
  • Contributor
  • Feb 12, 2024 7:25 PM UTC

Here is a screenshot of my JSONTemplater settings.


jurgenmack
Contributor
Forum|alt.badge.img+9
  • Author
  • Contributor
  • Feb 13, 2024 11:15 PM UTC

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.


jurgenmack
Contributor
Forum|alt.badge.img+9
  • Author
  • Contributor
  • Feb 14, 2024 1:54 PM UTC

@danilo_fme I have posted the workbench template. 

 

Thanks Jurgen


itsmatt
Celebrity
Forum|alt.badge.img+48
  • Celebrity
  • Feb 14, 2024 2:01 PM UTC

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?


jurgenmack
Contributor
Forum|alt.badge.img+9
  • Author
  • Contributor
  • Feb 14, 2024 3:21 PM UTC

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


daveatsafe
Safer
Forum|alt.badge.img+24
  • Safer
  • Best Answer
  • Feb 14, 2024 10:13 PM UTC

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’.

 


daveatsafe
Safer
Forum|alt.badge.img+24
  • Safer
  • Feb 14, 2024 10:14 PM UTC

Adding modified workspace to illustrate


jurgenmack
Contributor
Forum|alt.badge.img+9
  • Author
  • Contributor
  • Feb 14, 2024 11:07 PM UTC

@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


daveatsafe
Safer
Forum|alt.badge.img+24
  • Safer
  • Feb 14, 2024 11:36 PM UTC

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