Skip to main content

Hello,

I would like to create the Geojson output as shown below:

{
  "type": "FeatureCollection",
  "name": "Example_Dataset",
  "crs": {
    "type": "name",
    "properties": {
      "name": "EPSG:28992"
    }
  },
  "bbox": null,
  "features": ,
    {
      "type": "Feature",
      "properties": {
        "Name": "AO1",
        "Begin K": "0",
        "End K": "2.196"
      },
      "geometry": {
        "type": "LineString",
        "coordinates": 
          >
            143267.805,
            559438.354,
            1.944,
            0
          ],
          [
            143268.356,
            559439.188,
            1.987,
            0.001
          ],
          
            143268.907,
            559440.023,
            2.029,
            0.002
          ],
          3
            143269.235,
            559440.968,
            2.022,
            0.003
          ],

I have tried to follow this post https://community.safe.com/s/question/0D54Q000080hepZSAQ/create-geojson-array

and specifically the workspace : build-geojson-with-jsontemplater.fmwt

but without success. I am not sure how/what to fill in the JSON templater and how to proceed further.

 

Attached you can find a sample of my dataset (csv), my so far workspace, and the final GeoJson file that I would like to reproduce using the FME workspace.  

 

Thank you in advance.

Hi @penicillin​ ,

 

It seems you are dealing with a Measure, and I'm not sure if that's supported in the GeoJSON standard.

 

What I did notice is that if you set a Measure to the coordinates, the GeometryExtractor doesn't include this at the coordinates when using the GeoJSON encoding, whereas when using the Esri JSON encoding, a measure is included at the coordinates. 

 

So I think you need to manually construct your desired GeoJSON Geometry incl measure. You could do that yourself in a JSONTemplator, or you could use the Esri JSON geometry encoding as a template for the coordinates, and recreate that into a GeoJSON Geometry.

 

See attached workspace for an example of these options.

 

Note. I'm not sure what your requirements are for the number accuracy c.q. data type of attributes.

E.g. I initially got floating point rounding errors like n <X>, <Y>, <Z>, 1.2910000085830688 ]. I suppose t <X>, <Y>, <Z>, 1.291 ] is nicer, so I added some tweaks for that. 

Also, the example you provided contains the following 

"End K": "2.196"

Specifically, that defines the value for End K as a string. I assumed (depending on your application I might be wrong though) that it should actually be written as a number, so I changed it to

"End K": 2.196

At last also here I included a workaround to avoid the a floating point rounding error, otherwise I obtained '2.1960000991821289' as the value for End K. 


Hi @penicillin​ ,

 

It seems you are dealing with a Measure, and I'm not sure if that's supported in the GeoJSON standard.

 

What I did notice is that if you set a Measure to the coordinates, the GeometryExtractor doesn't include this at the coordinates when using the GeoJSON encoding, whereas when using the Esri JSON encoding, a measure is included at the coordinates. 

 

So I think you need to manually construct your desired GeoJSON Geometry incl measure. You could do that yourself in a JSONTemplator, or you could use the Esri JSON geometry encoding as a template for the coordinates, and recreate that into a GeoJSON Geometry.

 

See attached workspace for an example of these options.

 

Note. I'm not sure what your requirements are for the number accuracy c.q. data type of attributes.

E.g. I initially got floating point rounding errors like n <X>, <Y>, <Z>, 1.2910000085830688 ]. I suppose t <X>, <Y>, <Z>, 1.291 ] is nicer, so I added some tweaks for that. 

Also, the example you provided contains the following 

"End K": "2.196"

Specifically, that defines the value for End K as a string. I assumed (depending on your application I might be wrong though) that it should actually be written as a number, so I changed it to

"End K": 2.196

At last also here I included a workaround to avoid the a floating point rounding error, otherwise I obtained '2.1960000991821289' as the value for End K. 

Hi thijsknapen,

 

Thank you for taking some time out.

I just managed to check your workspace.

You are right about converting the number's data type, I didn't focus on that part that much

but indeed that looks better and is the appropriate format.

 

I am trying to understand your process since my FME knowledge is still in a basic level (and especially the geojson format knowledge).

Indeed I am dealing with a measure which are points with km. I am trying to add that measure and create a 4th "dimension" to the geojson file, by using FME because that will save me a lot of time! 

 

Here I have some basic questions before going deeper.

I checked the option 1 by extracting the results in a geojson file. The file structure seems to be what I want as all of the 4 measures (x,y,z and k) are included. Although I can not load the file in a gis application (tried in Qgis), do you might know why?

 

Option 2 : I can not see the results when I run the transformers. Am I doing something wrong? 

I am really interested in seeing what this option does.

 

Thank you in advance!


Hi thijsknapen,

 

Thank you for taking some time out.

I just managed to check your workspace.

You are right about converting the number's data type, I didn't focus on that part that much

but indeed that looks better and is the appropriate format.

 

I am trying to understand your process since my FME knowledge is still in a basic level (and especially the geojson format knowledge).

Indeed I am dealing with a measure which are points with km. I am trying to add that measure and create a 4th "dimension" to the geojson file, by using FME because that will save me a lot of time!

 

Here I have some basic questions before going deeper.

I checked the option 1 by extracting the results in a geojson file. The file structure seems to be what I want as all of the 4 measures (x,y,z and k) are included. Although I can not load the file in a gis application (tried in Qgis), do you might know why?

 

Option 2 : I can not see the results when I run the transformers. Am I doing something wrong?

I am really interested in seeing what this option does.

 

Thank you in advance!

Hi @penicillin​ ,

 

Regarding not seeing the output for the second option. I added a parameter 'Processing_option_GeoJSON' so that you can choose whether you want to use option 1 (Manual), or option 2 (EsriJSON_template). See also the TestFilter in the workspace.

When you run the workspace, you can choose whether you want to use Option 1 or 2;

imageBut for the sake of this example it might have been easier if I just let both options be evaluated. See attached workspace which I changed the workspace to do just that.

 

Regarding the GeoJSON and not being able to see it in QGIS. I think this has to do with my initial question;

It seems you are dealing with a Measure, and I'm not sure if that's supported in the GeoJSON standard.

 

I had a quick google search on 'geojson measure' and found the following

in the last paragraph of section 3.1.1 of RFC 7946: The GeoJSON Format;

 

Implementations SHOULD NOT extend positions beyond three elements because the semantics of extra elements are unspecified and ambiguous. Historically, some implementations have used a fourth element to carry a linear referencing measure (sometimes denoted as "M") or a numerical timestamp, but in most situations a parser will not be able to properly interpret these values. The interpretation and meaning of additional elements is beyond the scope of this specification, and additional elements MAY be ignored by parsers.

 

So to get back to my own question. It seems that measures are not (officially) supported by the GeoJSON standard, and that parsers may ignore any extra/additional coordinate/position elements. I guess QGIS is one of those parsers.

 

Maybe it's possible for you to use a different file format?

As mentioned. Esri JSON does have support for measures. Is that maybe an option for you? (can QGIS read Esri JSON?).

 

Otherwise maybe 'OGC GeoPackage' is an option for you? I believe QGIS is able to read that, and OGC GeoPackage does seem to support measures. See also section 2.1.1. Simple Features SQL Introduction of the OGC®️ GeoPackage Encoding Standard;

Geometries MAY include m coordinate values. The m coordinate value allows the application environment to associate some measure with the point values.

 

 


Hi thijsknapen,

 

Thank you for taking some time out.

I just managed to check your workspace.

You are right about converting the number's data type, I didn't focus on that part that much

but indeed that looks better and is the appropriate format.

 

I am trying to understand your process since my FME knowledge is still in a basic level (and especially the geojson format knowledge).

Indeed I am dealing with a measure which are points with km. I am trying to add that measure and create a 4th "dimension" to the geojson file, by using FME because that will save me a lot of time!

 

Here I have some basic questions before going deeper.

I checked the option 1 by extracting the results in a geojson file. The file structure seems to be what I want as all of the 4 measures (x,y,z and k) are included. Although I can not load the file in a gis application (tried in Qgis), do you might know why?

 

Option 2 : I can not see the results when I run the transformers. Am I doing something wrong?

I am really interested in seeing what this option does.

 

Thank you in advance!

Thank you so much for the help!

 

 

 


Reply