GeoServer WFS – How to Fix GML Reporting Wrong Polygon Coordinates

geoservergmlwfs

From my GeoServer, I can correctly download a Shapefile of a Polygon layer and request it as WMS as well.

However, when requesting the same layer through WFS, I get wrong coordinates delivered.

A shapefile feature looks like this in QGIS, which is equivalent to the WMS rendered layer:

enter image description here

For the WFS request

https://myhost/workspace/ows?request=GetFeature&service=WFS&version=1.0.0&typename=workspace:typename

the capabilities are reporting this FeatureType, which looks good to me regarding the Bounding Box.

<FeatureType>
<Name>mytypename</Name>
<Title>mytitle</Title>
<SRS>EPSG:4326</SRS>
<LatLongBoundingBox minx="-72.4293746948242" miny="-35.4582633972168" maxx="-70.028450012207" maxy="-18.3206176757812"/>
</FeatureType>

However, the feature coordinates do not seem to be proper.

<gml:featureMember>
<workspace:typename fid="typename.1">
<workspace:geom>
<gml:MultiPolygon srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
<gml:polygonMember>
<gml:Polygon>
<gml:outerBoundaryIs>
<gml:LinearRing>
<gml:coordinates decimal="." cs="," ts=" ">
-70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0 -70,-18,0
</gml:coordinates>
</gml:LinearRing>
</gml:outerBoundaryIs>
</gml:Polygon>
</gml:polygonMember>
</gml:MultiPolygon>
</workspace:geom>
</workspace:typename>
</gml:featureMember>

After reading this post, I was checking the geometry type of the feature in PostGIS and it reported as ST_MultiPolygon which seems to be acceptable.

Any ideas what could cause this, might this be a WFS misconfiguration on my side?

EDIT:

I have checked different outputformats. KML, Shapefile and CSV are returning correctly looking coordinates with 14 decimal places.

FID,geom,
typename.1,"MULTIPOLYGON (((-70.32050165699997 -18.41908396799994, -70.32124551599998 -18.419575648999967, -70.32183959999998 -18.41996832899997, -70.32314272499997 -18.41856867599995, -70.32594203199994 -18.41509367499998, -70.32915158199995 -18.41094297899997, -70.33103387399996 -18.40792648499996, -70.32924810899993 -18.406309643999975, -70.32738512299994 -18.40674208799993, -70.32491401099998 -18.40740619999997, -70.32380200999995 -18.40726719999998, -70.31966289799993 -18.405923532999964, -70.31821111899995 -18.405506531999947, -70.31797945199997 -18.405460198999947, -70.31714545199998 -18.40646408799995, -70.31692922999997 -18.406881087999977, -70.31706822999996 -18.407050976999926, -70.31729989699994 -18.407143643999973, -70.31771689699997 -18.407189976999973, -70.31835011899994 -18.40669575499993, -70.31879800799999 -18.406155198999954, -70.31896789699994 -18.406927421999967, -70.31895245299995 -18.407220865999932, -70.31859722999997 -18.407483421999927, -70.31819567499997 -18.407483421999927, -70.31801034099993 -18.407483421999927, -70.31768600799995 -18.407576088999974, -70.31745434099997 -18.407807754999965, -70.31725356299995 -18.40811664399996, -70.31697556299997 -18.408425532999956, -70.31657085699999 -18.408868395999946, -70.31632597899994 -18.408854407999968, -70.31610917899997 -18.408841361999976, -70.31590275899998 -18.40890952199993, -70.31567463399995 -18.409020470999963, -70.31539750999997 -18.409210307999956, -70.31525122099998 -18.409276020999982, -70.31509517999996 -18.40932765799994, -70.31485239699998 -18.409429098999965, -70.31461973199998 -18.409498656999972, -70.31433030899996 -18.40955877899995, -70.31410936399993 -18.409523194999963, -70.31392895799996 -18.40947804999996, -70.31373160199996 -18.40950069699994, -70.31351202399998 -18.409428585999933, -70.31303063099995 -18.40906612599997, -70.31278293499997 -18.40895611199994, -70.31245936899995 -18.408819342999948, -70.31231368099998 -18.408697617999962, -70.31208028999998 -18.408514228999934, -70.31191611399998 -18.408400636999943, -70.31177898499993 -18.408474487999968, -70.31166025199997 -18.408506065999973, -70.31156569199999 -18.40852300499995, -70.31141118899995 -18.408527714999934, -70.31154779699995 -18.408775644999935, -70.31164798999998 -18.408957484999974, -70.31185649999998 -18.409176852999963, -70.31217789699997 -18.40963418499996, -70.31230892999997 -18.40988385399993, -70.31283344099995 -18.410311170999933, -70.31323105099995 -18.410974628999952, -70.31363441499997 -18.41114269199994, -70.31409925099996 -18.411276332999932, -70.31455765399994 -18.411489122999967, -70.31513722499994 -18.411540754999976, -70.31571609999997 -18.41164910499998, -70.31621109999998 -18.41170065299997, -70.31542049999996 -18.412921798999946, -70.31636164599996 -18.413742284999955, -70.31800261899997 -18.414852354999937, -70.31672362599994 -18.41634853599993, -70.31949879999996 -18.41830322499993, -70.32050165699997 -18.41908396799994)))

GML in all versions and JSON return truncated coordinates (only integer values) as it seems.

On the GeoServer Global Settings page I also checked the field Number of decimals (GML and GeoJSON output) to be set to 8.

I have installed GeoServer 2.22.2 version.

EDIT:

For the use case of getting the features displayed in QGIS, I could work around it using an UTM projection with meter coordinates. However this only seems to be a workaround, not a solution to this.

Best Answer

There is a setting, under "Global Settings", "Number of Decimals (GML and GeoJSON output)", controlling how many decimals are used to represent coordinates. It normally defaults to 8 (way more than enough normally).

Can you double-check check it's not set to a small number in your case?

Since it seems you're accessing a workspace-specific service https://myhost/workspace/ows?, also check if you have setting overrides in that workspace as well.

Related Question