Got it! Lots of fun! Good links for python http://pcjericks.github.io/py-gdalogr-cookbook/vector_layers.html#get-wfs-layer-and-iterate-over-features
Thousand thanks Even Rouault <[email protected]>@lists.osgeo.org Envoyé par : [email protected] 2014-12-12 15:42 A [email protected] cc [email protected] Objet Re: [gdal-dev] Parse GML without geometry Le vendredi 12 décembre 2014 21:38:06, [email protected] a écrit : > thanks Kyle > > I ended up with > geom=osgeo.ogr.CreateGeometryFromGML(wfs_response) > Returns ERROR 1: Unrecognised geometry type <FeatureCollection> > > If I understand well, I think my question now is > How do I parse the feature collection with ogr? With the WFS driver: ogrinfo "WFS: http://demo.mapserver.org/cgi-bin/wfs?SERVICE=WFS&REQUEST=GetFeature&version=1.1.0&Typename=continents&maxfeatures=10&propertyname=(NA2DESC) " -ro -al You can read the OGR API tutorial to see how to use a OGR datasource, layer, feature Regarding gemetry or not geometry, it won't matter. Actually as generated by mapserver, there's a geometry column declared, but not filled. Won't be an issue: $ wget " http://demo.mapserver.org/cgi-bin/wfs?SERVICE=WFS&REQUEST=DescribeFeatureType&VERSION=1.1.0&TYPENAME=continents& " -O - <schema targetNamespace="http://mapserver.gis.umn.edu/mapserver" xmlns:ms="http://mapserver.gis.umn.edu/mapserver" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:gml="http://www.opengis.net/gml" elementFormDefault="qualified" version="0.1" > <import namespace="http://www.opengis.net/gml" schemaLocation=" http://schemas.opengis.net/gml/3.1.1/base/gml.xsd" /> <element name="continents" type="ms:continentsType" substitutionGroup="gml:_Feature" /> <complexType name="continentsType"> <complexContent> <extension base="gml:AbstractFeatureType"> <sequence> <element name="msGeometry" type="gml:GeometryPropertyType" minOccurs="0" maxOccurs="1"/> <element name="NA2DESC" type="string"/> <element name="NA3DESC" type="string"/> </sequence> </extension> </complexContent> </complexType> </schema> > > > > > > > > Kyle Shannon <[email protected]> > 2014-12-12 14:47 > > A > [email protected] > cc > GDAL Developers <[email protected]> > Objet > Re: [gdal-dev] Parse GML without geometry > > > > > > > > > Steve, > > On Fri, Dec 12, 2014 at 12:35 PM, <[email protected]> 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&versio > n=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@kyle-workstation:~$ ogrinfo -so -al -ro > "/vsicurl_streaming/http://demo.mapserver.org/cgi-bin/wfs?SERVICE=WFS&REQUE > ST=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&REQUE > ST=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 > > [email protected] > > http://lists.osgeo.org/mailman/listinfo/gdal-dev > > kss -- Spatialys - Geospatial professional services http://www.spatialys.com _______________________________________________ gdal-dev mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/gdal-dev
_______________________________________________ gdal-dev mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/gdal-dev
