Skip to main content
Question

Get polygons which central points are inside

  • May 29, 2018
  • 7 replies
  • 114 views

Forum|alt.badge.img

Hello,

In one table in my database I have some polygons (lets say covering cities) with their names. In other tables I have some other features(geometries together with attributes).

Now I would like the flow like that:

1. Pass publish parameter as city name.

2. get all features from other tables (for example schools) but only which are inside specified city

3. spatial filter can't be (contains) because I also want to have school presented on the attached image

4. My idea was to get the central point for each school, then test if it is inside given polygon and if yes then add it to the result.

My idea was to do it this way:

1. feature reader for cities with filter applied

2. feature reader for schools - end now the problem, should I apply the spatial filter here or is it impossbile?

Now how to test if the center of given school is inside that city?

I don't know how to combine it all together. Thanks for any hints on that. cheer!

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

7 replies

david_r
Celebrity
  • 8394 replies
  • May 29, 2018

Can't you simply use the spatial predicate INTERSECTS rather than CONTAINS?


Forum|alt.badge.img
  • Author
  • 45 replies
  • May 29, 2018

Can't you simply use the spatial predicate INTERSECTS rather than CONTAINS?

I don't think so because for example I don't want this school to be put into result (school_out)

 

 

 

 


philippeb
Enthusiast
Forum|alt.badge.img+22
  • Enthusiast
  • 329 replies
  • May 29, 2018

You only want schools that have their centroid inside the city?

Convert your schools to points with CenterPointReplacer and after you use SpatialFilter with CONTAINS.


Forum|alt.badge.img
  • Author
  • 45 replies
  • May 29, 2018

You only want schools that have their centroid inside the city?

Convert your schools to points with CenterPointReplacer and after you use SpatialFilter with CONTAINS.

Ok but I would like to have original polygons in the result so I have to get them back from DB? I don't know how to set up the flow :/

 

 


philippeb
Enthusiast
Forum|alt.badge.img+22
  • Enthusiast
  • 329 replies
  • May 29, 2018
Ok but I would like to have original polygons in the result so I have to get them back from DB? I don't know how to set up the flow :/

 

 

Yeah you could get the polygons back with a FeatureMerger

 

 


david_r
Celebrity
  • 8394 replies
  • May 29, 2018
Yeah you could get the polygons back with a FeatureMerger

 

 

Another alternative is to use the GeometryExtractor to save the polygon geometry as an attribute, then use the GeometryReplacer to get it back later on.

jkr_wrk
Influencer
Forum|alt.badge.img+35
  • 424 replies
  • May 30, 2018

Be aware that a centre-point is not always the same as mostly in. There can be weird shaped schools in weird shaped city's where the centre-point of the building is inside the city, but the building itself is not in the city at all. This could be the case with L or C shaped buildings. But you have to see for yourself if this is a problem in your area.

I think i would start with a Contains filter to filter out the 90% that is totally within the city. Then you could calculate the % of area that is within the city to figure out the rest. This could be done with an GeometryExtractor - AreaCalculator - AreaOnAreaOverlayer - AreaCalculator - Tester (Divide Area2/Area1) - GeometryReplacer.

But maybe this is overkill to your problem.