Login  Register

Re: Zip codes and Electoral districts

Posted by Daniel Haran on Feb 09, 2007; 1:01am
URL: http://civicaccess.416.s1.nabble.com/Zip-codes-and-Electoral-districts-tp865p869.html

Hi Stéphane,

There are a few problems with that approach. First of all, the
lat/long mapping databases tend to be copyrighted themselves. Besides,
those are the centroids - the center-most point of a polygon.

One of the main problems Russell mentioned (and explained further at
http://www.digital-copyright.ca/node/1607 ) is that the mapping is not
one to one. A postal code region can overlap several electoral
districts.

The drupal lobby module he mentioned has a good regular expression for
validating postal codes:
/([ABCEGHJKLMNPRSTVXY]\d[A-Z]\s?\d[A-Z]\d)/i

For non-techies, that first segment ABC...Y are all the allowable
first letters in a postal code. That reduces the number of
possibilities to 1,216,800 from 17,576,000. At a second a piece,
that's a bit over 14 days from 100 :)

cheers,

Daniel.

On 2/8/07, Stéphane Zagar <[hidden email]> wrote:

> Hey
>
> In fact, technically it's not complicated to get a zip code mapping with
> latitude and longitude :
>
> H3T1A1;45.5113;-73.6162
> H3T1B1;45.5083;-73.6183
> H3T1C1;45.5016;-73.6245
> H3T1E1;45.4974;-73.628
> H3T1G1;45.51;-73.614
> H3T1H1;45.5061;-73.6176
> H3T1J1;45.4945;-73.6282
> H3T1K1;45.5002;-73.6212
> H3T1L1;45.4962;-73.6253
> H3T1M1;45.4971;-73.6225
> H3T1N1;45.501;-73.6178
> H3T1P1;45.4942;-73.6229
> H3T1R1;45.5105;- 73.6154
> H3T1S1;45.5078;-73.6178
> H3T1T1;45.5052;-73.6198
> H3T1V1;45.5005;-73.6192
> H3T1W1;45.4987;-73.6208
> H3T1X1;45.4971;-73.6212
> H3T1Y1;45.4959;-73.6206
> H3T1Z1;45.4977;-73.6257
>
> And I think it's not that much complicated to do the same reverse
> engineering for electoral district.
>
> The problem is that mathematically, there are about 17 millions of valid
> combination of zip code. It take about 1 sec for my script to retrieve the
> zipcode/lat-long so if we do a basic computation it gives us about... 100
> days to retrieve everything (and probably a lot of bandwidth). Even if we
> set the last number to 1 (what I did in my previous test), it's still about
> 2 millions valid values. And I'm not sure if the website I use to retrieve
> this will allow this (with 1 request/sec, I can't imagine they won't see
> that something is happening).
>
> By the way, I have a question for geostuff people (Tracey ?) : On the
> geogratis website, there are some files concerning the electoral districts (
> http://geogratis.cgdi.gc.ca/geogratis/en/option/select.do?id=1169),
> but I don't know anything concerning the format (Arc Export or shape file).
> Is there a way to do something with that ? For example do a process
> what-ever to find out in which electoral district is a point (long-lat) ?
>
> Steph
>
> _______________________________________________
> CivicAccess-discuss mailing list
> [hidden email]
> http://civicaccess.ca/mailman/listinfo/civicaccess-discuss_civicaccess.ca
>
>