Sql server has a method As.GML to produce GML file from geography/geometric type. Is there a good example to utilize this GML on other mapping platform such as QGIS? I have ask a related question here, but QGIS reports its format is not valid.


2 Answers 2


I finally ended up write my own parser in python to parse the polygon string returned by sql server. Note that the simplekml library and the xml.etree library are used.

from xml.etree import ElementTree
import simplekml

def ParsexmlString(xmlstring):
    rxml = ElementTree.fromstring(xmlstring)
    drivetime = rxml.find('./Polygons/').get('duration')
    polygonstring = rxml.findtext('./[Your Polygon Location]}Polygon/{http://www.opengis.net/gml}exterior/{http://www.opengis.net/gml}LinearRing/{http://www.opengis.net/gml}posList')
    polygonlist= polygonstring.split(' ')
    polygonlist = [float(i) for i in polygonlist] 
    polygonlist = list(zip(*(iter(polygonlist),) * 2))
    polygonlist2 = [(i[1],i[0]) for i in polygonlist]
    return (polygonlist2)

def AddPolygontoKml(multiplekml, counter, polygonlist):
    multiplekml.newpolygon(name="Store Number " +str(counter),outerboundaryis=polygonlist)

    return (multiplekml)

QGIS is reading GML data with GDAL which wants to find the geometries inside gml:FeatureCollection as you can see from the example of the driver manual page http://www.gdal.org/ogr/drv_gml.html

Another example about GML that GDAL understands can be captured from this WFS server http://demo.opengeo.org/geoserver/wfs?service=wfs&version=1.1.0&request=getfeature&typename=osm:water_areas&outputformat=gml3&maxfeatures=1

I fear that for parsing GML like in your sample a special QGIS plugin would be needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.