Learning Geospatial Analysis with Python by 2013

Learning Geospatial Analysis with Python by 2013

Author:2013
Language: eng
Format: epub
Publisher: Packt Publishing


This example is quite simple but OGR can become quite verbose as your script becomes more complex.

PyShp

PyShp is a simple, pure Python library that reads and writes shapefiles. It doesn't do any geometry operations and only uses Python's standard library. It's contained in a single file that's easy to move around, squeeze onto small embedded platforms, and modify. It is also compatible with Python 3. It also implements __geo_interface__. The PyShp module is available on PyPI.

Let's repeat the previous OGR example with PyShp:

>>> import shapefile >>> shp = shapefile.Reader("point") >>> for feature in shp.shapeRecords(): ... point = feature.shape.points[0] ... rec = feature.record[0] ... print point[0], point[1], rec ... 1.0 1.0 First 3.0 1.0 Second 4.0 3.0 Third 2.0 2.0 Fourth 0.0 0.0 Appended



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.