- Import data into PostGIS
- Create GIS servlet
- Draw the data on google maps
- Query PostGIS for google's lat/long
- Select Properties from the map
Prepare PostGIS
I'm running Ubuntu 11.04, PostgreSQL 8.4 with postGIS 1.5.1 installed from the default software repo.
psql (8.4.8) Type "help" for help. postgres=# create database propertymap; CREATE DATABASE postgres=# \q ~$ createlang plpgsql propertymap; ~$ cd /usr/share/postgresql/8.4/contrib/postgis-1.5/ postgis-1.5$ psql -f postgis.sql propertymap postgis-1.5$ psql -f ../postgis_comments.sql propertymap; postgis-1.5$ psql -f spatial_ref_sys.sql propertymap;Convert Shapefile
Create a ton of insert statements using shp2pgsql:
poly$ shp2pgsql -s 926985 OwnerPly.shp ownertable > inserts.sql Shapefile type: Polygon Postgis type: MULTIPOLYGON[2]If we look at the .prj file included, we see that the projection for the data is NAD_1983_StatePlane_Maryland_FIPS_1900. We need to add the projection from spatialreference.org in to our database
propertymap=# INSERT into spatial_ref_sys (srid, auth_name, .......66666666],UNIT["Meter",1.0]]'); INSERT 0 1 propertymap=# \i inserts.sqlRun your first query
propertymap=# select ownername,square,lot,premiseadd from ownertable where premiseadd like '%1600 PENNSYLVANIA%'; ownername | square | lot | premiseadd --------------------------+--------+------+------------------------- UNITED STATES OF AMERICA | 0187 | 0800 | 1600 PENNSYLVANIA AV NW UNITED STATES OF AMERICA | 0187 | 0802 | 1600 PENNSYLVANIA AV NW UNITED STATES OF AMERICA | 0187 | 0801 | 1600 PENNSYLVANIA AV NWFirst, a little background on what we asked for. DC property records are based on square, suffix, and lot. Square generally refers to a city block and goes all the way back to the original city planning in the old part of the city. Lot is a lot within a square/suffix. For the most part, you can ignore suffix as it's rarely used. Next time, create a simple servlet to expose all of this.