[gdal-dev] Parse GML without geometry

Kyle Shannon kyle at pobox.com
Fri Dec 12 11:47:47 PST 2014


Steve,

On Fri, Dec 12, 2014 at 12:35 PM,  <Steve.Toutant at inspq.qc.ca> wrote:
> Hi,
> I need to parse the GML returned by this query, to make a list of unique
> value of NA2DESC tag using python
> http://demo.mapserver.org/cgi-bin/wfs?SERVICE=WFS&REQUEST=GetFeature&version=1.1.0&Typename=continents&maxfeatures=10&propertyname=(NA2DESC)
>
> I could not make it with a XML parser yet. I consider using ogr API but can
> I use it even if there is no geometry?

This one has a geometry, or so ogr thinks so:

kyle at kyle-workstation:~$ ogrinfo -so -al -ro
"/vsicurl_streaming/http://demo.mapserver.org/cgi-bin/wfs?SERVICE=WFS&REQUEST=GetFeature&version=1.1.0&Typename=continents&maxfeatures=10&propertyname=(NA2DESC)"
INFO: Open of `/vsicurl_streaming/http://demo.mapserver.org/cgi-bin/wfs?SERVICE=WFS&REQUEST=GetFeature&version=1.1.0&Typename=continents&maxfeatures=10&propertyname=(NA2DESC)'
      using driver `GML' successful.

Layer name: continents
Geometry: Unknown (any)
Feature Count: 10
Extent: (-90.000000, -180.000000) - (83.627419, 180.000000)
Layer SRS WKT:
GEOGCS["WGS 84",
    DATUM["WGS_1984",
        SPHEROID["WGS 84",6378137,298.257223563,
            AUTHORITY["EPSG","7030"]],
        AUTHORITY["EPSG","6326"]],
    PRIMEM["Greenwich",0,
        AUTHORITY["EPSG","8901"]],
    UNIT["degree",0.0174532925199433,
        AUTHORITY["EPSG","9122"]],
    AUTHORITY["EPSG","4326"]]
Geometry Column = msGeometry
gml_id: String (0.0)
NA2DESC: String (0.0)
NA3DESC: String (0.0)

>
> If ogr api is a good option, any link to examples or tutorial would be
> appreciated since I never used the API.

API tutorials:

For gdal 2.x:

http://gdal.org/ogr_apitut.html

For gdal 1.x (the vector side is ogr):

http://gdal.org/1.11/ogr/ogr_apitut.html

>
> Thanks!
>
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev

kss

-- 
Kyle


More information about the gdal-dev mailing list