4

I have some Dutch Infrastructure GML files that I'm trying to display in GeoServer. Step 1 is to import the GML into PostGIS and while I can make it work using the OGR GML driver, I end up with a nasty mismash of tables that have to be stitched back together with views (and guess work). So I thought I could use the GMLAS driver (it should be able to handle this sort of INSPIRE data) and it seems to except it doesn't import the geometries of the links.

These are stored in pairs of features like this, 1st there is a imkl:Rioolleiding (a storm water drain) which links via it's <net:link xlink:href="nl.imkl-GM1641.236013_ulink"></net:link> to the following feature us-net-common:UtilityLink which holds some more information and the actual geometry.

Running ogrinfo -oo REMOVE_UNUSED_LAYERS=yes -oo REMOVE_UNUSED_FIELDS=yes -ro GMLAS:GI_gebiedsinformatielevering_19C000111_1.xml gives 66 layers but only one in us_net_common which is us_net_common_inspireid, and 3 rioolleiding layers none of which has any geometry.

23: rioolleiding (None)
24: rioolleiding_innetwork (None)
25: rioolleiding_link (None)

Please tell me I'm missing something obvious.

<imkl:Rioolleiding 
xmlns:us-govserv="http://inspire.ec.europa.eu/schemas/us-govserv/4.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" 
xmlns:gn="http://inspire.ec.europa.eu/schemas/gn/4.0" 
xmlns:gts="http://www.isotc211.org/2005/gts" 
xmlns:sc="http://www.interactive-instruments.de/ShapeChange/AppInfo" 
xmlns:gco="http://www.isotc211.org/2005/gco" 
xmlns:act-core="http://inspire.ec.europa.eu/schemas/act-core/4.0" 
xmlns:gmd="http://www.isotc211.org/2005/gmd" 
xmlns:gmlexr="http://www.opengis.net/gml/3.3/exr" 
xmlns:gsr="http://www.isotc211.org/2005/gsr" 
xmlns:gss="http://www.isotc211.org/2005/gss" 
gml:id="nl.imkl-GM1641.236013">
            <net:beginLifespanVersion>1900-01-01T00:00:00.000Z</net:beginLifespanVersion>
            <net:inspireId>
                <base:Identifier>
                    <base:localId>GM1641.236013</base:localId>
                    <base:namespace>nl.imkl</base:namespace>
                </base:Identifier>
            </net:inspireId>
            <net:inNetwork xlink:href="nl.imkl-GM1641.Maasgouw_RVV"></net:inNetwork>
            <net:link xlink:href="nl.imkl-GM1641.236013_ulink"></net:link>
            <us-net-common:currentStatus xlink:href="http://inspire.ec.europa.eu/codelist/ConditionOfFacilityValue/functional"></us-net-common:currentStatus>
            <us-net-common:validFrom>1900-01-01T00:00:00.000Z</us-net-common:validFrom>
            <us-net-common:verticalPosition>underground</us-net-common:verticalPosition>
            <us-net-common:utilityFacilityReference></us-net-common:utilityFacilityReference>
            <us-net-common:governmentalServiceReference></us-net-common:governmentalServiceReference>
            <us-net-common:warningType xsi:nil="true" nilReason="unknown"></us-net-common:warningType>
            <us-net-common:pipeDiameter uom="urn:ogc:def:uom:OGC::mm">125.0</us-net-common:pipeDiameter>
            <us-net-sw:sewerWaterType xlink:href="http://inspire.ec.europa.eu/codelist/SewerWaterTypeValue/combined"></us-net-sw:sewerWaterType>
            <imkl:geoNauwkeurigheidXY xlink:href="http://definities.geostandaarden.nl/imkl2015/id/waarde/NauwkeurigheidXYvalue/onbekend"></imkl:geoNauwkeurigheidXY>
            <imkl:buismateriaalType xlink:href="http://definities.geostandaarden.nl/imkl2015/id/waarde/PipeMaterialTypeIMKLValue/PVC"></imkl:buismateriaalType>
        </imkl:Rioolleiding>
</gml:featureMember>
<gml:featureMember>
<us-net-common:UtilityLink 
xmlns:us-govserv="http://inspire.ec.europa.eu/schemas/us-govserv/4.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" 
xmlns:gn="http://inspire.ec.europa.eu/schemas/gn/4.0" 
xmlns:gts="http://www.isotc211.org/2005/gts" 
xmlns:sc="http://www.interactive-instruments.de/ShapeChange/AppInfo" 
xmlns:gco="http://www.isotc211.org/2005/gco" 
xmlns:act-core="http://inspire.ec.europa.eu/schemas/act-core/4.0" 
xmlns:gmd="http://www.isotc211.org/2005/gmd" 
xmlns:gmlexr="http://www.opengis.net/gml/3.3/exr" 
xmlns:gsr="http://www.isotc211.org/2005/gsr" 
xmlns:gss="http://www.isotc211.org/2005/gss" 
gml:id="nl.imkl-GM1641.236013_ulink">
            <net:beginLifespanVersion>1900-01-01T00:00:00.000Z</net:beginLifespanVersion>
            <net:inspireId>
                <base:Identifier>
                    <base:localId>GM1641.236013_ulink</base:localId>
                    <base:namespace>nl.imkl</base:namespace>
                </base:Identifier>
            </net:inspireId>
            <net:inNetwork xlink:href="nl.imkl-GM1641.Maasgouw_RVV"></net:inNetwork>
            <net:centrelineGeometry>
                <gml:LineString gml:id="nl.imkl-GM1641.236013_ulink-0" srsDimension="2" srsName="EPSG:28992">
                    <gml:posList>190008.375849 351407.866177 190008.475669 351408.328408</gml:posList>
                </gml:LineString>
            </net:centrelineGeometry>
            <net:fictitious>false</net:fictitious>
            <us-net-common:currentStatus xlink:href="http://inspire.ec.europa.eu/codelist/ConditionOfFacilityValue/functional"></us-net-common:currentStatus>
            <us-net-common:validFrom>2018-07-10T00:00:00.000Z</us-net-common:validFrom>
            <us-net-common:verticalPosition>underground</us-net-common:verticalPosition>
            <us-net-common:utilityFacilityReference></us-net-common:utilityFacilityReference>
            <us-net-common:governmentalServiceReference></us-net-common:governmentalServiceReference>
        </us-net-common:UtilityLink>
</gml:featureMember>
2
  • could it be that there is no geometry, only named places?
    – nmtoken
    Commented Jun 3, 2019 at 16:14
  • there is a a centrelineGeomertry element and it works if I use the GML driver
    – Ian Turton
    Commented Jun 3, 2019 at 16:17

3 Answers 3

3

It turns out the secret is to list all the schemas on the command line rather than just the root one. So after fetching the schemas (look for a list of imports in the top of imkl2015-wion.xsd) you can run:

ogr2ogr -f PostgreSQL -s_srs epsg:28992 -t_srs epsg:4326 PG:'host=localhost user=ian dbname=gml_test schemas=test2' \
 GMLAS:19G000603_1/GI_gebiedsinformatielevering_19G000603_1.xml \
 -nlt CONVERT_TO_LINEAR -skipfailures  \
 -oo XSD=ElectricityNetwork.xsd,imkl2015-wion.xsd,Leveringsinformatie-2.1.xsd,OilGasChemicalsNetwork.xsd,SewerNetwork.xsd,TelecommunicationsNetwork.xsd,ThermalNetwork.xsd,UtilityNetworksCommon.xsd,WaterNetwork.xsd \
 -oo CONFIG_FILE=./gmlasconf.xml \
 -oo REMOVE_UNUSED_LAYERS=YES -oo REMOVE_UNUSED_FIELDS=YES -lco LAUNDER=NO

And you will get 82 (or so) tables in your schema and can then tie them together using a view like:

CREATE OR REPLACE VIEW test.v_OlieGasChemicalienPijpleiding AS                  
 SELECT r.*,                                                                    
    replace(u."thema_href"::text, 'http://definities.geostandaarden.nl/imkl2015/id/waarde/Thema/'::text, ''::text) as thema,
    replace(r."currentStatus_href"::text, 'http://inspire.ec.europa.eu/codelist/ConditionOfFacilityValue/'::text, ''::text) AS "currentStatus",
    replace(u."utilityNetworkType_href"::text, 'http://inspire.ec.europa.eu/codelist/UtilityNetworkTypeValue/'::text, ''::text) AS "UtilityNetworkTypeValue",
    g."centrelineGeometry"                                                      
   FROM test."OlieGasChemicalienPijpleiding" r                                  
     JOIN test."OlieGasChemicalienPijpleiding_inNetwork" i ON r.ogr_pkid::text = i.parent_ogr_pkid::text
     JOIN test."OlieGasChemicalienPijpleiding_link" l ON r.ogr_pkid::text = l.parent_ogr_pkid::text
     JOIN test."Utiliteitsnet" u ON i.href::text = u.id::text                   
     JOIN test."UtilityLink" g ON l.href::text = g.id::text;                    

ALTER TABLE test.v_OlieGasChemicalienPijpleiding                                
  OWNER TO ian; 

Ideally, I'd like to avoid the replace functions but that would seem to involve rewriting the SLD files instead, unless there is another option to the GMLAS driver I'm missing.

1
  • 1
    Thanks for further investigating the GMLAS driver! That seems to make the first replacement step using cat obsolete. The fewer steps in the conversion, the better! I left out the full URI in the value lists. On closer inspection, the UtilityNetworkTypeValue column should actually be named UtilityNetworkType instead. Another round of improvements of the SLDs and documentation is slated for September. Commented Jun 10, 2019 at 19:34
0

Have you tried the GML Application Schema toolbox QGIS plugin - https://github.com/BRGM/gml_application_schema_toolbox ?

1
  • It seems just to be a wrapper around the ogr2ogr call - not really working either.
    – Ian Turton
    Commented Jun 10, 2019 at 12:57
0

I have been involved in the development of the IMKL2015 standard and created the SLDs for GeoServer. To create the view for Rioolleiding, I not only joined the table with the UtilityLink, but also with the Utiliteitsnet.

  1. Parse the GML: cat $GML_FILE | sed 's/xlink:href/val/g' | sed 's/xsi:nil/nil/g' > transformed.gml
  2. Load into PostGIS using OGR setting --config GML_ATTRIBUTES_TO_OGR_FIELDS YES
  3. Upgrade link column to type Array: ALTER TABLE imkl."Rioolleiding" ALTER COLUMN link TYPE varchar[] USING ARRAY[link];
  4. Create the view joining Rioolleiding with both UtilityLink and Utiliteitsnet: CREATE OR REPLACE VIEW imkl."Rioolleiding_view" AS SELECT a.*, ul.geom AS geom, un.thema AS thema FROM imkl."Rioolleiding" a JOIN imkl."UtilityLink" ul ON a.link @> ARRAY[ul.gml_id] JOIN imkl."Utiliteitsnet" un ON a."inNetwork" = un.gml_id;

Hopefully this points you in the right direction.

1
  • I don't get an UtilityLink table is the issue
    – Ian Turton
    Commented Jun 10, 2019 at 12:58

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.