Question

How can parse “geometry “ "LineString","coordinates"[?????] in JSONTemplater

  • 28 March 2019
  • 6 replies
  • 43 views

Badge +1

I am creating GeoJson file form Sheapfile while converting there is small requirement that’s why I have used “JSONTemplater” I am able to populate “properties” Attributes but i don’t know how can parse or put Geometry into the template can any one help ?

"geometry" : {

"type" : "LineString",

"coordinates" : [??????]

I have attached FME Workbench as well

 

Thank you in Advanced .


6 replies

Userlevel 4

For some reason I cannot open the posted workspace.

But have you considered simply using the built-in GeoJSON writer, rather than constructing the GeoJSON document manually?

Badge +1

Yes I have used "GeoJSON writer" if I want to convert Shapefile direct to GeoJSON but in between I have structural changes that been added in "JSONTemplater" the Property values I am putting under

properties" : {

 

"S_RNR" : [...]

 

that's why :)

Userlevel 4
Badge +13

Hi @amolparande. I have received a suggestion from development that the GeoJSON writer may make that easier than using JSONTemplater. If you only have LineString geoms, then you can create the attribute like in this workspace: geom_to_geojson.fmw.zip

Userlevel 3
Badge +17

Hi @amolparande. I have received a suggestion from development that the GeoJSON writer may make that easier than using JSONTemplater. If you only have LineString geoms, then you can create the attribute like in this workspace: geom_to_geojson.fmw.zip

As mentioned, you can use the GeometryExtractor to extract feature geometry as GeoJSON into an attribute. You can then insert this attribute within the JSONTemplater.

As this attribute is already formatted as JSON, the XQuery function to insert the geometry attribute is get-json-attribute (instead of get-attribute) in the JSONTemplater. I have attached a modified version of your workspace demonstrating this approach.

geom_to_geojson.fmw

Badge +1

As mentioned, you can use the GeometryExtractor to extract feature geometry as GeoJSON into an attribute. You can then insert this attribute within the JSONTemplater.

As this attribute is already formatted as JSON, the XQuery function to insert the geometry attribute is get-json-attribute (instead of get-attribute) in the JSONTemplater. I have attached a modified version of your workspace demonstrating this approach.

geom_to_geojson.fmw

Thank you Debbi for your replay. i have question in "AttributeSplitter" what exactly Split on i could not understood can you please help me to do so...?

Userlevel 3
Badge +17

Thank you Debbi for your replay. i have question in "AttributeSplitter" what exactly Split on i could not understood can you please help me to do so...?

The AttributeSplitter was meant to create multiple lines based on the carriage return and line feed/new line special characters contained within your JSON document attribute.

Upon checking, it doesn't seem like this step is necessary if the XQuery function fme-get-json-attribute is used instead of get-attribute. In this case, it may be best to remove the AttributeSplitter and ListExploder transformers from the workspace.

Reply