0

I'm trying to calculate the area of a polygon using the code from this page and I'm getting the following error

The requested Style can not be used with this layer. The style specifies an attribute of geometry and the layer is workspace:layer

Here's my code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<sld:StyledLayerDescriptor version="1.0.0"
xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd"
    xmlns="http://www.opengis.net/sld"
    xmlns:sld="http://www.opengis.net/sld"
    xmlns:ogc="http://www.opengis.net/ogc"
    xmlns:gml="http://www.opengis.net/ogc"
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <sld:NamedLayer>
        <sld:Name>style_osm_polygon</sld:Name>
        <sld:UserStyle>
            <sld:Title>'Polygon'</sld:Title>

            <sld:FeatureTypeStyle>
                <sld:Rule>
                    <ogc:Filter>
                        <ogc:And>
                            <ogc:PropertyIsEqualTo>
                                <ogc:PropertyName>natural</ogc:PropertyName>
                                <ogc:Literal>water</ogc:Literal>
                            </ogc:PropertyIsEqualTo>
                            <ogc:PropertyIsGreaterThan>
                                <ogc:Function name="area">
                                    <ogc:PropertyName>geometry</ogc:PropertyName>
                                </ogc:Function>
                                <ogc:Literal>1000000</ogc:Literal>
                            </ogc:PropertyIsGreaterThan>
                        </ogc:And>
                    </ogc:Filter>
                    <sld:MaxScaleDenominator>7500000</sld:MaxScaleDenominator>
                    <sld:PolygonSymbolizer>
                        <sld:Fill>
                            <sld:CssParameter name="fill">#777777</sld:CssParameter>
                        </sld:Fill>
                    </sld:PolygonSymbolizer>
                </sld:Rule>
            </sld:FeatureTypeStyle>

        </sld:UserStyle>
    </sld:NamedLayer>
</sld:StyledLayerDescriptor>

I've tried capital GEOMETRY. Still get the same error.

  • what is your geometry column called then? – Ian Turton Mar 2 '18 at 16:02
  • I'm not sure. How do I find out? – Neil Patrao Mar 2 '18 at 16:04
  • go to the layers menu and select workspace:layer and look at the bottom of the page – Ian Turton Mar 2 '18 at 16:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.