Thursday 26 April 2018

How to tell what co-ordinate system a WFS server is giving?


I got a GML file from an ArcGIS-based WFS server and converted it to GeoJSON using Ogre (online ogr2ogr), but then got very strange results from that GeoJSON file.


Here's the link to the getCapabilities page of the WFS server:



http://sedsh127.sedsh.gov.uk/arcgis/services/ScotGov/HumanHealthSafety/MapServer/WFSServer?request=GetCapabilities&service=WFS



...which seems to be saying that it's latitue / longitude unless I'm reading it wrong:




latitude,longitude




...but the actual data doesn't look like latitude and longitude. Here's a sample from the start of the GML/XML file, the six-figure numbers aren't what I was expecting, and there's something I don't understand about an envelope:


5513 530249470332 1220301.51S08000015Ayrshire and Arran 225054.5 669796 225053.5 669806.5 225041.5 669820.5 225036 669831 225037 669835 225049 669845.5 225052 669856 225052 669859.5 225045.5 669875.5 225042 669897.5 225037.5 669912 225036 669930 225048 669961 225048.70000000019 670000 225048.79999999981 670000.09999999963 225048 670008.5 225039 670027 225017.5 670036.5 225016 670040.5 225016 670047 225019.5 670056 225023 670076 225036 670120 225033.5 670131.5 225023 670152.5 225000 670148.5 224975 670139.5 224835.5 670136.5 224517 670000.09999999963 224516.90000000037 670000 224205 669872.5 224098.5 669645 224095 669634 224091.5 669631 224080 669626 224076 669619.5 224076.5 669614 224074.5 669607.5 224069.5 669602.5 224055.5 669595.5 224052.5 669584.5 224042 669576.5 224034.5 669575 224024.5 669578.5 224019.5 669578.5 224009.5 669576 223998.5 669560.5 223990.5 669554 223975.5 669546.5 223964.5 669543.5 223949 669545 

Here's what it says about projections, and I didn't define any projections when extracting or converting the data. I may have misunderstood this, but my understanding is that if co-ordinates are lat/long they'd be independent of projections and projections would only matter when they're rendered?


urn:ogc:def:crs:EPSG:6.9:27700
urn:ogc:def:crs:EPSG:6.9:4326


I also don't recognise EPSG:6.9:27700, searching on it suggests it's something only the UK government uses.




Whatever this is, mapshaper.org is capable of reading it as a map of Scotland (left) but D3 doesn't know what's going on (right):


enter image description here enter image description here


I think what I need to do is work out what co-ordinate system I'm being given, then work out how to convert it, but I can't see how to find out. The publisher (Scottish govt) give very little data around this and I don't think there's anyone I can ask.


Is there some way of "reading" the co-ordinate system from the WFS server, from the GML file, or from the GeoJSON? (or even better a converter that can figure it out and fix as it goes?)




Update: I think I might have figured out the specific cause of my problems, but I'd still like a general answer on what the 'correct' method to figure this out it is as opposed to my bumbling:


Truncating the projection code to EPSG:27700 losing the 6.9 turns up the Ordnance Survey National Grid, which is:




a system of geographic grid references used in Great Britain, different from using Latitude and Longitude. It is often called British National Grid (BNG).



...so it's clearly not just a projection, it's actually a whole different grid system as well. This would seem to explain why D3 is so confused. I'm not sure how someone would normally know this though, beyond knowing to recognise 27700 as a projection that also comes with a non-standard co-ordinate system?



Answer



The data's bounding box is defined with geographic coordinates. I guess this is what caused the confusion.


The data itself, however has the EPSG code 27700, hence the element urn:ogc:def:crs:EPSG:6.9:27700.


This means, that the data will be in EPSG 27700 unless otherwise specified. In this case, EPSG 4326 would be a possible alternative. You can look up the SRS characteristics on sites like spatialreference.org.


If you need your WFS result to be in 4326, simply add &srsName=EPSG:4326 to your WFS request.


The identifiers written before the EPSG code are used to unambiguously define WFS elements. The exact definition can be looked up at the EPSG home page. In this specific case its




  • urn: Universal Resource Name

  • ogc: Open Geospatical Consortium

  • def: Definition

  • crs: Coordinate Reverence System

  • EPSG: European Petroleum Survey Group


The 6.9 means that the SRS 4326 specified in version 6.9 of the EPSG database, which you can find here.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...