Well, I got my test up and running and it was fairly quick to do, once I decided to go with OGR/OSGEO. Here are some reference materials on OGR that I bookmarked in case anyone finds it helpful:
Quick Tutorial: http://invisibleroads.com/tutorials/gdal-shapefile-points-load.html
Helpful Documentation: http://gdal.org/python/
Gotchas: http://trac.osgeo.org/gdal/wiki/PythonGotchas
And here is my little bottle webservice test:
import bottle
import json, os, osgeo, ogr
from bottle import route
@route('/')
def index():
""" Display welcome & instruction messages """
return "<p>Welcome to my simple spatial bottle.py powered web service !</p> \
<p>How to invoke the web service? Just pass lat/long pairs to create a route, as below. \
The webservice will buffer the line then intersect it with my point file, and you will \
get a summary of total points per type in json format:\
<ul><li>http://mbruce.pythonanywhere.com/buffer?s=LINESTRING(-76.615 39.417,-76.642 39.478,-76.627 39.444)</li>\
</ul>"
@route('/buffer')
def buffer():
# Store HTTP GET arguments
googleroute = bottle.request.GET.get('s' , default=None)
# Execute WebService specific task
# create lineshape
route = ogr.CreateGeometryFromWkt(googleroute)
buff = route.Buffer(0.0025, 30)
#open the source file, create a lyer for OGR to use
input = '/home/mbruce/mysite/TestPointData_WGS84.shp'
shapeData = osgeo.ogr.Open(input)
layer = shapeData.GetLayer()
#set filters. This filter will only intersect the bounding box.
#to get more granular you have to check intersection on each
#feature
layer.SetSpatialFilter(buff) # set buffer polygon as spatial filter
#this loop creates an attribute filter for each distinct type, and
#returns an array of the count of records for each distinct type
count = 1
list = []
while (count < 6):
layer.SetAttributeFilter("ACCIDENT_S = '0" + str(count) + "'")
x = layer.GetFeatureCount()
list.append(x)
count = count + 1
# Sending back json
return json.dumps(
{
'result': list
},
indent=4)
application = bottle.default_app()