Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shapefile reader in Python?

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.

like image 517
Zameer Manji Avatar asked Dec 05 '10 05:12

Zameer Manji


People also ask

How do I read a shapefile in Python?

To import shapefiles you use the geopandas function read_file() . Notice that you call the read_file() function using gpd. read_file() to tell python to look for the function within the geopandas library. The CRS UTM zone 18N.

How do I read a shapefile?

Once on your local disk, double click the zipped file and extract the shape files using your own unzipping utility. To View: After downloading, the shapefiles can be read using ArcGIS and ArcGIS Explorer. The zipped shapefiles can also be added directly into ArcGIS Online.

How do I use PyShp?

Using PyShp create a Reader object to access the data from the Ireland_LA Shapefile. Create a Writer object to write data to as a new Shapefile. Set variables for access to the field information of both the original and new Shapefile. We will grab all the field info from the original and copy it into the new.

What is PyShp?

The Python Shapefile Library (PyShp) provides read and write support for the Esri Shapefile format. The Shapefile format is a popular Geographic Information System vector data format created by Esri.

How do I read a shapefile in Python?

Reading Shapefiles. To read a shapefile create a new "Reader" object and pass it the name of an existing shapefile. The shapefile format is acutally a collection of three files. You specify the base filename of the shapefile or the complete filename of any of the shapefile component files.

What is the default encoding for shapefiles in Python?

Most shapefiles are written in UTF-8 encoding, PyShp's default encoding, so in most cases you don't have to specify the encoding. For reading shapefiles in any other encoding, such as Latin-1, just supply the encoding option when creating the Reader class.

How many code examples are there for shapefile reader?

The following are 30 code examples for showing how to use shapefile.Reader () . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

How to import shapefile in pyshp?

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. Show activity on this post.


2 Answers

The pyshp library should be good.

like image 187
user225312 Avatar answered Sep 22 '22 16:09

user225312


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.

like image 34
GeospatialPython Avatar answered Sep 19 '22 16:09

GeospatialPython