Jim,
Your algorithm is spot on and I would definitely filter with the
bounding box first. Beyond that you would have to get into spatial
indexing <
http://www.pygame.org/wiki/QuadTree> which is sufficiently
complex enough that I haven't played with it yet in pure Python.
As for you ID question... The FIDs are just an illusion by ArcGIS
(and other packages) for convenience. The shapefile format doesn't
support any sort of id or numbering. The indexes (i.e. shape[n]) are
implied by the order they appear in the shapefile. When you open a
shapefile in ArcGIS and open the attribute records, the FIDs are not
persistent. If you delete a record, say #7, the attribute table will
jump from 6 to 8. But if you close that shapefile and reopen it in
ArcGIS, former record #8 will now be #7 the same as if you delete a
row in Excel. The ids are not persistent. If you are using ArcSDE or
PostGIS the database may insert persistent object ids but that is a
feature of the database and not the data format.
At NVision <
nvs-inc.com> we will often add our own permanent ID column
to a shapefile and autonumber it so that the ID will be persistent if
you need unique tags for records.
Good luck and let us know if we can be of further assistance.
- Joel