Skip to main content
Solved

JsonTempater Geometry template usage


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
Did this help you find an answer to your question?

13 replies

danilo_fme
Evangelist
Forum|alt.badge.img+41
  • Evangelist
  • February 10, 2024

Hi @jurgenmack 

 

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

 

 

Thanks


jurgenmack
Contributor
Forum|alt.badge.img+9
  • Author
  • Contributor
  • February 10, 2024

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
Evangelist
Forum|alt.badge.img+41
  • Evangelist
  • February 11, 2024
jurgenmack wrote:

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
  • February 12, 2024

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
  • February 12, 2024

Here is a screenshot of my JSONTemplater settings.


jurgenmack
Contributor
Forum|alt.badge.img+9
  • Author
  • Contributor
  • February 13, 2024

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
  • February 14, 2024

@danilo_fme I have posted the workbench template. 

 

Thanks Jurgen


virtualcitymatt
Celebrity
Forum|alt.badge.img+34

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
  • February 14, 2024

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+19
  • Safer
  • Best Answer
  • February 14, 2024

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+19
  • Safer
  • February 14, 2024

Adding modified workspace to illustrate


jurgenmack
Contributor
Forum|alt.badge.img+9
  • Author
  • Contributor
  • February 14, 2024

@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+19
  • Safer
  • February 14, 2024

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


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