6 Replies Latest reply: Dec 8, 2017 5:44 AM by Arun Raj

# Point in Polygon

Hi ,

I need to find out if a point is inside or outside a polygon. Suppose I have a square with the following co-ordinates :

0,0

0,2

2,2

2,0

Is there a way in Load script, I can identify whether or not point (x,y) is inside or outside the square? So if my point is (1,1) then it should return 'Inside' and if my point is (3,3) it should return 'outside'.

Any help will be greatly appreciated.

Kind Regards

A

• ###### Re: Point in Polygon

Why 1,1 and 3,3 only.. Is there any logic to pick only those or does they coming from another field?

• ###### Re: Point in Polygon

Hi Anil,

No 1,1 and 3,3 were just examples. It is not necessary that the shape is a square. It can have any number of vertices.

• ###### Re: Point in Polygon

Not really, Sure how Polygon values are setting up. Are you loading any earth data using boudaries from in and out??

• ###### Re: Point in Polygon

Hi Anil,

You are right, I will be given latitude longitude co-ordinates.

I will be given the latitude longitude co-ordinates of an area of any shape for example:

Tab1:

Area_Latitude, Area_Longitude

51.717772, 0.906372

51.690096, -0.494385

51.372295, -0.543823

51.262431, -0.175781

51.2074, 0.340576

51.512674, 0.038452

I need to show whether the customer address falls within the above area or not.

Tab2:

CustomerID, Cust_Latitude, Cust_Latitude

1, 51.499305, -0.137329

2, 51.478783, 0.164795

Result:

CustomerID, Cust_Latitude, Cust_Latitude, Inside_OutsideAreaIndicator

1, 51.499305, -0.137329, Inside Area

2, 51.478783, 0.164795, Outside Area

• ###### Re: Point in Polygon

What kind of polygons do you have?

If only squares then one condition might be simply:

x>=x1 and x<=x2 and y>=y1 and y<=y2

Please post some sample data (tables and fields) and your expected result to test with.

thanks

regards

Marco

• ###### Re: Point in Polygon

Hi Marco,

You are right, that condition will work for a square.

Unfortunately it can be any shape. eg: pentagon, hexagon . with any number of vertices.

I will be given the latitude longitude co-ordinates of an area of any shape for example:

Tab1:

Area_Latitude, Area_Longitude

51.717772, 0.906372

51.690096, -0.494385

51.372295, -0.543823

51.262431, -0.175781

51.2074, 0.340576

51.512674, 0.038452

I need to show whether the customer address falls within the above area or not.

Tab2:

CustomerID, Cust_Latitude, Cust_Latitude

1, 51.499305, -0.137329

2, 51.478783, 0.164795

Result:

CustomerID, Cust_Latitude, Cust_Latitude, Inside_OutsideAreaIndicator

1, 51.499305, -0.137329, Inside Area

2, 51.478783, 0.164795, Outside Area

KInd Regards

Arun