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.
Answers:
The pyshp library should be good.
GDAL includes the OGR library which supports shapefile I/O. However, the installation process for this package in Windows is not very straightforward.
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.
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.
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/
The problem with the shapefile library is that the package not abled to access the details in the file
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.
The pyshp library should be good.
GDAL includes the OGR library which supports shapefile I/O. However, the installation process for this package in Windows is not very straightforward.
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.
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.
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/
The problem with the shapefile library is that the package not abled to access the details in the file