This reference describes all filter functions that can be used in WFS/WMS filtering or in SLD expressions.
The list of functions available on a GeoServer instance can be determined by browsing to http://localhost:8080/geoserver/wfs?request=GetCapabilities and searching for ogc:Function_Names (WFS 1.0.0), ogc:FunctionNames (WFS 1.1.0), or fes:Functions (WFS 2.0.0) in the returned XML. If a function is described in the Capabilities document but is not in this reference, then it might mean that the function cannot be used for filtering, or that it is new and has not been documented. Ask for details on the Discourse user group.
Unless otherwise specified, none of the filter functions in this reference are understood natively by the data stores, and thus expressions using them will be evaluated in-memory.
This function returns the value of environment variables defined in various contexts. WMS GetMap automatically defines some variables SLD rendering, while others can be provided using the env request parameter. Example usage in e.g. a dynamic symbolizer:
The area of the specified geometry. Works in a Cartesian plane, the result will be in the same unit of measure as the geometry coordinates (which also means the results won't make any sense for geographic data)
boundary
geometry:Geometry
Returns the boundary of a geometry
boundaryDimension
geometry:Geometry
Returns the number of dimensions of the geometry boundary
buffer
geometry:Geometry, distance:Double
Returns the buffered area around the geometry using the specified distance
Returns the buffered area around the geometry using the specified distance and using the specified number of segments to represent a quadrant of a circle.
centroid
geometry:Geometry
Returns the centroid of the geometry. Can be often used as a label point for polygons, though there is no guarantee it will actually lie inside the geometry
convexHull
geometry:Geometry
Returns the convex hull of the specified geometry
difference
a:Geometry, b:Geometry
Returns all the points that sit in a but not in b
dimension
a:Geometry
Returns the dimension of the specified geometry
distance
a:Geometry, b:Geometry
Returns the euclidean distance between the two geometries
endAngle
line:LineString
Returns the angle of the end segment of the linestring
endPoint
line:LineString
Returns the end point of the linestring
envelope
geometry:geometry
Returns the polygon representing the envelope of the geometry, that is, the minimum rectangle with sides parallels to the axis containing it
exteriorRing
poly:Polygon
Returns the exterior ring of the specified polygon
geometryType
geometry:Geometry
Returns the type of the geometry as a string. May be Point, MultiPoint, LineString, LinearRing, MultiLineString, Polygon, MultiPolygon, GeometryCollection
geomFromWKT
wkt:String
Returns the Geometry represented in the Well Known Text format contained in the wkt parameter
geomLength
geometry:Geometry
Returns the length/perimeter of this geometry (computed in Cartesian space)
getGeometryN
collection:GeometryCollection, n:Integer
Returns the n-th geometry inside the collection
getX
p:Point
Returns the x ordinate of p
getY
p:Point
Returns the y ordinate of p
getZ
p:Point
Returns the z ordinate of p
interiorPoint
geometry:Geometry
Returns a point that is either interior to the geometry, when possible, or sitting on its boundary, otherwise
interiorRingN
polyg:Polygon, n:Integer
Returns the n-th interior ring of the polygon
intersection
a:Geometry, b:Geometry
Returns the intersection between a and b. The intersection result can be anything including a geometry collection of heterogeneous, if the result is empty, it will be represented by an empty collection.
isClosed
line: LineString
Returns true if line forms a closed ring, that is, if the first and last coordinates are equal
isEmpty
geometry:Geometry
Returns true if the geometry does not contain any point (typical case, an empty geometry collection)
isometric
geometry:Geometry, extrusion:Double
Returns a MultiPolygon containing the isometric extrusions of all components of the input geometry. The extrusion distance is extrusion, expressed in the same unit as the geometry coordinates. Can be used to get a pseudo-3d effect in a map
isRing
line:LineString
Returns true if the line is actually a closed ring (equivalent to isRing(line) and isSimple(line))
isSimple
line:LineString
Returns true if the geometry self intersects only at boundary points
isValid
geometry: Geometry
Returns true if the geometry is topologically valid (rings are closed, holes are inside the hull, and so on)
numGeometries
collection: GeometryCollection
Returns the number of geometries contained in the geometry collection
numInteriorRing
poly: Polygon
Returns the number of interior rings (holes) inside the specified polygon
numPoint
geometry: Geometry
Returns the number of points (vertexes) contained in geometry
Returns the arc cosine of an angle in radians, in the range of 0.0 through PI
asin
angle:Double
Returns the arc sine of an angle in radians, in the range of -PI / 2 through PI / 2
atan
angle:Double
Returns the arc tangent of an angle in radians, in the range of -PI/2 through PI/2
atan2
x:Double, y:Double
Converts a rectangular coordinate (x, y) to polar (r, theta) and returns theta.
ceil
x: Double
Returns the smallest (closest to negative infinity) double value that is greater than or equal to x and is equal to a mathematical integer.
cos
angle: Double
Returns the cosine of an angle expressed in radians
double2bool
x: Double
Returns true if x is zero, false otherwise
exp
x: Double
Returns Euler's number e raised to the power of x
floor
x: Double
Returns the largest (closest to positive infinity) value that is less than or equal to x and is equal to a mathematical integer
IEEERemainder
x: Double, y:Double
Computes the remainder of x divided by y as prescribed by the IEEE 754 standard
int2bbool
x: Integer
Returns true if x is zero, false otherwise
int2ddouble
x: Integer
Converts x to a Double
log
x: Integer
Returns the natural logarithm (base e) of x
max, max_3, max_4
x1: Double, x2:Double, x3:Double, x4:Double
Returns the maximum between x1, ..., x4
min, min_3, min_4
x1: Double, x2:Double, x3:Double, x4:Double
Returns the minimum between x1, ..., x4
pi
None
Returns an approximation of pi, the ratio of the circumference of a circle to its diameter
pow
base:Double, exponent:Double
Returns the value of base raised to the power of exponent
random
None
Returns a Double value with a positive sign, greater than or equal to 0.0 and less than 1.0. Returned values are chosen pseudo-randomly with (approximately) uniform distribution from that range.
rint
x:Double
Returns the Double value that is closest in value to the argument and is equal to a mathematical integer. If two double values that are mathematical integers are equally close, the result is the integer value that is even.
round_2
x:Double
Same as round, but returns a Long
round
x:Double
Returns the closest Integer to x. The result is rounded to an integer by adding 1/2, taking the floor of the result, and casting the result to type Integer. In other words, the result is equal to the value of the expression (int)floor(a + 0.5)
roundDouble
x:Double
Returns the closest Long to x
sin
angle: Double
Returns the sine of an angle expressed in radians
tan
angle:Double
Returns the trigonometric tangent of angle expressed in radians
toDegrees
angle:Double
Converts an angle expressed in radians into degrees
toRadians
angle:Double
Converts an angle expressed in radians into degrees
String functions generally will accept any type of value for String arguments. Non-string values will be converted into a string representation automatically.
Name
Arguments
Description
Concatenate
s1:String, s2:String, ...
Concatenates any number of strings. Non-string arguments are allowed.
Abbreviates the sentence at first space beyond lower (or at upper if no space). Appends append if string is abbreviated.
strCapitalize
sentence:String
Fully capitalizes the sentence. For example, "HoW aRe YOU?" will be turned into "How Are You?"
strConcat
a:String, b:String
Concatenates the two strings into one
strDefaultIfBlank
str:String, default:String
returns default if str is empty, blank or null
strEndsWith
string:String, suffix:String
Returns true if string ends with suffix
strEqualsIgnoreCase
a:String, b:String
Returns true if the two strings are equal ignoring case considerations
strIndexOf
string:String, substring:String
Returns the index within this string of the first occurrence of the specified substring, or -1 if not found
strLastIndexOf
string:String, substring:String
Returns the index within this string of the last occurrence of the specified substring, or -1 if not found
strLength
string:String
Returns the string length
strMatches
string:String, pattern:String
Returns true if the string matches the specified regular expression. For the full syntax of the pattern specification see the Java Pattern class javadocs
Returns the string with the pattern replaced with the given replacement text. If the global argument is true then all occurrences of the pattern will be replaced, otherwise only the first. For the full syntax of the pattern specification see the Java Pattern class javadocs
strStartsWith
string:String, prefix:String
Returns true if string starts with prefix
strStripAccents
string:String
Removes diacritics (\~= accents) from a string. The case will not be altered.
strSubstring
string:String, begin:Integer, end:Integer
Returns a new string that is a substring of this string. The substring begins at the specified begin and extends to the character at index endIndex - 1 (indexes are zero-based).
strSubstringStart
string:String, begin:Integer
Returns a new string that is a substring of this string. The substring begins at the specified begin and extends to the last character of the string
strToLowerCase
string:String
Returns the lower case version of the string
strToUpperCase
string:String
Returns the upper case version of the string
strTrim
string:String
Returns a copy of the string, with leading and trailing blank-space omitted
Formats the specified date according to the provided format. The format syntax can be found in the Java SimpleDateFormat javadocs
dateParse
format:String, dateString:String
Parses a date from a dateString formatted according to the format specification. The format syntax can be found in the Java SimpleDateFormat javadocs
numberFormat
format:String, number:Double, locale:String
Formats the number according to the specified format using the default locale or the one provided as an optional argument. The format syntax can be found in the Java DecimalFormat javadocs
parseBoolean
boolean:String
Parses a string into a boolean. The empty string, f, 0.0 and 0 are considered false, everything else is considered true.
parseDouble
number:String
Parses a string into a double. The number can be expressed in normal or scientific form.
Computes the difference between two date (as a-b) and return a result in a specific time units. timeUnits is optional, representing the desired time units result. Default as milliseconds. Possible values are s (seconds), m (minutes), h (hours), d (days).
Transformation functions transform values from one data space into another. These functions provide a concise way to compute styling parameters from feature attribute values. See also Styling using Transformation Functions.
+-------------+----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Name | Arguments | Description |
+-------------+----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Recode | lookupValue:Object, | Transforms a lookupValue from a set of discrete data values into another set of values. Any number of data/value pairs may be specified. |
| | | |
| | data:Object, value:Object, ... | |
+-------------+----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Categorize | lookupValue:Object, value:Object, | Transforms a continuous-valued attribute value into a set of discrete values. lookupValue and value must be an orderable type (typically numeric). The initial value is required. Any number of additional threshold/value pairs may be specified. belongsTo is optional, with the value succeeding or preceding. It defines which interval to use when the lookup value equals a threshold value. |
| | | |
| | threshold:Object, ... value:Object, | |
| | | |
| | belongsTo : String | |
+-------------+----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Interpolate | lookupValue:Numeric, | Transforms a continuous-valued attribute value into another continuous range of values. Any number of data/value pairs may be specified. mode is optional, with the value linear, cosine or cubic. It defines the interpolation algorithm to use. method is optional, with the value numeric or color. It defines whether the target values are numeric or RGB color specifications. |
| | | |
| | data:Numeric, value:Numeric or #RRGGBB, ... | |
| | | |
| | mode:String, method:String | |
+-------------+----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+