adang1345 / delvewheel

Self-contained Python wheels for Windows
MIT License
123 stars 12 forks source link

Bug #7

Closed asfixia closed 3 years ago

asfixia commented 3 years ago

There's a bug when reads the following docstring in init.py: ( Fiona 1.8.6 library )

""" Fiona is OGR's neat, nimble, no-nonsense API.

Fiona provides a minimal, uncomplicated Python interface to the open source GIS community's most trusted geodata access library and integrates readily with other Python GIS packages such as pyproj, Rtree and Shapely.

How minimal? Fiona can read features as mappings from shapefiles or other GIS vector formats and write mappings as features to files using the same formats. That's all. There aren't any feature or geometry classes. Features and their geometries are just data.

A Fiona feature is a Python mapping inspired by the GeoJSON format. It has id, 'geometry, andpropertieskeys. The value ofidis a string identifier unique within the feature's parent collection. The geometryis another mapping withtypeandcoordinateskeys. The properties` of a feature is another mapping corresponding to its attribute table. For example:

{'id': '1', 'geometry': {'type': 'Point', 'coordinates': (0.0, 0.0)}, 'properties': {'label': u'Null Island'} }

is a Fiona feature with a point geometry and one property.

Features are read and written using objects returned by the collection function. These Collection objects are a lot like Python file objects. A Collection opened in reading mode serves as an iterator over features. One opened in a writing mode provides a write method.

Usage

Here's an example of reading a select few polygon features from a shapefile and for each, picking off the first vertex of the exterior ring of the polygon and using that as the point geometry for a new feature writing to a "points.shp" file.

import fiona with fiona.open('docs/data/test_uk.shp', 'r') as inp: ... output_schema = inp.schema.copy() ... output_schema['geometry'] = 'Point' ... with collection( ... "points.shp", "w", ... crs=inp.crs, ... driver="ESRI Shapefile", ... schema=output_schema ... ) as out: ... for f in inp.filter( ... bbox=(-5.0, 55.0, 0.0, 60.0) ... ): ... value = f['geometry']['coordinates'][0][0] ... f['geometry'] = { ... 'type': 'Point', 'coordinates': value} ... out.write(f)

Because Fiona collections are context managers, they are closed and (in writing modes) flush contents to disk when their with blocks end. """