Find the State given Latitude and Longitude Coordinates

后端 未结 4 928
一向
一向 2021-02-06 16:14

I have a set of 900 Latitude and Longitude Coordinates-- I need a relatively simple method for finding the \'State\' referred to by these coordinates. If it helps, the data is

相关标签:
4条回答
  • 2021-02-06 16:34

    Try to use the average values as provided here. With a bit of luck, most of your 900 coordinate pairs belong to the state with the nearest center. Calculation of distances between longitude/latitude locations is explained here.

    An alternative would be to use a ZIP table with US postcodes as provided here. Once you know the postcode, you know the state, don't you? I'm not sure, but each state has an interval of ZIP codes. Once you know the ZIP code of a location, you can find the interval and the state it belongs to.

    A list of coordinates of US locations could help to get a more exact allocation: http://www.bcca.org/bahaivision/fast/latlong_us.html Find the nearest location in the list and take its state as result.

    0 讨论(0)
  • 2021-02-06 16:45

    A simpler solution would be to just use the ezcmd.com rest API services. They provide two APIs:

    http://ezcmd.com/apps/app_geo_postal_codes#geo_postal_codes_api

    1) All you have to do is just give it a zip code and a country code (for usa you either use US or USA) and optionally you'll pass the distance radius, and units (Miles or Km) and it'll return all other zip codes with state and province that are within the given distance

    2) Free search, where you give it any fuzzy search phrase that includes either one of zip / city / state / province and country and it returns the best matches for that search phrase.

    Hint: You can use #2 to find the zip code for a fuzzy (human readable) address and pass that zip code to #1 to find nearest places to that zip code.

    Also they have another API that returns zip code along with full geo location information for a given IP address here:

    http://ezcmd.com/apps/app_ezip_locator#ezip_locator_api

    Enjoy ! I hope this helps.

    0 讨论(0)
  • 2021-02-06 16:47

    Google provide a Geocoding service. Part of this is reverse geocoding which converts geographic coordinates into a human-readable address including States. This Demo illustrates what can be done. There are limits to what you can do with this service.

    0 讨论(0)
  • 2021-02-06 16:48

    Google requires that geocoding / reverse geocoding be used with maps that users can see, so if that isn't an option for you, I think the best way is to use a database with spatial functions. First, you'll need the state boundaries found for free at NationalAtlas.gov. I use SQL Server (need 2008 or 2012 versions) and you can use the STContains() method to find what state it belongs to.

    0 讨论(0)
提交回复
热议问题