class Layer extends java.lang.Object implements Renderable
A Layer is a source of spatial data that contains a collection of Features. Most often Layers are accessed from a Workspace but you can create an in memory Layer by simply passing a name and a Schema:
Schema schema = new Schema("facilities", [new Field("geom","Point", "EPSG:2927"), new Field("name","string"), new Field("address","string")])
Layer layer = new Layer("facilities", schema)
If, all you want to store in a Layer is Geometry, you can just pass a layer name:
Layer layer = new Layer("points")
layer.add([new Point(0,0)])
layer.add([new Point(1,1)])
| Modifiers | Name | Description |
|---|---|---|
protected static FilterFactory2 |
filterFactory |
The FilterFactory2 for creating Filters |
| Constructor and description |
|---|
Layer
(FeatureSource<SimpleFeatureType, SimpleFeature> fs)Create a new Layer from a GeoTools FeatureSource |
Layer
(Layer layer)Create a new Layer from an existing Layer |
Layer
(java.lang.String name, Workspace workspace, FeatureSource<SimpleFeatureType, SimpleFeature> fs, Schema schema)Create a new Layer from a name, Workspace, FeatureSource, and Schema |
Layer
(Workspace workspace, FeatureSource<SimpleFeatureType, SimpleFeature> fs)Create a new Layer from a Workspace and FeatureSource |
Layer
(java.lang.String name, Workspace workspace)Create a new Layer from a name and Workspace |
Layer
(java.lang.String name, Schema schema)Create a new Layer with a name in the Memory Workspace |
Layer
()Create a new Layer with a default name, Schema in the Memory Workspace |
Layer
(java.lang.String name)Create a new Layer with the given name, a simple Schema with just a Geometry Field in the Memory Workspace |
Layer
(FeatureCollection fc)Create a new Layer from a GeoTools FeatureCollection. |
Layer
(java.lang.String name, FeatureCollection fc)Create a new Layer from a GeoTools FeatureCollection |
| Type Params | Return Type | Name and description |
|---|---|---|
|
void |
add(java.lang.Object o)Add a Feature to the Layer |
|
Bounds |
bounds(java.lang.Object filter)Get the Bounds of the Features in the Layer |
|
Bounds |
bounds(Map options)Get the Bounds of Layer using named parameters |
|
Layer |
buffer(Map options, double distance)Buffer all of the Features in the this Layer. |
|
Layer |
buffer(Map options, Expression distance)Buffer all of the Features in the this Layer. |
|
Layer |
clip(Map options, Layer clipLayer)Clip this Layer by another Layer. |
|
java.util.List |
collectFromFeature(java.lang.Object filter, groovy.lang.Closure closure)Collect values from the Features of a Layer |
|
java.util.List |
collectFromFeature(Map options, groovy.lang.Closure closure)Collect values from the Features of a Layer |
|
int |
count(java.lang.Object filter)Count the number of Features in the layer |
|
int |
count(Map options)Count the number of Features using named parameters |
|
void |
delete(java.lang.Object filter)Delete Features from the Layer |
|
Layer |
dissolve(Map options, Field field)Dissolve the Features of a Layer by a Field. |
|
Layer |
dissolve(Map options)Dissolve intersecting Features of a Layer. |
|
void |
eachFeature(java.lang.Object filter, groovy.lang.Closure closure)Call the Closure for each Feature optionally filtered by the Filter |
|
void |
eachFeature(Map options, groovy.lang.Closure closure)Call the Closure for each Feature. |
|
Layer |
erase(Map options, Layer layer2)Erase this Layer with another Layer. |
|
Layer |
filter(java.lang.Object filter, java.lang.String newName)Filer the Layer. |
|
Feature |
first(Map options)Get the first Feature that matches |
|
static Layer |
fromGeometries(Map options, java.lang.String name, java.util.List<Geometry> geometries)Create a Layer from a List of Geometries |
|
static Layer |
fromGeometry(Map options, java.lang.String name, Geometry geometry)Create a Layer from a Geometry |
|
Bounds |
getBounds()Get the Bounds of the Features in the Layer |
|
int |
getCount()Count the number of Features in the layer |
|
Cursor |
getCursor(Map options)Get a Cursor over the Features of the Layer using named parameters. |
|
Cursor |
getCursor(java.lang.Object filter, java.util.List sort, int max, int start, java.util.List fields, java.lang.Object sourceProj, java.lang.Object destProj, java.lang.Object params)Get a Cursor over the Features of the Layer. |
|
java.util.List<Feature> |
getFeatures(java.lang.Object filter, groovy.lang.Closure transform, java.util.List sort, Map params)Get a List of Features |
|
java.util.List<Feature> |
getFeatures(Map options)Get a List of Features |
|
java.lang.String |
getFormat()Get the Workspace format |
|
java.util.List |
getMapLayers(Bounds bounds, java.util.List size)Get the map layers @return |
|
java.lang.String |
getName()Get the Layer's name |
|
Projection |
getProj()Get the Layer's Projection |
|
Raster |
getRaster(java.lang.Object field, java.util.List gridSize, Bounds bounds, java.lang.String rasterName)Convert this Layer into a Raster |
|
Writer |
getWriter(Map options)Get a Writer for this Layer |
|
java.util.List |
histogram(java.lang.Object field, int classes)Calculate a histogram of values for an attribute of the Layer. |
|
Layer |
identity(Map options, Layer layer2)Calculate the identity between this Layer and another Layer. |
|
java.util.List |
interpolate(java.lang.Object field, int classes, java.lang.String method)Create a List of interpolated values for a Field |
|
Layer |
intersection(Map options, Layer layer2)Intersect this Layer with another Layer. |
|
Layer |
merge(Map options, Layer otherLayer)Merge this Layer with another Layer to create an output Layer |
|
Map |
minmax(java.lang.Object field, java.lang.Object low, java.lang.Object high)Calculates the minimum and maximum values for an attribute of the Layer. |
|
static java.lang.String |
newname()Generate a new name |
|
void |
plus(java.lang.Object o)Add a Feature to the Layer |
|
void |
queueModified(Feature feature, java.lang.String name)Add the Feature to a List of modified Features |
|
protected FeatureCollection |
readFeatures(Cursor cursor, Schema schema, int chunk)Read Features from a Cursor in Batches. |
|
Layer |
reproject(Projection p, java.lang.String newName, int chunk, Projection sourceProjection)Reproject the Layer |
|
Layer |
reproject(Projection p, Workspace outputWorkspace, java.lang.String newName, int chunk, Projection sourceProjection)Reproject the Layer to another Layer in the given Workspace |
|
Layer |
reproject(Layer projectedLayer, int chunk, Projection sourceProjection)Reproject this Layer to another Layer that already exists. |
|
protected double |
round2(double num) |
|
protected void |
setDefaultSymbolizer(java.lang.String geometryType)Set the default Symbolizer based on the geometry type |
|
void |
setProj(java.lang.Object value)Set the Layer's Projection. |
|
void |
split(Field field, Workspace workspace)Split this Layer into sub Layers based on values taken from the Field. |
|
void |
split(Layer splitLayer, Field field, Workspace workspace)Split this Layer into multiple Layers based on the Features from the split Layer. |
|
Layer |
symDifference(Map options, Layer layer2)Calculate the symmetric difference between this Layer and another Layer. |
|
java.lang.String |
toString()The string representation |
|
Layer |
transform(java.lang.String name, Map definitions)Transform this Layer into a Layer with a new name using a Map of definitions. |
|
Layer |
union(Map options, Layer layer2)Union this Layer with another Layer. |
|
void |
update(Field fld, java.lang.Object value, java.lang.Object filter, boolean isScript)Update the values of a Field |
|
void |
update()Update all modified Features whose values where changed with the Feature.set(field,value) method. |
|
Layer |
update(Map options, Layer layer2)Calculate the update between this Layer and another Layer. |
|
void |
withWriter(Map options, groovy.lang.Closure c)Add Features to a Writer within a Closure that takes a Writer ready to adding Features. |
| Methods inherited from class | Name |
|---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
The FilterFactory2 for creating Filters
The GeoTools FeatureSource
The name
The Schema
The Style
The Workspace
Create a new Layer from a GeoTools FeatureSource
fs - The GeoTools FeatureSourceCreate a new Layer from an existing Layer
layer - Another LayerCreate a new Layer from a name, Workspace, FeatureSource, and Schema
name - The Layer's nameworkspace - The Workspacefs - The GeoTools FeatureSourceschema - The GeoScript SchemaCreate a new Layer from a Workspace and FeatureSource
workspace - The Workspacefs - The GeoTools FeatureSourceCreate a new Layer from a name and Workspace
name - The Layer's nameworkspace - The WorkspaceCreate a new Layer with a name in the Memory Workspace
name - The Layer's nameschema - The SchemaCreate a new Layer with a default name, Schema in the Memory Workspace
Create a new Layer with the given name, a simple Schema with just a Geometry Field in the Memory Workspace
Create a new Layer from a GeoTools FeatureCollection.
fc - The GeoTools FeatureCollectionCreate a new Layer from a GeoTools FeatureCollection
name - The name of the new Layerfc - The GeoTools FeatureCollectionAdd a Feature to the Layer
o - The Feature, the List of Features, or a List/Map of valuesGet the Bounds of the Features in the Layer
filer - The Filter or Filter String to limit the Features used to construct the bounds. Defaults to null.Get the Bounds of Layer using named parameters
options - The named parameters
Buffer all of the Features in the this Layer.
options - The Map of options which can include outWorkspace and outLayer
distance - The buffer distanceBuffer all of the Features in the this Layer.
options - The Map of options which can include outWorkspace and outLayer
distance - An Expression that represents the buffer distance (can be a Literal, Function, or Property)Clip this Layer by another Layer.
options - Named parameters
clipLayer - The clip LayerCollect values from the Features of a Layer
filter - The Filter which is optionalclosure - A Closure which takes a Feature and returns a valueCollect values from the Features of a Layer @return
options - The named parameters
* closure - The Closure which takes a Feature and returns a valueCount the number of Features in the layer
filer - The Filter or Filter String to limit the number of Features counted. Defaults to null.Count the number of Features using named parameters
options - The named parameters
Delete Features from the Layer
filer - The Filter or Filter String to limit the Features to delete. Defaults to null.Dissolve the Features of a Layer by a Field.
options - A Map of options that can include outLayer, outWorkspace, idFieldName, and countFieldNamelayer - The input Layerfield - The FieldDissolve intersecting Features of a Layer.
options - A Map of options that can include outLayer, outWorkspace, idFieldName, and countFieldName
layer - The input Layerfield - The FieldCall the Closure for each Feature optionally filtered by the Filter
filter - The Filter which is optionalclosure - A Closure which takes a FeatureCall the Closure for each Feature.
options - The named parameters
* closure - The Closure which takes a FeatureErase this Layer with another Layer.
options - Named parameters
layer2 - The second LayerFiler the Layer.
filter - A Filter or Filter String used to limit the number of Features returned in the new LayernewName - The name of the new Layer (defaults to a default new name)Get the first Feature that matches @return
options - Named parameters
Create a Layer from a List of Geometries
options - Optional named parameters:
name - The name of the new Layergeometries - The List of GeometriesCreate a Layer from a Geometry
options - Optional named parameters:
name - The name of the new Layergeometry - The GeometryGet the Bounds of the Features in the Layer
Count the number of Features in the layer
Get a Cursor over the Features of the Layer using named parameters.
options. - The Map of named parameters can include:
Get a Cursor over the Features of the Layer.
filter - The Filter or Filter String to limit the Features. Defaults to null.sort - A List of Lists [[Field or Field name, "ASC" or "DESC"],...] or a List of Strings ["name DESC", "price ASC"]
that define the sort order. Not all Layers support sorting!max - The maximum number of Features to include in the Cursorstart - The zero based index of the record to start the cursor at. Together with maxFeatures this simulates paging.
Not all Layers support the start index and paging!fields - A List of Fields or Field names to include. Used to select only a subset of Fields.params - A Map of parameters to plug into the query.Get a List of Features
filer - The Filter or Filter String to limit the Features used to construct the bounds. Defaults to null.transform - The Closure used to modify the Features. Defaults to null.sort - A List of Lists that define the sort order [[Field or Field name, "ASC" or "DESC"],...]. Not all Layers
support sorting!params - A Map of parameters to plug into the query.Get a List of Features
options - The named parameters
Get the Workspace format
Get the map layers @return
Get the Layer's name
Get the Layer's Projection
Convert this Layer into a Raster
field - The numeric Field or Field name from which to get valuesgridSize - The grid size (width and height)bounds - The Bounds of the Rastername - The name of the RasterGet a Writer for this Layer
options - The named parameters
Calculate a histogram of values for an attribute of the Layer.
field - The Field or field nameclasses - The number of classesCalculate the identity between this Layer and another Layer.
options - Named parameters
layer2 - The second LayerCreate a List of interpolated values for a Field
field - The Field of Field nameclasses - The number of classesmethod - The interpolation method: linear, exp(onential), log(arithmic)Intersect this Layer with another Layer.
options - Named parameters
layer2 - The second LayerMerge this Layer with another Layer to create an output Layer
options - A Map of options that can include outLayer or outWorkspace
otherLayer - The other layerCalculates the minimum and maximum values for an attribute of the Layer.
field - The Fieldlow - The low/minimum valuehigh - The high/maximum valueGenerate a new name
Add a Feature to the Layer
o - The Feature or List/Map of valuesAdd the Feature to a List of modified Features
feature - The modified Featurename - The modified field name.Read Features from a Cursor in Batches.
cursor - The Cursorschema - The output Schemachunk - The number of Features to be readReproject the Layer
p - The ProjectionnewName - The new name (defaults to a default new name)chunk - The number of Features to reproject in one batchsourceProjection - The optional default source Projection if the Layer doesn't have a Projection definedReproject the Layer to another Layer in the given Workspace
p - The ProjectionoutputWorkspace - The output WorkspacenewName - The name of the new Layerchunk - The number of Features to reproject in one batchsourceProjection - The optional default source Projection if the Layer doesn't have a Projection definedReproject this Layer to another Layer that already exists.
projectedLayer - The already created projected Layerchunk - The number of Features to reproject in one batchsourceProjection - The optional default source Projection if the Layer doesn't have a Projection definedSet the default Symbolizer based on the geometry type
geometryType - The geometry typeSet the Layer's Projection.
value - The value can either be a Projection or a StringSplit this Layer into sub Layers based on values taken from the Field. The new Layers are created in the given Workspace.
field - The Field that contains the values that will be used to split the Layerworkspace - The Workspace where the new Layers will be createdSplit this Layer into multiple Layers based on the Features from the split Layer.
splitLayer - The split Layer whose Features are used to split this Layer into multiple Layersfield - The Field from the split Layer used to name the new Layersworkspace - The Workspace where the new Layers are createdCalculate the symmetric difference between this Layer and another Layer.
options - Named parameters
layer2 - The second LayerThe string representation
Transform this Layer into a Layer with a new name using a Map of definitions.
name - The new namedefinitions - A Map of Definitions (key=Field name, value=Expression)Union this Layer with another Layer.
options - Named parameters
layer2 - The second LayerUpdate the values of a Field
fld - The Field whose values will be updatedvalue - Either a static value, a Closure that takes
a Feature and return an Object, an Expression, or a Groovy Script (if isScript is true)filter - The Filter to limit the Features that will be updatedisScript - A flag for whether the value is a Groovy script or not (defaults to false).
If the value is a script, it can access the Feature as variable f and the counter as
variable c.Update all modified Features whose values where changed with the Feature.set(field,value) method.
Calculate the update between this Layer and another Layer.
options - Named parameters
layer2 - The second LayerAdd Features to a Writer within a Closure that takes a Writer ready to adding Features.
options - The named parameters
c - A Closure which takes one parameter, a WriterGroovy Documentation