• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 586
  • Last Modified:

Determine Country by Geographic Coordinate

Hi, is it possible to determine country name by having only geographic coordinate in SQL Server 2008?
0
zstapic
Asked:
zstapic
  • 3
  • 2
1 Solution
 
wht1986Commented:
if you had a table containing the geography of each country it is quite easy
0
 
wht1986Commented:
The code to determine  what polygon a point contains might look like

select countyname from Countries where geo.STContains( geography::Point(long,lat,4326) ) = 1

It is important to remember the geography data type can only hold data which geography instance is in a single hemisphere.  Joy to microsoft for the implementation.  Heres a link that describe it further

http://blogs.msdn.com/isaac/archive/2009/02/06/the-geography-hemisphere-limitation.aspx
0
 
oobaylyCommented:
The NOAA provides coastline data, unfortunately it's just a series of points. While it's simple to create a geography object from them, it doesn't provide the name of the country.

http://rimmer.ngdc.noaa.gov/coast/

Also have a look here:
http://www.collinssoftware.com/freegis_by_region.htm
0
 
wht1986Commented:
did that help zstapic?
0
 
oobaylyCommented:
I also have a basic set of data that contains the bounding rectangle for countries, you could either test for a point being inside the rectangle, or a point closest to the rectangle's centroid.
However it's not guaranteed as if you take a point just inside the border of a large country, the centroid of the neighbouring small country may be closer, so the wrong country could be returned.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now