Skip to main content

I am trying to limit the attributes read by the FeatureReader. The data I want to read are coming either from an Oracle or PostGIS database. Of course I can use the WHERE clause to limit the features based on limiting values, but I do not need all the columns the data table holds.

 

 

I there a way to do this inside the FeatureReader? Currently, I am using an AttributeManager after my featureReader to remove columns not needed, but that's a waste of ressources and more important, time.

When I use databases, I use the SQLCreator and use a WHERE clause in that. This will limit the columns but it isn't that different to using FeatureReader. Under the 'parameters' section, you can run a SQL To Run Before Read. This might help you if you want to limit attributes.


Hi @thomasgeo, as far as I know, there seems to be no way to select only required columns with the FeatureReader. How about using the SQLExecutor instead?


Hi @david_whiteside and @takashi, I believe in my specific case the SQLCreator will not work since I also have a spatial relationship (intersect) to take into account.

 

 

I am reading objects from a PostGIS table (polylines), buffer them, and thereafter I am connecting the buffers as 'Initiator' to the FeatureReader. Using the SQLExecutor with my Oracle database, I can bind the buffers in the same way to it as I do with the FeatureReader, but now I am struggeling with the SQL statement for the intersection.

If all the attributes returned by the FeatureReader don't create other problems than just filling up your workspace, I'd consider simply using an AttributeRemover (or AttributeKeeper) after the FeatureReader to remove what's not needed. Not a perfect solution, but at least the spatial relationship is easier to handle that way.


Hi @david_whiteside and @takashi, I believe in my specific case the SQLCreator will not work since I also have a spatial relationship (intersect) to take into account.

 

 

I am reading objects from a PostGIS table (polylines), buffer them, and thereafter I am connecting the buffers as 'Initiator' to the FeatureReader. Using the SQLExecutor with my Oracle database, I can bind the buffers in the same way to it as I do with the FeatureReader, but now I am struggeling with the SQL statement for the intersection.
PostGIS supports ST_* functions to manipulate geometry data. For example, this where clause determines if the geometry stored in the "geom" field intersects a given geometry defined with the Well Known Text (WKT) format.

 

select * from my_table
where ST_Intersects(geom, ST_GeomFromText('@Value(_geometry)'))
Assuming that the "my_table" has a geometry type field called "geom" and the initiator feature has an attribute called "_geometry" that stores WKT geometry representation. You can use the GeometryExtractor to create the "_geometry" attribute.

 


PostGIS supports ST_* functions to manipulate geometry data. For example, this where clause determines if the geometry stored in the "geom" field intersects a given geometry defined with the Well Known Text (WKT) format.

 

select * from my_table
where ST_Intersects(geom, ST_GeomFromText('@Value(_geometry)'))
Assuming that the "my_table" has a geometry type field called "geom" and the initiator feature has an attribute called "_geometry" that stores WKT geometry representation. You can use the GeometryExtractor to create the "_geometry" attribute.

 

Just be aware that if your geometry is complex and/or has a huge amount of vertices, this might not work in all instances. But for simple geometries it's a great solution.
PostGIS supports ST_* functions to manipulate geometry data. For example, this where clause determines if the geometry stored in the "geom" field intersects a given geometry defined with the Well Known Text (WKT) format.

 

select * from my_table
where ST_Intersects(geom, ST_GeomFromText('@Value(_geometry)'))
Assuming that the "my_table" has a geometry type field called "geom" and the initiator feature has an attribute called "_geometry" that stores WKT geometry representation. You can use the GeometryExtractor to create the "_geometry" attribute.

 

Agree. If the geometry could be too complex, I would try to perform approximate filtering using bounding box (envelope) with the SQL statement, and then perform detailed filtering by an FME transformer such as SpatialFilter. What is the best depends on the actual data condition.

 


you can use a select statement in the feature reader parameter to read only the attributes you need.


you can use a select statement in the feature reader parameter to read only the attributes you need.

I'm intrigued, where did you find that option?

If using a reader (from database) you can specify the columns required in the user attributes tab of (settings?) dialog evoked by the readers cog.


Reply