The workspace.workspace module provides layer access and manipulation.
- class geoscript.workspace.workspace.Workspace(factory=None, params=None, ds=None)¶
A workspace is a container of layers.
- add(layer, name=None, chunk=1000)¶
Adds an existing layer to the workspace.
layer is the Layer to add.
name is the optional name as a str to assign to the layer when copied into the workspace.
>>> ws = Workspace() >>> ws.layers() [] >>> from geoscript.layer import Layer >>> l = Layer('foo') >>> l = ws.add(l) >>> ws.layers() ['foo']
- close()¶
Closes the workspace disposing of any resources being consumed. Generally this method should always be closed when the workspace is no longer needed.
- create(name=None, fields=[('geom', <type 'com.vividsolutions.jts.geom.Geometry'>, 'epsg:4326')], schema=None)¶
Creates a new Layer geoscript.layer.layer.Layer in the workspace.
name is the optional name to assign to the new layer.
fields is an optional list of str/type tuples which define th e schema of the new layer.
schema is the optional Schema of the new layer.
Note: When the schema argument is specified neither of name or fields should be specified.
>>> from geoscript import geom >>> ws = Workspace() >>> l1 = ws.create('foo', [('geom', geom.Point)]) >>> ws.layers() ['foo']>>> from geoscript.feature import Schema >>> l2 = ws.create(schema=Schema('bar', [('geom', geom.Point)])) >>> ws.layers() ['foo', 'bar']
- get(name)¶
Returns a Layer geoscript.layer.layer.Layer in the workspace. This method raised KeyError if the layer does not exist.
name is the name of a layer to return.
>>> ws = Workspace() >>> try: ... ws.get('foo') ... raise Exception('Should not get here') ... except KeyError: ... pass >>> x = ws.create('foo') >>> l = ws.get('foo') >>> str(l.name) 'foo'
- layers()¶
The names of all the layers in the workspace.
>>> ws = Workspace() >>> l1 = ws.create('foo') >>> l2 = ws.create('bar') >>> ws.layers() ['foo', 'bar']