Difference between revisions of "Downloading PEI Civic Address Data"
Line 1: | Line 1: | ||
+ | ==About the Civic Address System== | ||
+ | |||
In recent years, [[Prince Edward Island]] has moved to a uniform system of civic addresses, where each property in the province is assigned a unique civic address. Originally intended to enable the 911 emergency system, the civic addressing system, because it ties civic address data to latitude and longitude geolocation information, has tremendous utility for other applications. | In recent years, [[Prince Edward Island]] has moved to a uniform system of civic addresses, where each property in the province is assigned a unique civic address. Originally intended to enable the 911 emergency system, the civic addressing system, because it ties civic address data to latitude and longitude geolocation information, has tremendous utility for other applications. | ||
Line 5: | Line 7: | ||
Documented here is a PHP script that enables the automatic creation of a [[MySQL]] database and download and import of current civic address data. The system was created to enable the [[PEI Civic Address Lookup with AJAX]] application, but can be used to drive any application that relies upon having access to digital Prince Edward Island address information. | Documented here is a PHP script that enables the automatic creation of a [[MySQL]] database and download and import of current civic address data. The system was created to enable the [[PEI Civic Address Lookup with AJAX]] application, but can be used to drive any application that relies upon having access to digital Prince Edward Island address information. | ||
− | ===Reference Materials | + | ==What the Script Does== |
+ | |||
+ | The PHP script connects to the [http://www.gov.pe.ca/civicaddress/download/index.php3 civic address data download page] and grabs the latest data for the three counties of Prince Edward Island as tab-delimited ASCII text files. These are then concatenated into one large text file and imported into a MySQL table. If the table already exists, it is emptied before import; if the table doesn't exist, then it is created, along with associated indices. | ||
+ | |||
+ | ==System Requirements== | ||
+ | |||
+ | The script was created on a Linux system, and has only been tested under Linux; it may work, with modifications, under other operating systems. | ||
+ | |||
+ | * [http://www.mysql.com/ MySQL] | ||
+ | * [http://www.php.net/ PHP] (you don't need a webserver, just the command-line PHP will do) | ||
+ | * [http://www.gnu.org/software/wget/wget.html GNU Wget] (used to download the data) | ||
+ | |||
+ | ==Download or Browse the Source Code== | ||
+ | |||
+ | The source code is kept in a [[Subversion]] repository: | ||
+ | |||
+ | * [http://websvn.reinvented.net/listing.php?repname=PEI+Civic+Address+Data&path=%2F&sc=0 Browse the Repository] | ||
+ | * Via HTTP: [http://svn.reinvented.net/PEICivicAddressData http://svn.reinvented.net/PEICivicAddressData] | ||
+ | * Via SVN: svn://svn.reinvented.net/PEICivicAddressData | ||
+ | |||
+ | ==Install and Run== | ||
+ | |||
+ | # Create a new database, or select an existing one, to hold the civic address data. | ||
+ | # Edit the file '''settings/PEICivicAddressData.inc''', adding your MySQL username and password, and selecting the database name and table name for the civic address data (these default to 'civicaddress', so the assumption is that you have a database called 'civicaddress'). | ||
+ | # Also check the settings for the location of 'wget' and 'cat' on your host (hint: '''whereis wget''' and '''whereis cut''' will help). | ||
+ | # Set the '''$DEBUG''' variable to '''1''' to see copious debugging message the first time through (you can set it to '''0''' later, when you're sure everything is working okay). | ||
+ | # <code>php ./dataimport/PEICivicAddressDataImport.php</code> | ||
+ | |||
+ | If everything worked okay, you should see debugging messages, finishing with ''Total of X addresses now in the table.'' where X is in the range of 65,000 addresses. | ||
+ | |||
+ | ==Reference Materials== | ||
* [http://www.gov.pe.ca/photos/original/civicaddress.pdf Prince Edward Island Civic Address Standards and Guidelines] | * [http://www.gov.pe.ca/photos/original/civicaddress.pdf Prince Edward Island Civic Address Standards and Guidelines] |
Revision as of 20:46, 7 November 2005
Contents
About the Civic Address System
In recent years, Prince Edward Island has moved to a uniform system of civic addresses, where each property in the province is assigned a unique civic address. Originally intended to enable the 911 emergency system, the civic addressing system, because it ties civic address data to latitude and longitude geolocation information, has tremendous utility for other applications.
The province's Address Locator page links to several web-based applications for looking up civic addresses. In addition, raw civic data is available from a form-based data download page.
Documented here is a PHP script that enables the automatic creation of a MySQL database and download and import of current civic address data. The system was created to enable the PEI Civic Address Lookup with AJAX application, but can be used to drive any application that relies upon having access to digital Prince Edward Island address information.
What the Script Does
The PHP script connects to the civic address data download page and grabs the latest data for the three counties of Prince Edward Island as tab-delimited ASCII text files. These are then concatenated into one large text file and imported into a MySQL table. If the table already exists, it is emptied before import; if the table doesn't exist, then it is created, along with associated indices.
System Requirements
The script was created on a Linux system, and has only been tested under Linux; it may work, with modifications, under other operating systems.
- MySQL
- PHP (you don't need a webserver, just the command-line PHP will do)
- GNU Wget (used to download the data)
Download or Browse the Source Code
The source code is kept in a Subversion repository:
- Browse the Repository
- Via HTTP: http://svn.reinvented.net/PEICivicAddressData
- Via SVN: svn://svn.reinvented.net/PEICivicAddressData
Install and Run
- Create a new database, or select an existing one, to hold the civic address data.
- Edit the file settings/PEICivicAddressData.inc, adding your MySQL username and password, and selecting the database name and table name for the civic address data (these default to 'civicaddress', so the assumption is that you have a database called 'civicaddress').
- Also check the settings for the location of 'wget' and 'cat' on your host (hint: whereis wget and whereis cut will help).
- Set the $DEBUG variable to 1 to see copious debugging message the first time through (you can set it to 0 later, when you're sure everything is working okay).
-
php ./dataimport/PEICivicAddressDataImport.php
If everything worked okay, you should see debugging messages, finishing with Total of X addresses now in the table. where X is in the range of 65,000 addresses.