Skip to main content
Question

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


amolparande
Forum|alt.badge.img+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

david_r
Celebrity
  • March 29, 2019

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?


amolparande
Forum|alt.badge.img+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 :)


fmelizard
Safer
Forum|alt.badge.img+18
  • Safer
  • March 29, 2019

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


debbiatsafe
Safer
Forum|alt.badge.img+20
fmelizard wrote:

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


amolparande
Forum|alt.badge.img+1
debbiatsafe wrote:

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


debbiatsafe
Safer
Forum|alt.badge.img+20
amolparande wrote:

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.


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