Skip to main content
Combine Featurereader and neighborfinder

I have a shapefile with polygons which I want to find the nearest neighbour from a postgis database of points. If the postgis database was in shapefile I would use the neighborfinder but I want to be more efficent and query the Postgis to find the nearest neighbour.

Is there a way of combining the two together in FME?


If you mean: Find the objects in an area surrounding a point objects, you can use the Bufferer to create a circle of interest and feed that to the FeatureReader. That way you will read the objects in a radius from the point object.


It is the other way round. I have a polygon which I want to find which is the nearest point and then take the attributes from that point. e.g. a boundary of a property I want to find the nearest postcode point (Codepoint) to the polygon and then take the postcode from the point.

The codepoint is in a postgis database.

Rather than reading the entire postgis database in as a reader and then using the neighborfinder to do find the nearest point I wanted to use featurereader to streamline the process.


So, if you want to select only those points from the PostGis database that are within or close to a polygon you want to enlarge the polygons by a margin (using the Bufferer) and use those polygons as Initiator for the FeatureReader to read the points. For performace reasons you might even want to replace the polygons by bounding boxes before enlarging them (using BoundingBoxReplacer).


So, if you want to select only those points from the PostGis database that are within or close to a polygon you want to enlarge the polygons by a margin (using the Bufferer) and use those polygons as Initiator for the FeatureReader to read the points. For performace reasons you might even want to replace the polygons by bounding boxes before enlarging them (using BoundingBoxReplacer).

Yes, I think it will be a two-step process (get near features with the buffer search then use a NeighborFinder). It is an interesting idea to combine the two - and perhaps you could suggest that in the ideas pages to see if it picks up votes from other users.


Yes, I think it will be a two-step process (get near features with the buffer search then use a NeighborFinder). It is an interesting idea to combine the two - and perhaps you could suggest that in the ideas pages to see if it picks up votes from other users.

@Mark2AtSafe and @sebkingsley: I will add the "Find the nearest object" as a Spatial filter to the FeatureReader as an idea.


Reply