Making a Charlottetown Zoning Lookup

Peter Rukavina

Since receiving a copy of the City of Charlottetown Zoning Map in digital form (as an ESRI shapefile), I’ve been thinking of various ways of using the data. An obvious one is to build a tool that allows a civic address to be entered and the current zoning designation to be returned; there’s no online tool that supports this sort of lookup right now (there’s this tool on the city’s website; it’s not pretty or particularly intuitive, but it will return the information), and, partly as a result, I think most city residents are ignorant of the zoning of their own property and those around them.

I decided that I wanted to build this as a standalone browser-based tool, which meant nothing on the server side (MySQL, PHP) would be required, and the tool wouldn’t need to rely on a data connection to be used, making it more suitable for mobile use. Here’s how I did it.

Convert the dBASE Database

The attribute data for ESRI shapefiles is stored in a dBASE-format database. To get this data out I needed a tool that would dump data out of dBASE files and into plain ASCII, and shapelib fit the bill. I downloaded the latest source code and then simply:

unzip shapelib-1.3.0.zip
cd shapelib-1.3.0
make
make install

With this done, I could now use the dbfdump utility to convert the dBASE file:

wget https://github.com/reinvented/charlottetown-zoning/blob/master/shapefiles/City_Zoning_Apr-2012.dbf?raw=true -O City_Zoning_Apr-2012.dbf
dbfdump City_Zoning_Apr-2012.dbf > City_Zoning_Apr-2012.txt

I now had a fixed-width ASCII file that looked like this:

               PID        AREA_1   PERIMETER ZONING
134114.00000000000 1882636.72500 11146.96717 A
386524.00000000000  767652.65500  4243.97634 CDA
386128.00000000000  549478.99625  4015.56484 OS

Get the Civic Address Data

For the civic address data I was able to leverage some work I did many years ago that automates the download of the civic address data from the Province of PEI’s website, giving me a companion ASCII file, also containing the PID number, which I could then use to merge with the zoning information.

Merging Zoning with Civic Address

To ease the merging of the civic address and zoning data, I dump both datasets into SQLite3 tables; I chose SQLite3 because it’s pre-installed on my Mac and easily available otherwise.

Rolling all of the above and this together, I ended up with a PHP script to download and convert the civic address and zoning data, merge it together based on PID, and dump out the result to a JavaScript file. This JavaScript file looks like this:

var zoning = [{"pid":134023,
               "area":8038.86596,
               "perimeter":960.3898,
               "zoning":"OS",
               "street_no":489,
               "street_nm":"BRACKLEY POINT RD - RTE 15",
               "comm_nm":"BRACKLEY",
               "apt_no":"",
               "county":"QUN",
               "latitude":46.29746,
               "longitude":-63.14203,
               "unique_id":5712716,
               "census":1102048},...

For each zoning designation that matches a civic address (there are 942 that don’t) this newly-defined zoning object holds information about the PID, the civic address and the zoning.

Making it Searchable

There are plenty of ways of searching through a JavaScript object; I opted for jSQL, a JavaScript library that offers some SQL-like features, allowing me to search for addresses in my zoning object as simply as this:

var db = new jSQL();
db.create('zoning',zoning).use('zoning');
db.select('*').where(function(o) {
    return (o.street_no == 222)
});
var data = db.listAll();

Which returns all of the addresses where the street number is 222.

I wrapped this all into a single HTML file (you can try the search out here at this live demo) that looks like this:

Add new comment

Plain text

  • Allowed HTML tags: <b> <i> <em> <strong> <blockquote> <code> <ul> <ol> <li>
  • Lines and paragraphs break automatically.

About This Blog

Photo of Peter RukavinaI am . I am a writer, letterpress printer, and a curious person.

To learn more about me, read my /nowlook at my bio, read presentations and speeches I’ve written, or get in touch (peter@rukavina.net is the quickest way). You can subscribe to an RSS feed of posts, an RSS feed of comments, or receive a daily digests of posts by email.

Search