Solved

Read only polyline geometry from data (gdb, shp or json)

  • 14 January 2022
  • 6 replies
  • 7 views

Hello,

 

I'm currently reading multiple data sources with a File/DIRECTORY reader and then using the path to read data whether its from a gdb, shp or json. I'm having trouble understanding how I can manage to read ONLY features that have a POLYLINE geometry. I'm guessing there is something to do in the constraint parameters of a FeatureReader transformer but, for the life of me, I can't seem to figure it out.

imageimageThanks for your help!

Anne-Marie

icon

Best answer by markatsafe 14 January 2022, 22:14

View original

6 replies

Badge +2

@amdubois​ For your Geodatabase reader, you might be able to formulate a SQL query to identify the geometry type. But I think the easiest solution is to just add a GeometryFilter after your FeatureReader's

Userlevel 4

You can use the Schema (any format) reader to retrieve all the feature class definitions and filter by

fme_geometry{0} = fme_line

You can then send the feature class names in fme_feature_type_name to a FeatureReader to read the actual contents into FME.

 

This will work with most data formats, including File or Enterprise Geodatabase, Shape, etc. Just be aware that it might not work so well with formats such as (Geo)JSON, as there aren't any hard schema constraints on homogeneous geometry types per feature type.

 

If your source data contains a lot of non-line data, this could be much faster than using the GeometryFilter as you'll not be reading any non-line features into FME.

@david_r​ 

Thank you for your answer. I'm still having trouble with the Schema reader. I'm not sure when I would be supposed to input the filter query to extract only line geometry. Directly in the Schema reader or in the following FeatureReader? Or would I have to insert a Test tranformer in betweeen? Would I have to expose the fme_geomtry attribute?

 

read only line geometry, feature Reader parameter set example 

If you could add a picture that would really help me, thanks!

Userlevel 4

@david_r​ 

Thank you for your answer. I'm still having trouble with the Schema reader. I'm not sure when I would be supposed to input the filter query to extract only line geometry. Directly in the Schema reader or in the following FeatureReader? Or would I have to insert a Test tranformer in betweeen? Would I have to expose the fme_geomtry attribute?

 

read only line geometry, feature Reader parameter set example 

If you could add a picture that would really help me, thanks!

Try something like this:

FGDB only read linesSee also the attached workspace template (FME 2020).

 

I ended using a geometry filter because it was easier than redoing my whole sequence but clearly the schema + tester is much simpler. Thank you all!

Userlevel 4

I ended using a geometry filter because it was easier than redoing my whole sequence but clearly the schema + tester is much simpler. Thank you all!

I'd argue that the GeometryFilter is actually much simpler, but for some datasets it might be much slower. But for other datasets it might not make much of a difference, so both are equally valid solutions :-)

Reply