GeoScript

Previous topic

feature

Next topic

Field

This Page

Schema

class geoscript.feature.Schema

Describes the structure of a feature. A schema is composed of a name, and a set of fields each containing a name and a type.

name is a str.

fields is a list of (str, type) tuples.

>>> from geoscript import geom
>>> schema = Schema('widgets', [ ('geom', geom.Point), ('name', str), ('price', float) ])
>>> schema
widgets [geom: Point, name: str, price: float]
feature(vals, id=None)

Creates a feature of the schema from a dict of values values.

vals is a dict in which keys are attribute names, and values are attribute values.

id is an optional feature identifier as a str.

>>> s = Schema('widgets', [('name', str), ('price', float) ])
>>> f = s.feature({'name': 'anvil', 'price': 100.0}, '1')
>>> f 
widgets.1 {name: anvil, price: 100.0}
field(*args, **kwargs)

Use get().

geom

The geometry Field of the schema. Returns None in the event the schema does not contain any geometric attributes

name

The name of the schema. A schema name is usually descriptive of the type of feature being described, for example “roads”, “streams”, “persons”, etc...

uri

The namespace uri of the schema. A schema namespace uri qualifies the schema name, usually used for purposes of encoding GML.