Process Feature Plugin

The gt-process-feature plugin gathers up a number of high quality processes for working with vector information.

Maven:

<dependency>
   <groupId>org.geotools</groupId>
   <artifactId>gt-process-feature</artifactId>
   <version>${geotools.version}</version>
 </dependency>

Transform

Transform a feature collection using a series of expressions to define each attribute.

The definition of the output feature type can be provided as a Definition data structure or using a simple string format:

        String transform = "the_geom=the_geom\n" + "name=name\n" + "area=area( the_geom )";

        TransformProcess process = new TransformProcess();

        SimpleFeatureCollection features = process.execute(featureCollection, transform);

This is a very flexible process which can be used to:

  • Change the order of attributes - resulting in a new feature type:

    INPUT Schema          DEFINITION                     OUTPUT Schema
    the_geom: Polygon     the_geom                       the_geom: Polygon
    name: String          id                             id: Long
    id: Long              name                           name: String
    description: String   description                    description: String
    
  • Rename or remove attributes - resulting in a new feature type:

    INPUT Schema          DEFINITION                     OUTPUT Schema
    the_geom: Polygon     the_geom                       the_geom: Polygon
    name: String          id_code=id                     id_code: Long
    id: Long              summary=description            summary: String
    description: String
    
  • Process geometry - using functions like the_geom=simplify( the_geom, 2.0 ) or the_geom=centriod( the_geom ):

    INPUT Schema          DEFINITION                     OUTPUT Schema
    the_geom: Polygon     the_geom=centriod(the_geom)    the_geom: Point
    name: String          name                           name: String
    id: Long              id                             id: Long
    description: String   description                    description: String
    
  • Generate additional attributes using the form: area=area( the_geom ):

    INPUT Schema          DEFINITION                     OUTPUT Schema
    the_geom: Polygon     the_geom=centriod(the_geom)    the_geom: Point
    name: String          name                           name: String
    id: Long              id                             id: Long
    description: String   description                    description: String
                          area=area( the_geom)           area: Double
                          text=concatenate(name,'-',id)  text: String
    

Group candidate selection

Filters a FeatureCollection according to the aggregate operation chosen (MIN or MAX) and the groups defined through attribute names. Given a feature collection, groups according to the defined grouping attributes, and returns the feature having the MIN or MAX value for the chosen attribute. One feature will be chosen for each group.

This vector process accepts four parameters:

  • data: the data on which perform the computation.

  • aggregation: the type of operation required to filter data (MIN or MAX).

  • operationAttribute: the xpath to the attribute whose value will be used to perform the MIN or MAX operation.

  • groupingAttributes: a lists of xpath pointing to the attirbutes defining the features’ groups for which perform the filtering process.

The process ensures a consistent results only if the FeatureCollection has already been sorted by the feature’s attributes passed as the groupingAttributes parameter.