1

In GeoServer, is there a way to only retrieve the attributes/properties of features, without geometries, using the GetFeatureInfo request?

I need to use the GetFeatureInfo request to retrieve features' attributes at a location when user clicks on a web map (similar to "Identify" tool in Esri). However, the response contains huge amount of coordinates/geometries in GeoJSON format, which makes it take up lots of computing/network resources. For example, some routes/lines geometries take up 10K lines when formatted nicely!

Looks like there is something called Freemarker but I can't find any good examples/resources so far. It appears that one limitation of Freemarker templates is it would apply to ALL GetFeatureInfo responses, whereas I only want the remove geometries for this particular web app.

Also we could use HTML or text format but they are harder to parse.

I'm new to GeoServer and we use PostgreSQL as the database.

New contributor
henrykodev is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
1

There is an example on the page you link to, all you need to do is remove the lines that print the geometry. (<#-- starts a comment, --> ends it)

<#list features as feature>
{
 "content" : "this is the content",
 "type": "Feature",
 "id" : "${feature.fid}",
 <#list feature.attributes as attribute>
 <#if attribute.isGeometry>
 <#-- "geometry": ${geoJSON.geomToGeoJSON(attribute.rawValue)}, -->
 </#if>
 </#list>
 "properties": {
 <#list feature.attributes?filter(a -> !a.isGeometry) as attribute>
 "${attribute.name}": "${attribute.value}"
 <#if attribute_has_next>
 ,
 </#if>
 </#list>
 }
}
<#if feature_has_next>
,
</#if>
</#list>
1
  • Thanks, I'll look into Freemarker templates more. Howerver one limitation seems to be the template is applied to all responses, whereas I only want to remove geometries for one web app (I have edited my question to reflect this).
    – henrykodev
    11 hours ago
0

I figured it out: turns out there is a vendor parameter called propertyName you can use to exclude geometry, by explicitly listing all the attributes you want.

For example, this URL will return the geometry which are quite a few coordinates:

https://data.stategrowth.tas.gov.au/geoserver/ssg/ows/?service=WMS&version=1.3.0&info_format=application/json&xsl_template=infoTemplate.xsl&SERVICE=WMS&REQUEST=GetFeatureInfo&FORMAT=image/png&TRANSPARENT=TRUE&STYLES=&VERSION=&version=1.3.0&LAYERS=GEO_ROAD_WORKS&WIDTH=1012&HEIGHT=858&SRS=EPSG:3857&BBOX=16417092.979047688,-5189935.42838609,16494447.25167218,-5124352.458117498&INFO_FORMAT=application/json&QUERY_LAYERS=GEO_ROAD_WORKS&FEATURE_COUNT=25&X=510&Y=539

Using the propertyName parameter removes the geometry but still including the properties/attributes (just 4 of them in the example below):

https://data.stategrowth.tas.gov.au/geoserver/ssg/ows/?service=WMS&version=1.3.0&info_format=application/json&xsl_template=infoTemplate.xsl&SERVICE=WMS&REQUEST=GetFeatureInfo&FORMAT=image/png&TRANSPARENT=TRUE&STYLES=&VERSION=&version=1.3.0&LAYERS=GEO_ROAD_WORKS&WIDTH=1012&HEIGHT=858&SRS=EPSG:3857&BBOX=16417092.979047688,-5189935.42838609,16494447.25167218,-5124352.458117498&INFO_FORMAT=application/json&QUERY_LAYERS=GEO_ROAD_WORKS&FEATURE_COUNT=25&X=510&Y=539
&PROPERTYNAME=ID,EVENT_TYPE,ROAD_NAME,TRAFFIC_MANAGEMENT
New contributor
henrykodev is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

henrykodev is a new contributor. Be nice, and check out our Code of Conduct.

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.