2

From server side, I'm using GeoServer and from client side I'm using OpenLayers to allow the users see the layers (PostGIS) on the map. The new requirement is that the users may download layers in shapefile format.

What is the best way to do this?

I would prefer add the option to download them in the same map view.

  • 2
    set the format to SHAPE-ZIP – Ian Turton Jun 13 '13 at 14:04
  • @iant sorry, I am very newbie. Where and how to set the format to SHAPE-ZIP? – Overflow012 Jun 13 '13 at 14:08
  • 1
    when you make a WFS request you set the format (usually to gml) - if instead you set it to shape-zip you will get a zipped shapefile back – Ian Turton Jun 13 '13 at 14:17
1

To get features from a WFS to display on a map (as an OpenLayers layer) you would make a WFS GetFeature request and specify the output format as GML or JSON, something like:

For GML (default output)

http://ogc.bgs.ac.uk/digmap625k_gsml_insp_gs/ows?
SERVICE=WFS&
VERSION=1.0.0&
REQUEST=GetFeature&
TYPENAME=gsmlp:GBR_BGS_625k_BA_INSP&
SRSNAME=EPSG:27700&

The outputFormatparameter can be omitted

For JSON

http://ogc.bgs.ac.uk/digmap625k_gsml_insp_gs/ows?
SERVICE=WFS&
VERSION=1.0.0&
REQUEST=GetFeature&
TYPENAME=gsmlp:GBR_BGS_625k_BA_INSP&
SRSNAME=EPSG:27700&
outputFormat=application/json&

To get a zipped shapefile from a GeoServer WFS you need to change the outputFormat parameter on the request to SHAPE-ZIP, like:

http://ogc.bgs.ac.uk/digmap625k_gsml_insp_gs/ows?
SERVICE=WFS&
VERSION=1.0.0&
REQUEST=GetFeature&
TYPENAME=gsmlp:GBR_BGS_625k_BA_INSP&
SRSNAME=EPSG:27700&
outputFormat=SHAPE-ZIP&

You can find out what output formats are available for any service by looking at the GetCapabilities response, for example the above service gives the following output formats for the GetFeature operation:

<ows:Parameter name="outputFormat">
    <ows:AllowedValues>
        <ows:Value>text/xml; subtype=gml/3.2</ows:Value>
        <ows:Value>GML2</ows:Value>
        <ows:Value>KML</ows:Value>
        <ows:Value>SHAPE-ZIP</ows:Value>
        <ows:Value>application/gml+xml; version=3.2</ows:Value>
        <ows:Value>application/json</ows:Value>
        <ows:Value>application/vnd.google-earth.kml xml</ows:Value>
        <ows:Value>application/vnd.google-earth.kml+xml</ows:Value>
        <ows:Value>csv</ows:Value>
        <ows:Value>gml3</ows:Value>
        <ows:Value>gml32</ows:Value>
        <ows:Value>json</ows:Value>
        <ows:Value>text/xml; subtype=gml/2.1.2</ows:Value>
        <ows:Value>text/xml; subtype=gml/3.1.1</ows:Value>
    </ows:AllowedValues>

Your Answer

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.