I am trying to map a WFS layer with data originally coming from a PostGIS table, and using a OpenLayers 3. At some point in this process, I believe the longitude and latitude coordinates are getting switched. Here is the relevant bit of code, but I don't think this is the problem.

 var planningAppsSource = new ol.source.GeoJSON({
      'projection': map.getView().getProjection(),
      'url': 'http://localhost:8080/geoserver/wfs?DATASTORE=Framework&service=wfs&version=1.3.0&request=GetFeature&typeName=POSTGIS:equatortable&outputFormat=application/JSON&maxFeatures=5'

var planningAppsLayer = new ol.layer.Vector({
   source: planningAppsSource,
   style: new ol.style.Style({
      image: new ol.style.Icon(({
        anchor: [5, 5],
        anchorXUnits: 'fraction',
        anchorYUnits: 'pixels',
        src: 'marker-icon.png'


None of the points showed up, so I went and entered the output from the WFS call into geojson.io, and points that were supposed to be in Indiana were in Antarctica. Switching the x and y in geojson.io got the points to where they should have been. To double check my hypotheses I created a PostGIS table with the point (0,0), (5,5) and (-5,5). The first two were where you would expect them to be, while the last was not. The odd things is that the WFS is the only place where I have this problem. I can call the same exact data using WMS, and it maps fine using openlayers or on the geoserver previews. I can get the WFS and view it using QGIS and the map looks right. Any idea where the problem is?

My best guess is that the problem arises because I have my data is in EPSG:4326 projection which takes lat, lon while the protocol for WFS 1.3 is lon, lat. Am I on the right track for understanding what is wrong?

I can probably fix the problem by creating 'false' points, and having everything plotted back properly, but I was wondering if there was a less absurd solution to this problem.

  • 1
    Which GeoServer version you use? What is the output projection? BTW, WFS 1.3.0 does not exist. GeoServer probably uses the highest version that it supports, either 2.0 or 1.1.0. – user30184 Nov 19 '14 at 22:46
  • 4326 is lon/lat too. Have you set the view projection correctly in OpenLayers? Also see this question from yesterday dealing with 4326 WFS from Geoserver. Coordinates are definitely lon/lat, as this is US West Coast. – John Powell Nov 20 '14 at 8:43
  • 2
    Use the URN form of the ogc epsg cofe to be certain of your axis order. – Ian Turton Nov 20 '14 at 14:31

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.