How to get the bounding coordinates for a US postal(zip) code?

前端 未结 5 1226
眼角桃花
眼角桃花 2020-12-08 11:25

Is there a service/API that will take a postal/zip code and return the bounding(perimeter) coordinates so I can build a Geometry object in a MS SQL database?

By boun

5条回答
  •  南方客
    南方客 (楼主)
    2020-12-08 11:47

    What you are asking for is a service to provide "Free Zip code Geocoding". There are a few out there with varying quality. You're going to have a bad time coding something like this yourself because of a few reasons:

    1. Zip codes can be assigned to a single building or to a post office.
    2. Zip codes are NOT considered a polygonal area. Projecting Zip codes to a polygonal area will require you to make an educated guess where the boundary is between one zipcode and the next.
    3. ZIP code address data specifies only a center location for the ZIP code. Zip code data provides the general vicinity of an address. Mailing addresses that exist between one zipcode and another can be in dispute on which zipcode it actually is in.
    4. A mailing address may be physically closer to zipcode 11111, yet its official zip code is a more distant zip code point 11112.

    Google Maps has a geocoding API:

    The google maps API is client-side javascript. You can directly query the geocoding system from php using an http request. However, google maps only gives you what the United States Postal Service gives them. A point representing the center of the zipcode.

    https://developers.google.com/maps/#Geocoding_Examples

    map city/zipcode polygons using google maps

    Thoughts on projecting a zipcode to its lat/long bounding box

    There are approximately 43,000 ZIP Codes in the United States. This number fluctuates from month to month, depending on the number of changes made. The zipcodes used by the USPS are not represented as polygons and do not have hard and fast boundaries.

    The USPS (United States Postal Service) is the authority that defines each zipcode lat/long. Any software which resolves a zipcode to a geographical location would be in need of weekly updates. One company called alignstar provides demographics and GIS data of zipcodes ( http://www.alignstar.com/data.html ).

    Given a physical (mailing) address, find the geographical coordinates in order to display that location on a map.

    If you want to reliably project what shape the zipcode is in, you are going to need to brute force it and ask: "give me every street address by zipcode", then paint boxes around those mis-shapen blobs. Then you can get a general feel for what geographical areas the zipcodes cover.

    http://vterrain.org/Culture/geocoding.html

    If you were to throw millions of mailing address points into an algorithm resolving every one to a lat/long, you might be able to build a rudimentary blob bounding box of that zipcode. You would have to re-run this algorithm and it would theoretically heal itself whenever the zipcode numbers move.

    Other ideas

    http://shop.delorme.com/OA_HTML/DELibeCCtpSctDspRte.jsp?section=10075

    http://www.zip-codes.com/zip-code-map-boundary-data.asp

提交回复
热议问题