Reading shapefile attributes

The .dbf file is a simple database format that is structured in a similar way to a spreadsheet with rows and columns, with each column as a label defining what information it contains. We can view that information by checking the fields property of the Reader object:

r.fields # [('DeletionFlag', 'C', 1, 0), ['STATEFP10', 'C', 2, 0],  ['PLACEFP10', 'C', 5, 0], # ['PLACENS10', 'C', 8, 0], ['GEOID10', 'C', 7, 0], ['NAME10', 'C',  100, 0], # ['NAMELSAD10', 'C', 100, 0], ['LSAD10', 'C', 2, 0], ['CLASSFP10',  'C', 2, 0], # ['PCICBSA10', 'C', 1, 0], ['PCINECTA10', 'C', 1, 0], ['MTFCC10',  'C', 5, 0], # ['FUNCSTAT10', 'C', 1, 0], ['ALAND10', 'N', 14, 0], ['AWATER10',  'N', 14,0], # ['INTPTLAT10', 'C', 11, 0], ['INTPTLON10', ...

Get Learning Geospatial Analysis with Python - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.