GML (.gml)
- Import fully supports the XML version of the GML format.
Background & Context
-
- MIME type: application/gml+xml
- Vector map format
- GML is an XML-based format for geographic data.
- GML models geographic features and systems.
- GML enables data exchange over the internet.
- GML supports geometry, topology and coordinate systems.
Import & Export
- Import["file.gml"] imports the data associated to the vector geo primitives stored in the given file.
- Import["file.gml",elem] imports the specified element from a OSM file.
- Import["file.gml",{{elem1},{elem2},…}] imports multiple elements.
- The import format can be specified with Import["file","GML"] or Import["file",{"GML",elem,…}].
- See the following reference pages for full general information:
-
Import import from a file CloudImport import from a cloud object ImportString import from a string ImportByteArray import from a byte array
Import Elements
- General Import elements:
-
"Elements" list of elements and options available in this file "Summary" summary of the file "Rules" list of rules for all available elements - Data representation elements:
-
"Data" graphics primitives for each layer "Graphics" all layers combined into a single graphics object "GraphicsList" list of graphics representing the layers of an OSM archive - Import by default uses the "Graphics" element for the GML format.
- Import["file","Data"] returns an expression of the form {layer1,layer2,…} . Individual layers are given as a list of rules representing the geometry, as well as numerical and textual information associated with the features.
- Metainformation elements:
-
"LayerNames" all layer names, given as a list of strings "LayerTypes" what graphics primitives comprise each layer "SpatialRange" range of geographic coordinates, typically given in decimal degrees - Elements representing the geodetic datum and reference ellipsoid used in the file:
-
"CoordinateSystem" name of the coordinate system used in the file "Datum" geodetic datum "SemimajorAxis" semimajor axis of the reference ellipsoid "SemiminorAxis" semiminor axis of the reference ellipsoid "InverseFlattening" inverse flattening of the ellipsoid "LinearUnits" coordinate system units - Elements specifying the cartographic projection and its parameters:
-
"Projection" projection name and parameters "Centering" latitude and longitude defining the origin of the projection "StandardParallels" standard parallels "CentralScaleFactor" scale factor at the central meridian or center of projection "GridOrigin" grid coordinates {n,e} of the central parallel and meridian "ProjectionName" Wolfram Language standard name of the projection used "ReferenceModel" what reference sphere or ellipsoid to use - Accessing low-level metainformation from the file:
-
"CoordinateSystemInformation" raw parameters of the coordinate system as stored in the file - See the reference page for GeoProjectionData for full information on cartographic projections.
Options
- General rendering options:
-
GeoBackground Automatic background style ImageSize Automatic overall size of the image
Examples
open all close allBasic Examples (1)
Scope (1)
Import Elements (21)
Available Elements (1)
Data Representation (3)
"Data" (1)
"Graphics" (1)
Import the full set of graphics primitives and represent them using GeoGraphics:
Import["https://exampledata.wolfram.com/PalacioReal.gml"]%//HeadThis is equivalent to using an explicit "Graphics" element:
%% === Import["https://exampledata.wolfram.com/PalacioReal.gml", "Graphics"]Metadata (3)
"LayerNames" (1)
"LayerTypes" (1)
"SpatialRange" (1)
Import a map of the Royal Palace of Madrid, displaying its projected coordinate axes:
Import["https://exampledata.wolfram.com/PalacioReal.gml", Frame -> True]The "SpatialRange" element reports the projected ranges in the form {{xmin,ymin},{xmax,ymax}}:
Import["https://exampledata.wolfram.com/PalacioReal.gml", "SpatialRange"]Datum and Reference Ellipsoid (6)
"CoordinateSystem" (1)
"Datum" (1)
"SemimajorAxis" (1)
"SemiminorAxis" (1)
"InverseFlattening" (1)
Cartographic Projection (7)
"Projection" (1)
"Centering" (1)
"StandardParallels" (1)
Standard parallels of the cartographic projection, with None denoting no standard parallels:
Import["https://exampledata.wolfram.com/PalacioReal.gml", "StandardParallels"]"CentralScaleFactor" (1)
"GridOrigin" (1)
"ProjectionName" (1)
Applications (1)
Extract geometric data from a GML file:
data = Import["https://exampledata.wolfram.com/PalacioReal.gml", "Data"];geometrydata = "Geometry" /. data;Extract the projected polygons of this geometric data:
polygons = Cases[geometrydata, _Polygon, Infinity];Those are projected polygons in this projection:
Import["https://exampledata.wolfram.com/PalacioReal.gml", "Projection"]This is the "UTMZone30" projection:
GeoProjectionData["UTMZone30"]Represent these primitives in a map:
GeoGraphics[polygons, GeoProjection -> "UTMZone30"]Related Guides
History
Introduced in 2025 (14.3)