4

My team is currently working to develop a web-based GIS for a government client and we're using Geoserver 2.1.1 as our server application.

We're trying to play around with Geoserver's GetFeature function to generate a .csv file of the attribute fields of features saved in a PostGIS database. The function below does exactly that:

function generateFeatureTable(feature){ var featureTableURL = "http://localhost:8080/geoserver/prism/wfs?REQUEST=GetFeature&SERVICE=WFS&VERSION=1.1.0&TYPENAME=prism:" + feature + "&OUTPUTFORMAT=csv&SRSNAME=epsg:4326"; window.open(featureTableURL); }

The problem is that the .csv file is also including "the_geom" as one of its fields. If we make use of the PROPERTYNAME argument to specify the fields we like to include in the table, we would have to specify each and every field name excluding that of "the_geom".

Any ideas on how to specify the ones you would NOT want to include in the output file?

3 Answers 3

4

The WFS protocol does not have a notion of excluding attributes, so no, it's not possible.

0

It's possible to use the WFS DescribeFeatureType request to determine the attributes (columns) associated with a give layer. The response includes a list of all attributes and their types. Using the response you could then create a list of those attributes that you'd like to include.

In your case the request would be:

http://localhost:8080/geoserver/prism/wfs?REQUEST=DescribeFeatureType&SERVICE=WFS&VERSION=1.1.0&TYPENAME=prism:layername

Where prism:layername is the name of the your layer.

0

It might not help in your situation, but just in case you can make it work.

You can generate a .csv with the PostgreSQL COPY command, retrieving every column by simply naming the table OR passing a SELECT statement instead, specifying the exact columns/records to retrieve.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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