Search code examples
pythonparsingarcgisshapefile

How to parse a .shp file?


I am interested in gleaning information from an ESRI .shp file. Specifically the .shp file of a polyline feature class.

When I open the .dbf of a feature class, I get what I would expect: a table that can open in excel and contains the information from the feature class' table.

However, when I try to open a .shp file in any program (excel, textpad, etc...) all I get is a bunch of gibberish and unusual ASCII characters.

I would like to use Python (2.x) to interpret this file and get information out of it (in this case the vertices of the polyline).

I do not want to use any modules or non built-in tools, as I am genuinely interested in how this process would work and I don't want any dependencies.

Thank you for any hints or points in the right direction you can give!


Solution

  • Your question, basically, is "I have a file full of data stored in an arbitrary binary format. How can I use python to read such a file?"

    The answer is, this link contains a description of the format of the file. Write a dissector based on the technical specification.