views:

727

answers:

5

If I have a point in latitude/longitude and I want to find out if it is a valid for use within a particular coordinate system, how can I do it?

As an example. Say I am working in Swiss Grid (CH 1903, EPSG 21781) and have a point representing something in London in the UK, I want to know if that point is valid in the Swiss Grid coordinate system.

Typically the conversion will work, but it may be so far outside the area that Swiss grid is good for that it is not really valid.

The context for this is that users will be importing points in latitude longitude into an application that works in a projected coordinate systme and they want to be warned when the points they are importing fall outside the projected coordinate system bounds.

But as far as I can tell, a projected coordinate system does not have any bounds.

+2  A: 

You're imposing an artificial bounds upon the coordinate system by stating that there is a limit to the system itself (i.e. a point is "outside" the bounds because it falls out of the area I care about).

In that case, find the "corners" of the area you're interested in. If a point falls outside of those bounds, then you can flag the point as being outside your area of interest.

Michael Todd
+1  A: 

Sorry, but you are stuck implementing something on your own, because it really needs to be your rules. Projected coordinate systems typically don't have bounds, but they have error behavior. For a particular application, a given projected coordinate system is often only accurate enough within certain bounds.

The short answer therefore is that it really needs to be up to your application to impose those restrictions. Every coordinate system is different, and your needs will drive a lot of it. For instance, perhaps you need 100 meter accuracy, in which case the Swiss Grid might be adequate for a fairly large area. If you need 10 meter accuracy, the errors the build up on the edge cases will become significant much faster, and therefore your bounds must be tighter.

Using a "four-corners-bounding-box" approach will work the bulk of the time, but it's not universal. Some projections bounds are better expressed as "radius from the central point", and it wouldn't shock me if some where "distance from the prime meridian". It's all a matter of how the errors build up for a given projection.

Chris Arguin
+1  A: 

The bounds for a given coordinate system are specific to that coordinate system so there is no generic algorithm for determining if a coordinate is out of bounds.

Beyond that, being "out of bounds" is probably specific to your domain. For example, in the Swiss Grid, 400N 200E is not in Switzerland, and therefore out of bounds for the typical use of the Swiss Grid and yet still represents a real place. Is this out of bounds for your domain or not?

Alex B
+5  A: 

Although the answers listed are correct - there is no concept of "bounds" in a coordinate system, there are still approaches you can use.

The EPSG database provides a latitude/longitude bounding box for each coordinate system defined. This is listed in the "Area" table, and provides a (albeit rough) bounding box in which the coordinate system is reasonable. This alone might be enough to help you determine a reasonable extent.

By checking the coordinate of your point, and the four corners in the EPSG DB, you should be able to tell whether the coordinate is (potentially) reasonable for a given projection.

Reed Copsey
Thanks for this - very interesting. It looks like this will do the job.
Nick R
A: 

The EPSG and custom projections are available at:

http://www.spatialreference.org/

Search the site for your EPSG code and you can see the coordinates listed.

milovanderlinden
This doesn't really help. All it shows is the central location. The epsg database identified above helps a lot more as it provides a way to get a bounding box
Nick R
That is not correct. Perhaps you overlooked the wgs84 bounds and the projected bounds?See: http://www.spatialreference.org/ref/epsg/28992/ as example
milovanderlinden
I am checking with the developers of spatialreference if they can expose the wgs84 and projected boundingbox through a rest interface. It could then provide you with an internet lookup to see if coordinates are valid.
milovanderlinden