European Commission logo
INSPIRE Community Forum

Orientation of polygons created using HALE

Bas VANMEULEBROUK
By Bas VANMEULEBROUK Replies (16)

During the workshop on extending the INSPIRE PS Theme for CDDA Reporting at the EEA we have used HALE to transform shape files to the new INSPIRE compliant CDDA datamodel. There is one problem with the generated GML file: it contains clockwise outer polygons whereas the GML specifications prescribes outer polygons should be counter clockwise. This is probably due to the fact that in a shape file outer polygons should be clockwise. Anyone come across this problem and found a solution?

  • Daniel COCANU

    Hi,

    In the alignment, switch LAT, LON order at Ordinates to Point transformation, in order to obtain X = LON and Y = LAT. It should solve your problem. Anyway, consider that the CRS definition in the exported gml should be urn:ogc:def:crs:EPSG::3035, not EPSG:3035, which will switch the coordinate axes order.

    Daniel Cocanu

  • Stefania MORRONE

    By Stefania MORRONE

    We’ve come across the same problem (clockwise vs counter clockwise) in our activities related to the development of a Validation Service for INSPIRE GML based on the OGC GML Test Suite.

    More specifically the GML requirement (the respect of ISO19107) is tested by means of the validSurfaceOrientation() method, checking that the orientation of the surface boundary is consistent with the upward normal i.e. exterior boundary counterclockwise and interior boundaries clockwise. 
    Most INSPIRE GML files fail this test, but some others do not. The files are all derived from shapefile sources transformed to GML by means of HALE software and use the gml:polygon encoding.
    We are still investigating, but it seems that the issue does not depend on HALE but rather on ESRI shp standard.  
    We’re also considering the feasibility of using PostGIS import of shapefiles and subsequent change of boundaries orientation (ST_ForceLHR, ST_ForceRHR) .
    Actually we are also investigating with OGC how to avoid such a restriction on orientation of boundaries be a barrier to the use of INSPIRE data models by the data providers. 

  • Bas VANMEULEBROUK

    By Bas VANMEULEBROUK

    Thank you very much for your answers. I was indeed referring to the clockwise or counter clockwise orientation of the polygons generated by HALE, not to lon,lat or lat,lon order in individual coordinates. I have not checked that yet. May do that in the future.

    For another project, I have created a download service using GeoServer backed by a PostGIS database. This does allow you to correct the orientation of the polygons using PostGIS functions. But it also further complicates the CDDA reporting process. For this process, it would be nice if a shape file would work. Reversing the orientation in the shape file is maybe not such a good idea, since the shape file format prescribes that outer polygons should be clockwise, whereas GML prescribes they should be counter clockwise. The preferred option would be if HALE would check the orientation before writing the GML. Anyone aware of an option in HALE to achieve this?

  • Thorsten REITZ

    By Thorsten REITZ

    HALE by default does not change the orientation of any polygons that are processed. You can use a Groovy Custom Function to test and unify the orientation though. I will share an example for this in the next days. In cases like this when you have HALE-specific questions, it would be great if you can cross-post them to the HALE community board, so that we can respond quicker to them.

  • Thorsten REITZ

    By Thorsten REITZ

    We've discussed adding "Unify Winding Order" options (clockwise, counter-clockwise, no unification) to the HALE exporters, as a post processing step similar to the existing CRS conversion.

    Just so that we understand better what which writer format requires, I researched which OGC standard mandates which winding order for which geometry type. As far as I understood Stefania, polygons should be oriented counter-clockwise, but I wasn't able to find that requirement outside of the Simple Feature Access Specification 1.2.1 (Section 6.1.11.1 "The exterior boundary LinearRing defines the “top” of the surface which is the side of the surface from which the exterior boundary appears to traverse the boundary in a counter-clockwise direction).

    In GML 3.2.1, I suspect the key is the orientation flag, which "is implicitly fixed to +.". However, there is also the statement in  Section 13.3.2.1: "In the case of planar topology, the sequence of gml:directedEdges shall be clockwise to ensure a lossless topology representation"

    Maybe you can help me a bit with this?

  • Bas VANMEULEBROUK

    By Bas VANMEULEBROUK

    Thank you very much for your answers. I am not a member of the HALE comunity yet, but I will register and post a summary there, OK? 

    I stumbled upon this problem when I validated a GML generated during the workshop using the Dutch Geonovum INSPIRE validator which can be found at http://validatie-dataspecificaties.geostandaarden.nl/genericvalidator/standaard/INSPIREAllAnnexes. I have uploaded a screenshot (see below). Unfortunately, it is in Dutch, but I can translate the messages. It says it found GML 3.2 and then lists the errors found in the geometry. The error message translates as follows: "Invalid polygon. The outer ring of the polgon is clockwise within element MultiSurface" and then it mentions the gmlID and the coordinates of the polygon. This was conformed by the SFA specs you are referring to. I could try to get more information from Geonovum on this subject if you want to. 

    Geonovum INSPIRE GML validator

  • Stefania MORRONE

    By Stefania MORRONE

    Hi all,

    GML 3.2.1 standard directly refers the ISO 19107  in which we read ( ISO 19107:2003, cl. 6.3.17: GM_Surface)

    " the orientation of the surface chooses an "up" direction through the choice of the upward normal, which, if the surface is not a cycle, is the side of the surface from which the exterior boundary appears counterclockwise"

    The official  OGC Validator - GML 3.2.1 Test Suite -  checks that the orientation of the surface boundary is consistent with the upward normal by means of  the test class org.opengis.cite.iso19136.data.spatial.SurfaceTests.

    Hope this helps

    Stefania

     

  • Thorsten REITZ

    By Thorsten REITZ

    Hi Stefania, Bas,

    Thanks, that does help. We'll include this in the next HALE release (2.9.5). I'll notify you when the daily builds have the feature, in case you're adventurous.

  • Bas VANMEULEBROUK

    By Bas VANMEULEBROUK

    Hello Thorsten,

    That would be great! I will test it.

  • Thorsten REITZ

    By Thorsten REITZ

    Dear Stefania, Bas,

    Since about a week, the daily builds now have the feature to unify the winding order:

    https://builds.wetransform.to/job/hale/job/hale%7Epublish(master)/

    Download the appropriate version for your operating system and then export data using any of the GML Writers to test if it works for you.

    All the best,

    Thorsten

     

This discussion is closed.

This discussion is closed and is not accepting new comments.

Biodiversity & Area Management

Biodiversity & Area Management

If themes like Protected Sites, Area Management/Restriction/Regulation Zones and Reporting Units, Habitats and Biotopes, Species Distribution, Bio-geographical Regions matters to you, join these groups!