GML

GML is an abbreviation for "Geography Markup Language."  GML uses XML-like text to encode spatial data.   It is difficult to interchange because many incompatible forms of GML have emerged.   With the emergence of better formats, such as GeoJSON for "open" text format interchange and GPKG for "open" binary interchange,  GML is disappearing.  Even GML enthusiasts such as the UK's Ordnance Survey now publish downloadable data in either shapefiles or in GML.  Choose shapefiles.

 

There are two main problems with GML:  First, GML's design allows so much variation that most implementations of GML to date for saving GIS data have been incompatible with other implementations.  Second, in addition to the variability designed into GML, a significant problem with GML is the extreme inefficiency of the format. GML will frequently require files that are over 100 megabytes in size to store GIS data that other formats can save in only six megabytes.   

 

At the present time, the only concrete form of GML in which a significant amount of data is published appears to be GML as used by the UK's Ordnance Survey (OS).  The Manifold GML importer therefore aims at Ordnance Survey GML format, for example, as used for OS Open Data products that may be downloaded without charge.

 

Newer GML files from the OS usually have a .gml extension.  Some OS data files, especially older files, have no extension. GML files can occur in both independent and topological polygon forms. Manifold will automatically import either type and will apply any updates specified. Manifold's GML importer supports object versions and will import any metadata as a Manifold comments component.

 

GML files may contain multiple drawings for separate area, line and point object drawings, as well as drawings for points with text attributes that can be converted into labels.  Area drawings will often contain large areas that overlap other areas.

 

Open Data maps are named using a grid naming scheme, with the grid square identified by two letters as seen in the illustration at right.   For example, the Open Data Local file for the NN square is called NN.gml.  It covers the grid square just to the north of Glasgow, which is covered by grid square NS.gml.

Zip Compression

To reduce the large file sizes typical of GML, the Ordnance Survey has published GML files zipped into .zip format or, with older files, zipped into .gz "zip" format.  Unzip into the contained GML format file before importing into Manifold.  

 

To import a GML format file:

 

  1. Choose File - Import from the main menu.

  2. Navigate to the desired file.

  3. Choose GML Files (*.gml) in the file type combo box if the file does not have a .gml extension

  4. Double-click the file to import it.

  5. New drawings and tables for the contents of the GML file will appear in the Project pane.

Coordinate System

Manifold will automatically read and assign the coordinate system from newer OS files, which often use the OSGB 1936 / British National Grid (EPSG:27700) coordinate system.   When importing older OS files, which may use deprecated coordinate system nomenclature, the coordinate system may or may not be automatically harvested from the GML.   If the coordinate system is not automatically assigned, assigning OSGB 1936 / British National Grid (EPSG:27700) from the EPSG tab or UK British Grid from the Standard tab of the Coordinate System dialog will usually be correct.

 

To fit into this documentation, illustrations show an artificially small Manifold desktop, with only a few panes, docked to the right side.   In real life we use a much larger Manifold desktop, and all panes would be turned on, with some panes docked to the left and others docked to the right.

Example

We download the opmplc_gml3_nn.zip file from the Ordnance Survey free downloads page for OpenMap.  That unzips into a folder called OS OpenMap Local (GML) NN, which in turn contains a subfolder called data.

 

 

 

We launch Manifold and choose File - Create - New Folder to create a new folder called GML layers.   The import will create many layers, so to prevent those from cluttering up the Project pane we create a new folder in which to keep them.

 

We click the GML layers folder to highlight it, and then we choose File - Import.

 

 

In Manifold, we launch File - Import, navigate to the data subfolder, and double-click on the NN.gml file to import it.

 

 

 

 

The GML file imports as many drawings, providing layers that each contain areas, lines or points.   In the illustration above we have created a map, with the Building Drawing layer using a Bing Streets image server base layer.   The buildings drawing contains areas that show the outlines of building footprints.  When zoomed far out they appear to be points.

 

 

 

 

In the above we have zoomed much further into the view, and we have used Style to color the building areas a green color.   We have clicked on the Component tab of the Info pane to see the coordinate system for the Building Drawing has been automatically read from the GML file and has been assigned.   The drawing therefore, as expected, lines up very well with the Bing streets layer.

Multi-type Geometry

GML, like GeoJSON, KML, and similar formats, can include geometry data for each object that mixes one or more geometry types.  Geometry values declared as multi-type but with all parts having the same underlying type, such as all areas, all lines, or all points, will preserve that underlying type. Geometry values declared as multi-type that mix different types are converted as follows:

 

 

See the discussion and example in the KML, KMZ Google topic.

 

Save using Efficient Formats

A 70 MB GML format file takes about 45 seconds to import into Manifold. However, it can be saved as a .mxb project file requiring only 4.7 MB of space in a few seconds and thereafter loaded almost instantly.   After importing GML files, it is a good idea to save the data in more efficient formats, such as Manifold projects.

Versions

GML entities can include version information that allows distinguishing between multiple versions of the same object, that is, between objects with same unique ID assigned by the data provider. When Manifold encounters an object that has already been imported, perhaps as the result of processing an update, it compares the versions of the existing object and the new object, determines which object is more recent and uses the more recent object.

 

A .gml file can contain a complete version of a drawing or, theoretically, it can contain updates to a drawing that represent changes to be made. In fact, a .gml file could contain both an original version as well as subsequent updates.  Manifold does not support use of incremental change files.

 

Notes

3D conversions - Geometry values with mixed 2D and 3Dcoordinates in GML, GeoJSON, and TopoJSON are automatically converted to 3D with 2D coordinates padded with zeros.

 

See Also

Drawings

 

Tables

 

Maps

 

Style

 

Web Servers

 

File - Import

 

File - Create - New Data Source

 

Example: An Imageserver Tutorial - An extensive tutorial showing step by step how to add new data sources that are image servers, how to show them as layers in a map, how to create a new drawing that matches the projection of the map and how to trace over what is seen in an image server layer to create an area object in the drawing.

 

Example: Import GML / OS Open Map Local - Import an Ordnance Survey, UK, vector map in GML format from the OS Open Map - Local series.