Shapefile reader in Python?

Question:

Are there any libraries that I can use to read a shp/shx/dbf/sbx set of files? I mainly need to extract some polygons but something that lets me extract any data that I want would be awesome.

Asked By: Zameer Manji

||

Answers:

The pyshp library should be good.

Answered By: user225312

GDAL includes the OGR library which supports shapefile I/O. However, the installation process for this package in Windows is not very straightforward.

Answered By: Jaime Soto

Also PySAL could be of some help. Reads shape files:

import pysal
shp = pysal.open('YOUR_FILE.shp')

And plenty of others geo related formats.

Answered By: radek

To use the Python Shapefile Library download shapefile.py:
http://code.google.com/p/pyshp/source/browse/trunk/shapefile.py

Place it in your working directory or in your Python site-packages directory and you are ready to go.

Just type “import shapefile” in your interpreter or python script and follow usage examples and documentation at the PyShp project on Google Code.

Answered By: GeospatialPython

Shapelib is also a good choice; it has c, c++, c# and python interface:
http://shapelib.maptools.org/

and pyshapelib here:
http://ftp.intevation.de/users/bh/pyshapelib/

Answered By: taijirobot

The problem with the shapefile library is that the package not abled to access the details in the file

Answered By: Richard Alphonse
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.