Search code examples
pythondictionarygisnetworkxgml

Networkx read ordnance survey - ITN Integrated Transport Network?/Reading GML file


I met some problems.

I want to import ordnance survey - ITN Integrated Transport Network into networkx to do some network analysis.

Since the ITN is in a GML 2.1.2 format, I tried to use

nx.read_gml

However it warned me that

ParseException: Expected "graph" (at char 0), (line:1, col:1)

Then, I took sometime to look at the content of my file and find out that it is not like a gml file used in someone else's example. It does not have graph or square bracket or nodes. Am I understand this format right?

https://www.dropbox.com/s/3ppgs3t9t6odkpj/os-mastermap-itn-layer-sample-data.gml?dl=0

I have attached it above, the first lines indside it are:

<?xml version='1.0' encoding='UTF-8'?>
<osgb:FeatureCollection
xmlns:osgb='http://www.ordnancesurvey.co.uk/xml/namespaces/osgb'
xmlns:gml='http://www.opengis.net/gml'
xmlns:xlink='http://www.w3.org/1999/xlink'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:schemaLocation='http://www.ordnancesurvey.co.uk/xml/namespaces/osgb http://www.ordnancesurvey.co.uk/xml/schema/v7/OSDNFFeatures.xsd'
fid='GDS-1614256-8519'>

I get a little bit confused that why the gml format seems different? Anyone has tried to use networkx or python analyse ITN data?


Solution

  • It looks like the GML you are citing is the Geography Markup Language https://en.wikipedia.org/wiki/Geography_Markup_Language and the GML referred to in NetworkX is the Graph Modeling Language https://en.wikipedia.org/wiki/Graph_Modelling_Language.