I am working with this WFS endpoint:
https://wxs-gpu.mongeoportail.ign.fr/externe/39wtxmgtn23okfbbs1al2lz3/wfs
In QGIS, I do: Layer -> Add Layer -> Add WFS Layer...
, then add the above endpoint. I am interested in the layer with the Title Communes
, Name wfs_du:municipality
:
I successfully add this layer to Canvas. Then I use the Identify Features functionality (⌘⇧I on Mac), click on a polygon, and successfully get the properties of the clicked polygon:
The property fields loaded:
name, gid, insee, is_rnu, is_deleted
I try to download the polygons & the property fields using ogr2ogr
. As an example, I attempt to download 5 such polygons:
url="https://wxs-gpu.mongeoportail.ign.fr/externe/39wtxmgtn23okfbbs1al2lz3/wfs"
ogr2ogr output.geojson WFS:"$url" -dialect sqlite -sql "SELECT * FROM 'wfs_du:municipality' LIMIT 5"
The resulting output.geojson
won't have the name
property. The first 500 characters of output.geojson
(via head -c500 output.geojson
):
{
"type": "FeatureCollection",
"name": "SELECT",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": [
{ "type": "Feature", "properties": { "gml_id": "municipality.34248971", "gid": 34248971, "insee": "65252", "is_rnu": false, "is_deleted": false }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ -0.1252042315, 43.167289121099998 ], [ -0.1249586084, 43.167386257899999 ], [ -0.1245957926, 43.167317557300002 ], [ -0.1226253882, 43.17097534
The properties are:
gml_id, gid, insee, is_rnu, is_deleted
The name
field above got replaced by the gml_id
. Somehow QGIS seems to be able to map gml_id
to name
, but ogr2ogr is not doing the same. I would like to have the name
fields too, not the gml_id
, when downloading data using ogr2ogr. In other words:
How can I download the same property fields as QGIS is showing?