Finding Rural Postal Codes in Canada

March 28th, 2008  |  Published in Tips, Well.ca  |  2 Comments

Yesterday, Alex, who handles marketing at Well.ca, asked for a list of top 50 rural customers in Canada. “Easy!” was my reply, then I thought about it. How to do it? Maybe if I get a list from Canadapost with all the postal codes and their population density I can use that. Maybe I can write up some crazy application to determine it based on the number of cities/towns that share the postal code.

And then, just for the hell of it, I checked Wikipedia’s article on Postal Codes…then the problem just became easier. According to the Wikipedia article, the first number in the postal code represents if the postal region is rural or urban. If the number is 0 (N0G2J3), the postal region is a rural area. If the number is anything else, 1-9, the postal region is an urban area. With this I wrote up a quick regular expression (^[a-zA-Z]{1}[0]{1}[a-zA-Z 0-9]+) and used the power of MySQLs regular expressions (have to remember MySQL can search w/ regular expressions) to write up a query to determine the top 50 rural customers. Easy!

Random fact: Wikipedia has all possible postal region codes (first 3 digits of the postal code) and their corresponding city/region. I wonder who took the time…The article is here.

Random fact II: The only provinces to have more then one letter as the first letter in a postal code is Quebec and Ontario. All the others have a specific letter to determine the province/territory. The map is here.

Responses

  1. Gary Will says:

    March 28th, 2008 at 9:38 am (#)

    And you can be on a “rural route” for mail delivery but still have an urban postal code, as long as your rural route is linked to an urban area.

  2. clong says:

    March 28th, 2008 at 4:20 pm (#)

    Cool, I didn’t know that. I’m not going to tell Alex that, she’ll just want more specific stats. ;)

    I’m kind of curious what happens when Canadapost upgrades a rural region to urban and what is the magical population number they use. Is it a gradual process, or do they just suddenly change it. I was initially thinking that they don’t “urbanize” regions too often, but, after reading up on it, they appear to do it fairly often (at least once every few years).

    Still a neat trick for these kind of statistics, and can always turn it into a bar trick (on second thought, maybe not).

Leave a Response

Subscribe via RSS

If you like the content of this website and are looking for a way to be notified of new content, look no further. Just click the orange icon to your right and subscribe using your favorite feed reader.