So things were going faster than expected. I installed PostGIS, then in the source directory fount a tool called shp2pgsql. Using the command
shp2pgsql -w -g geom tr36_d00 cshape >
tr36_d00.pgresimport
I turned the shapefiles into batch files that are executable by PostgreSQL. The -w turns the format into wkt format (well-known-text), which I just liked because it was readable. I had trouble with settings, and fudged around this area for a while.
I then created the standard OpenGIS tables as dictated in this page: the SPATIAL_REF_SYS and GEOMETRY_COLUMNS tables. It seems that they're mandatory. I then imported the file that I had previously created:
psql -Upostgres -d census_shapes -f tr36_d00.pgresimport
postgres is the user, census_shapes is the database, and tr36_d00.pgresimport is the import file. This worked, and all the entries started importing! Hurrah. After that, I tried querying:
select AsText(geom) from cshape limit 1;And I got an output that looked like:
MULTIPOLYGON(((-74.922368 44.960301,-74.917243 44.963743,-74.902403 44.947712,-74.901045 44.94551,-74.90028 44.944099,-74.898672 44.941034,-74.898415 44.940851,-74.898125 44.940097,-74.894169 44.935157,-74.893477 44.93416,-74.893223 44.933621,-74.89314 44.933076,-74.89314 44.932367,-74.890155 44.921848,-74.888541 44.916816,-74.887571 44.91426,-74.885153 44.911527,-74.88254 44.908058,-74.881842 44.898385,-74.886792 44.904059,-74.888457 44.905923,-74.892535 44.910287,-74.895901 44.913879,-74.89628 44.914283,-74.900616 44.918999,-74.90068 44.919068,-74.908067 44.926972,-74.908321 44.927241,-74.911828 44.930953,-74.912202 44.931349,-74.914032 44.933287,-74.919177 44.938664,-74.919808 44.939322,-74.920282 44.939845,-74.922369 44.942046,-74.924504 44.944292,-74.930209 44.950191,-74.931129 44.951419,-74.932078 44.95242,-74.934773 44.955263,-74.924425 44.959972,-74.922368 44.960301)))Great! And now for the final test: the query that I ran earlier on MySQL and didn't work --
SELECT t.TRACT
FROM cshape t
WHERE Contains(t.geom, GeomFromText('Point(-73.963956 40.808502)')) = 1;
And I get:
ERROR: contains:: operation not implemented - compile PostGIS with JTS or GEOS support
Uhh, what?
It turns out that I didn't have GEOS support compiled. GEOS (Geometry Engine Open Source) is a C/C++ port of the JTS (JTS Topological Suite), which handles topological calculations with polygons/lines/etc, spatial analysis, etc. Of course, this means that JTS and GEOS provide the capability to answer my crucial question: "Is point X inside shape Y"?
So -- I downloaded the newest version of GEOS, and am compiling it now. I believe (according to this page) that I need to recompile PostGIS by using the options:
LDFLAGS=-lstdc++
./configure --with-geos=PATH
I'm soo close.
update:
I finally fixed it here: success.