# Working out whether a specific point is in a specified area - please help!

Show 40 post(s) from this thread on one page
Page 1 of 2 12 Last
• May 22nd 2008, 06:14 AM
altyfc
Working out whether a specific point is in a specified area - please help!
Hi everyone

First post. I apologise in advance if this question is a little elementary, but I hope you are able to help.

I am working on some travel sites and would like to try to work out whether a given point is in a given area.

Let's suppose I had longitude/latitude information for Manhattan's boundary. I have a series of co-ordinates which I join together by a straight line in order to define the area.

Now... let's suppose I am given co-ordinates for, let's say, the Empire State Building and Bronx Zoo. I want to be able to mathematically deduce whether these two points fall inside or outside the boundary. Obviously, in this case, the ESB does, and the BZ doesn't. But is that easy to work out automatically?

Please note, I am not a mathematician so really need an explanation of how to work this out that a non-mathematician would understand!

Thanks a lot,

Aaron
• May 22nd 2008, 08:07 AM
janvdl
Quote:

Originally Posted by altyfc
Hi everyone

First post. I apologise in advance if this question is a little elementary, but I hope you are able to help.

I am working on some travel sites and would like to try to work out whether a given point is in a given area.

Let's suppose I had longitude/latitude information for Manhattan's boundary. I have a series of co-ordinates which I join together by a straight line in order to define the area.

Now... let's suppose I am given co-ordinates for, let's say, the Empire State Building and Bronx Zoo. I want to be able to mathematically deduce whether these two points fall inside or outside the boundary. Obviously, in this case, the ESB does, and the BZ doesn't. But is that easy to work out automatically?

Please note, I am not a mathematician so really need an explanation of how to work this out that a non-mathematician would understand!

Thanks a lot,

Aaron

If I understand you correctly...

If you have the boundaries' coordinates, then the latitiude of the point must be a value between the latitudes if the boundaries AND its longitude must be a value between the longitude of that of the boundaries.
• May 22nd 2008, 09:22 AM
altyfc
Thank you for the reply but - alas - I don't think it's as simple as that.

Take this map for example:

http://www.map-of-switzerland.com/images/ticino.gif

If you take the "L" of Lugano... this point is within the lat/long extremes but, because of the irregular shape, it doesn't fall within the boundaries of the specific region.

Or have I not understood your reply correctly? :)
• May 22nd 2008, 09:31 AM
janvdl
Quote:

Originally Posted by altyfc
Thank you for the reply but - alas - I don't think it's as simple as that.

Take this map for example:

http://www.map-of-switzerland.com/images/ticino.gif

If you take the "L" of Lugano... this point is with the lat/long extremes but, because of the irregular shape, it doesn't fall within the boundaries of the specific region.

Or have I not understood your reply correctly? :)

Excuse me for not understanding, but why would you want to check if the text is in the area? Are you not concerned about the point only?

EDIT: Oh maybe you only used the "L" as an example. I can honestly not think of a way to check if it would be in the area if the area has such an irregular shape.
• May 22nd 2008, 12:21 PM
altyfc
Yes, the L was just an example... I was simply illustrating that it didn't 'work' for the method I think you were suggesting.

I just want to find whether point x (for which I would have lat/long co-ordinates) fits in area y (for which I would have a series of co-ordinates which, when connected together, would mark the boundary).

I'm sure there must be a way...

Aaron
• May 22nd 2008, 12:37 PM
topsquark
Quote:

Originally Posted by janvdl
If I understand you correctly...

If you have the boundaries' coordinates, then the latitiude of the point must be a value between the latitudes if the boundaries AND its longitude must be a value between the longitude of that of the boundaries.

What about the red dot? It's outside the figure but inside the longitude and latitude boundaries that you specified.

-Dan
• May 22nd 2008, 12:38 PM
altyfc
Yes, that's right.

This is the same point as I was trying to make. But your diagram illustrates it much more clearly, thank you. :)
• May 22nd 2008, 01:08 PM
janvdl
Quote:

Originally Posted by topsquark
What about the red dot? It's outside the figure but inside the longitude and latitude boundaries that you specified.

-Dan

I didn't consider abnormal shapes...

How exactly will it be determined? By computer?
• May 22nd 2008, 05:44 PM
altyfc
Yes, we would be looking to decipher this by computer, as we'd be wanting to do this for multiple points (thousands, in fact!).

We just need to somehow grasp an understanding of the maths that any scripting would need to be based on.
• May 23rd 2008, 12:17 AM
janvdl
Quote:

Originally Posted by altyfc
Yes, we would be looking to decipher this by computer, as we'd be wanting to do this for multiple points (thousands, in fact!).

We just need to somehow grasp an understanding of the maths that any scripting would need to be based on.

Why not divide the map into small squares?
• May 23rd 2008, 01:55 AM
altyfc
I imagine that might be a possibility but I just assumed there must be a way of calculating this more immediately... ??
• May 23rd 2008, 02:07 AM
janvdl
Quote:

Originally Posted by altyfc
I imagine that might be a possibility but I just assumed there must be a way of calculating this more immediately... ??

My knowledge is too limited for this, I'm sorry. Maybe one of our senior mathematicians will take a look at this and let you know if it's possible.

EDIT: Since it's going to be on a computer, why not define the positions of the pixels as boundaries, and check if a point is between the specific row of pixels?
• May 23rd 2008, 08:29 AM
altyfc
Quote:

Originally Posted by janvdl
EDIT: Since it's going to be on a computer, why not define the positions of the pixels as boundaries, and check if a point is between the specific row of pixels?

Unless I'm misunderstanding you, I think that's the same as your original suggestion, and won't allow for irregular shapes.

Should I be posting this in the advanced geometry forum? It's too advanced for me, but I was hesitant about posting it there straight off, as I wasn't sure if it would be considered 'advanced' here... :)
• May 23rd 2008, 08:40 AM
janvdl
Quote:

Originally Posted by altyfc
Unless I'm misunderstanding you, I think that's the same as your original suggestion, and won't allow for irregular shapes.

No let's say on a specific line, we have a part of the boundary. Or a few pixels, as the left boundary. And on the same horisontal line, we have the right boundary of a few pixels. Now we check that the point itself, is between the pixels.

So we are dividing the whole map into pixels. And then we check for all the black pixels which we say makes up the outer border of a country, for example.

Quote:

Originally Posted by altyfc
Should I be posting this in the advanced geometry forum? It's too advanced for me, but I was hesitant about posting it there straight off, as I wasn't sure if it would be considered 'advanced' here... :)

No keep it in this forum. You will get in trouble for "double posting".
• May 23rd 2008, 09:16 AM
altyfc
But, even if your point falls between the left-hand-most boundary and the right-hand-most, you will can't necessarily make the assumption that a point between those two points is within your area.... I don't think, at least.
Show 40 post(s) from this thread on one page
Page 1 of 2 12 Last