[Shapelib] Verifying shapefile contents

Mateusz Loskot mateusz at loskot.net
Wed Aug 30 12:21:19 PDT 2006


Eron Lloyd wrote:
> Hello!
> 
> I'm doing some prelimenary analysis for a land value tax in Reading, PA, and 
> am currently reviewing the property assessment rolls. Unfortunately, like 
> many voter lists, I've discovered hundreds of records with invalid data; in 
> this case, many records aren't listed as being part of the municipality but 
> are, or even the reverse, where land outside the city's border is listed as 
> part of the city. I have the city's shapefile, which provides all the parcel 
> data, and I was wondering if it would be possible to use shapelib to
> 
> 1. process the entire list of map pins (each a unique # that identifies a 
> parcel in the shapefile, such as 530764436089)

I'm not sure what you mean as 'process', but if it means you
want to visit every shape feature (geometry + attributes) then
yes, it's feasible with Shapelib.

1. Open shapefile
2. Read shapefile info (number of features, etc.)
3. Iterate through features in shapefile
4. For every feature apply your 'processing'
5. Close shapefile

> 2. verify that each parcel is within the city's taxable jurisdiction (i.e. 
> boundary lines) or not (even testing for partial inclusion)

Is parcel a point or polygon?
You can implement point in polygon algorithm or use available
implementation (somewhere, e.g. GEOS).

> 3. manipulate the shapefile to represent visually any invalid, 
> unaccounted-for, or otherwise incorrectly designated parcels

I am not sure what you mean here, but generally you can do whatever you
want with shape objects. Shapelib enables you to access geometry and
attributes, then you can do your calculations/visualization, etc.

> I assume the GIS dept. could perhaps help with this, but developing a personal 
> tool to do this would be useful and educational. My language of choice is 
> Python, and I'd be happy to share the code once I get it working. My basic 
> need is a guide to the API and suggestions for how to proceed. I can 
> translate the procedure calls into Python.

yes, Python should work well here.
Here is pyshapelib wrapper:
http://hobu.biz/software/pyshapelib/index_html
Look at the pytest.py file from this package and you will
know how to use it, it's simple.


Note, there is also OGR (http://www.gdal.org/ogr/), also with Python
wrapper available. Note, OGR includes shapelib as a Shapefile driver.

Cheers
-- 
Mateusz Loskot
http://mateusz.loskot.net



More information about the Shapelib mailing list