PostGIS scripts to do spatial analysis