Determine if coordinates fall inside polygon

I have a set of polygons in a GeoJSON file. On the other hand, I have a bunch of <lat, long> coordinates.

I need to label each coordinate pair, with the polygon it belongs to (eg. which neighbourhood).

Can I use any of the existing geographical nodes for determining whether one coordinate pair is inside that polygon?

 

Thanks,

Fernando

 

Hi fernando,

maybe you could use the shapefile extension for this (https://tech.knime.org/shapefile-extension)

I know they have a coordinate row filter node, maybe you can use this to test if the point is inside the polygon.

Sorry for not being more helpful.

Cheers, Iris 

1 Like

Thanks!

 

Hei @Iris,

I am trying to do exactly the same thing as Peleitor. After searching it on Forum, I have followed your suggestion. But I am having Invalid Polygon error. Do you have any in order to fix this problem?

Best.

Hi @emre -

Could you post an example workflow demonstrating the error? Then maybe we can dig in and find out exactly what’s going on in your case.

Hi Scott,

I attach the workflow that I am working on. I can add other files like GEOJSON file if you need. Thank you for your time.

Best

Working_Matche_koordinater_med_polygoner.knar.knwf (11.4 KB)

Hi @emre -

It would be useful if you could upload the shapefile as well. Thank you!

Hi @ScottF,

I thought it was uploaded with workflow. Sorry. You can find the file here.

Basisdata_0000_Norge_25833_Grunnkretser2018_GEOJSON-kopi.zip (3.7 MB)

Hey there,

I am still having problems with polygons here. I have Invalid Polygon error when I used the coordinate row filter node. What should I do to fix polygons?

Best

Hi @emre

I’m not a GIS expert, but are you sure the data is in the right format for the task you’re trying to accomplish? From the thread above, I gather you’re trying to identify whether particular points fall inside a polygon, but the data you provided looks more like a series of lines (possibly roadways?) than closed polygons when I visualized your dataset using mapshaper.org.

I suspect this is why you’re seeing “invalid polygon” warnings in the Coordinate Row Filter node.

1 Like

What I am trying to do is to match points with polygons and data shows boundaries of polygons which represent circuits like neighborhoods. I also noticed that data looks like non-closed polygons but I took the data from a trusted source. And plus there are polygons very well closed but I had the error for all of the polygons.

In what application do you load this data and see ‘polygons very well closed’? Do you mean that there are sets of line segments that intersect and so end up forming a contained area given N individual line segments? (If so, those aren’t polygons - you will need something that takes these lines, discards ones that do not form closed areas, and derives actual polygons from the parts of ones that do.)

I have uploaded them to mapshaper.org and observed that there are closed polygons. The only problem was the exterior boundary of the country which would surround the whole map. And I thought it might be something special with GEOJSON file format since I have ever worked with that before. I have downloaded the file from the government`s map database and did not think there could be a problem with that. When I saw problems with all of the polygons on Knime, I thought it might be a misunderstanding and some missing points.

Anyway. I am helpless to fix it.