Dear SPSS, According to the following IBM website: the first link should provide the lat-long coordinates of US 3-digit ZIP codes, but unfortunately the link is broken. If anyone happens to have a list of the lat-long coordinates of US 3-digit ZIP codes (not 5-digit ZIP codes), I'd really appreciate it. @Jon: Could you please inform the appropriate person in IBM that the link on their website is broken? Thank you, Ryan |
I looked to see if the google geocoding api could return this info. It has an option for "postal_code_prefix", but when using the first three zip codes I think this just returns the centroid of the US. For general use here is a 5 digit zip code geocoding function (as I bothered to get that far might as well write one up!) First time I've heard of Zip prefixes, so I am unsure of any source of approximate coverage.
*********************************************. *Geocoding zip codes using google mapping api. BEGIN PROGRAM Python. import urllib, json #Takes Zip as a string!!, needs to be properly formatted #note free API cuts off after 2,500 requests def GoogZip(Zip): url = "https://maps.googleapis.com/maps/api/geocode/json?components=country:US|postal_code:" + Zip response = urllib.urlopen(url) jsonRaw = response.read() place = json.loads(jsonRaw) if place['status'] == 'OK': lng = place['results'][0]['geometry']['location']['lng'] lat = place['results'][0]['geometry']['location']['lat'] else: lng,lat = None,None return [lng,lat] print GoogZip("12303") END PROGRAM. *An example use. DATA LIST FREE / Zip (A5). BEGIN DATA 12303 12222 17815 END DATA. DATASET NAME Zip. SPSSINC TRANS RESULT=lng lat TYPE=0 0 /FORMULA GoogZip(Zip=Zip). *********************************************. |
In reply to this post by Ryan
I have reported the broken link to the
keepers of the Technotes. A little hunting around on the web didn't
turn up any free, 3-digit, lat/long coding, although 5-digit is readily
available. I noticed when I worked with 5-digit codes a few years
ago that the center lat/long was sometimes a pretty rough approximation
if you were, for example, doing distance calculations between nearby zip
codes as they are often very irregular. I suppose 3-digit would be
smoother, but that's just a guess.
As for using, say the Google lookup api, which is 5-digit anyway, I think, you would need to look carefully at the license terms, since allowed usage is very restricted. As an irrelevant aside, the then-called Sears Tower, where SPSS used to be headquartered, has its own 5-digit zip, and individual floors had their own 4-digit extensions. Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] phone: 720-342-5621 From: Ryan Black <[hidden email]> To: [hidden email] Date: 03/08/2015 09:20 AM Subject: [SPSSX-L] OT: Lat-Long Coordinates of US 3-Digit ZIP Codes Sent by: "SPSSX(r) Discussion" <[hidden email]> Dear SPSS, According to the following IBM website: http://www-01.ibm.com/support/docview.wss?uid=swg21401158 the first link should provide the lat-long coordinates of US 3-digit ZIP codes, but unfortunately the link is broken. If anyone happens to have a list of the lat-long coordinates of US 3-digit ZIP codes (not 5-digit ZIP codes), I'd really appreciate it. @Jon: Could you please inform the appropriate person in IBM that the link on their website is broken? Thank you, Ryan ===================== To manage your subscription to SPSSX-L, send a message to LISTSERV@... (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
That is a good point and fun fact about the Sear's tower. I've seen zip codes supplied by the census that are discontinuous, so presuming that the single point is returned is a centroid it is possible to have that point not even inside the actual area the zip code is supposed to cover.
An example in Albany the SUNY school gets its own zip code, so even the alternate campus a few miles away has 12222 zip. The zip code 12203 is highly discontinuous as well, see https://goo.gl/maps/reiTl (the census zip codes don't have the places to the north of the city, but do have an island around the Sage/Law School area. So I'm unsure where Google gets this info.) I would hazard a guess that most zip code errors in location are going to have an upper bound on the error around 2-3 miles (for relatively urban areas - can probably grow quite a bit in rural places). So between distances of ~100 miles this is not a big deal, but distances in just one city this could be pretty substantial. |
In reply to this post by Jon K Peck
It is always good to remember that Zip Codes are NOT official areas nor are they required to be nested or coterminous with other "official" areas. The first 3 digits of a ZIP code determine the central mail processing facility, also called sectional center facility or "sec center", that is used to process and sort mail. All mail with the same first 3 digits is first delivered to the same sec center where it is sorted according to the last 2 digits and distributed to local post offices. In this respect, there is primarily a hub and spoke relationship between the sectional center (zip3) and subordinate Zip5 delivery zones. Because the whole rationale for Zip codes is to improve mail delivery it is not necessary that this system of delivery zones and routes generates a compact tiling of the surface, and it does not as Andy W has mentioned. This is why the Census Bureau created ZCTA files ( Zip code tabulation areas) to approximate mapping the "official" Census Tracts into/onto Zip Codes. The ZCTA files are intended for mapping and include shapefiles and such. Both 5-digit and 3-digit ZCTA files were/are created. If you cannot locate any of these anywhere on the net, I actually do have them stashed away on my home computer. zcta5 ~~ 650 MB (compressed zip) zcta3 ~~ 130 MB (compressed zip) ... Mark Miller On Sun, Mar 8, 2015 at 9:46 AM, Jon K Peck <[hidden email]> wrote: I have reported the broken link to the keepers of the Technotes. A little hunting around on the web didn't turn up any free, 3-digit, lat/long coding, although 5-digit is readily available. I noticed when I worked with 5-digit codes a few years ago that the center lat/long was sometimes a pretty rough approximation if you were, for example, doing distance calculations between nearby zip codes as they are often very irregular. I suppose 3-digit would be smoother, but that's just a guess. |
Addendum to my note regarding ZCTA files TIGER/Line® Shapefiles and TIGER/Line® Files are available from the US Census at They show annual updated versions of the TIGER files from 2006 : 2014 The 2007 thru 2009 versions are the only ones which include Zcta matches for Zip3 as well as Zip5. All later versions have only Zip5. The Tiger files are ready to use with most GIS systems. ... Mark Miller On Sun, Mar 8, 2015 at 12:03 PM, Peter Spangler <[hidden email]> wrote:
|
Thank you Mark for that. It would be a slight chore but not too bad to simply collapse the 5 digit zip's based on the first three digits in GIS, and then calculate the centroid. Or just take the centroids of the 5 digit zips and calculate the centroid of those points. (I suspect they would be pretty similar, and by the time you are getting that far away from the actual geography a single point is not quite as meaningful, like taking the centroid of the states and mapping those. It can be useful to assess gross geographic patterns, but not much else.)
|
Thanks all. ArcGIS provided the centroids for me. I appreciate the comments regarding zips. Very helpful. For those interested, I am utilizing zips to account for geospatial dependencies within a mixed modeling framework. Really fascinating findings!
The day SPSS offers this capability in mixed models, I will expound on the topic. Ryan Sent from my iPhone > On Mar 9, 2015, at 11:18 AM, Andy W <[hidden email]> wrote: > > Thank you Mark for that. It would be a slight chore but not too bad to simply > collapse the 5 digit zip's based on the first three digits in GIS, and then > calculate the centroid. Or just take the centroids of the 5 digit zips and > calculate the centroid of those points. (I suspect they would be pretty > similar, and by the time you are getting that far away from the actual > geography a single point is not quite as meaningful, like taking the > centroid of the states and mapping those. It can be useful to assess gross > geographic patterns, but not much else.) > > > > ----- > Andy W > [hidden email] > http://andrewpwheeler.wordpress.com/ > -- > View this message in context: http://spssx-discussion.1045642.n5.nabble.com/OT-Lat-Long-Coordinates-of-US-3-Digit-ZIP-Codes-tp5728923p5728937.html > Sent from the SPSSX Discussion mailing list archive at Nabble.com. > > ===================== > To manage your subscription to SPSSX-L, send a message to > [hidden email] (not to SPSSX-L), with no body text except the > command. To leave the list, send the command > SIGNOFF SPSSX-L > For a list of commands to manage subscriptions, send the command > INFO REFCARD ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
In reply to this post by Mark Miller
Thank you for the files, Mark! I see that each ZCTA is associated with a lat/long. I have a database of address records with zip codes and survey data with the ZCTA. Do I understand correctly that using TIGER/shape files can join or map each record in the two datasets? Best Peter On Sun, Mar 8, 2015 at 12:03 PM, Peter Spangler <[hidden email]> wrote:
This email may contain confidential information for the sole use of the intended recipient(s). If you are not an intended recipient, please notify the sender and delete all copies immediately. ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
Peter, The files I sent to you are Tiger Line files (hence the tl prefix on the filenames) If you have a GIS which can handle Tiger files, then you should be able to produce maps of the survey data. ... Mark On Thu, Mar 12, 2015 at 10:14 AM, Peter Spangler <[hidden email]> wrote:
|
Free forum by Nabble | Edit this page |