SGIS v.R Technology
Advanced Editing Tools in SGIS: Changing the Drawing Orientation of a Selected Element and Adjusting the Orientation of a Whole Polygon Layer from CW to CCW and Vice Versa with a Single Click Function
Published on: 26.08.2024
Many GIS projects follow specific standards for how geometries should be stored and displayed. Reordering vertices ensures that your data adheres to these standards, facilitating smooth data exchange and interoperability.
Properly ordering vertices ensures topological consistency, maintaining accurate relationships between features such as shared boundaries or connected networks. It also prevents errors that can arise during spatial analysis or when exporting data, ensuring the data remains reliable and usable. In network tracing and flow analysis, the correct vertex order is essential for accurate results. Similarly, GIS operations like buffering or creating offsets rely on the correct orientation of features, and reordering vertices helps achieve the expected outcomes.
For line features like roads, pipelines, or streams, vertex order dictates the line’s direction, which is crucial for accurate network analysis, flow direction modeling, and other spatial analyses.
In many GIS systems, polygons must have their exterior rings drawn in a specific direction (typically clockwise) and interior rings (holes) in the opposite direction (typically counterclockwise).
Changing the orientation of a layer from clockwise (CW) to counterclockwise (CCW), or vice versa, is crucial in GIS to ensure that data meets the specific orientation requirements of different software and data standards.
For instance, the commonly used shapefile format in GIS typically requires polygon rings to have a clockwise (CW) orientation for exterior boundaries and a counterclockwise (CCW) orientation for interior boundaries (holes). This distinction is important for correctly interpreting and displaying polygons.
In contrast, the GML (Geography Markup Language) format usually requires the opposite orientation: counterclockwise (CCW) for exterior boundaries and clockwise (CW) for interior boundaries, following the “right-hand rule” used in many systems.
Having a tool that can adjust the orientation of an entire layer is therefore extremely useful. It helps ensure that spatial data is consistently interpreted and displayed across different platforms, preventing errors and maintaining data integrity.
Incorrect vertex ordering can lead to polygons rendering incorrectly, appearing inside-out, or causing errors in area calculations.
To demonstrate how easy and effective this function is in SGIS v.R, we’ll use two real-world examples.
By following these steps in SGIS v.R, you can efficiently reorder vertices and maintain the accuracy and consistency of your spatial data:
A practical example #1
Our example features GIS data with polygons representing land parcels and two separate polylines that need to be connected.
To achieve this, we must add an additional vertex and snap it to the starting vertex of the second line.
While this is a straightforward task, the challenge arises because both lines begin at the same point but extend in opposite directions.
This scenario highlights the need for a tool that can easily and effectively address such issues.
Using the ‘Add to Selection’ Tool, we’ve selected both polylines and displayed their vertices. This highlights the drawing order of each polyline and reveals the gap that needs fixing.
Notably, the first polyline is drawn in a clockwise (CW) order, while the second, lower polyline is in a counterclockwise (CCW) order. We need to adjust the vertex orientation of the first polyline to match the CCW direction of the second one.
From the Element Data, we access the editing toolbox and select the ‘Add Vertex’ tool. By holding down the Shift key, we activate the snapping option, which is indicated by a red circle around the desired vertex location. The blue arrow pointer highlights the exact spot where we will place the new vertex using the snapping feature.
Upon clicking, the new vertex is immediately added. However, since the drawing order is clockwise (CW), the new vertex, numbered 20, connects to vertex 19, which is the last vertex on the upper side.
As a result, the line is connected irregularly, visually appearing as if it passes through the polyline feature.
Since this is not the desired outcome, we’ll use the ‘Delete Vertex’ tool from the Editing Toolbox to remove the vertex. The command prompts a confirmation, and we click ‘Yes.’ The procedure is completed, and vertex 20 is deleted.
The next step is to open the ‘Change Element Orientation’ function, found in the Edit menu on the Main Menu toolbox. For better visual clarity, it’s highlighted with a red square. On the graphics panel, blue arrows indicate the vertices and their direction before the change.
To begin the process, simply click the ‘Change Element Orientation’ button with the left mouse button.
With a single left-click on the function, the procedure is automatically completed. As shown in Fig. 12, the vertices are reordered in the direction indicated by the blue arrows, now in a counterclockwise (CCW) orientation. Note that we need the CCW orientation in this specific example to proceed with the merging process of both lines.
Whether you should use a CW or CCW orientation in GIS depends on the specific application and the rules governing the data, as well as the specific requirements of the GIS project you are working on. There isn’t a universal rule that CW is more accurate; it is about following the correct orientation as per the data standards you are using.
By clicking on the desired vertex and holding the Shift key to activate the snapping option, we place the new vertex accurately. The line is now correctly extended since the vertices are in the proper order. In Fig. 14, this is further highlighted with blue arrows indicating the direction of the polyline.
The procedure is now complete.
A Practical Example #2
In this example, we’ll start by opening a SHP file that contains two polygon layers: parcels and buildings. Using the ‘Select’ function along with ‘Add to Selection,’ we select several polygons.
It’s important to note that we’re selecting them purely for demonstration purposes, to show how the vertices look before and after the orientation change. The function itself works on the entire layer, so there’s no need to select individual objects or features. The user only needs to ensure the layer is active in the Layers panel, then open and execute the function.
Returning to our example, as seen in Fig. 16, the orientation of the selected polygon vertices is currently clockwise (CW). Our goal is to change the orientation of all features in this layer—specifically, all the buildings—to counterclockwise (CCW).
This function provides two options: ‘Set CW Layer Orientation’ and ‘Set CCW Layer Orientation.’ These options standardize the orientation of the entire layer. For instance, if a layer contains polygons with mixed orientations, the function will unify them, making all polygons either CW or CCW, depending on the option selected.
To change the orientation of our SHP layer to CCW, simply click on ‘Set CCW Polygon Layer Orientation,’ and the entire layer will be adjusted accordingly.
This automatically changes the entire layer to a CCW orientation.
If we need to change the orientation of the entire polygon layer back from CCW to CW, we can easily do so by selecting the ‘Set CW Layer Orientation’ option from the edit menu. With just one click, the layer’s orientation will be adjusted.
In Fig.19, we’ve zoomed in to provide a clearer view of the vertex points for better visualization.
As mentioned earlier, the SHP file format typically requires the outer boundaries of polygons to have a CW orientation, while the GML file format specifies that these boundaries should be in a CCW orientation.
To demonstrate this, we’ll import a GML file from a GML zip archive containing polygons, and then verify and adjust the orientation of the entire layer, switching from CCW to CW and vice versa.
The GML data has been successfully loaded, containing four GML layers of building and parcel polygons. We’ll focus on the ‘buildings_o’ layer. As shown in Fig.23, after loading the data and enabling the ‘Vertex’ function to display vertex numbering, we can immediately see that the layer’s orientation is CCW.
Using the same function, we’ll now switch the orientation to CW.
The orientation has been adjusted, and the procedure is complete.
It’s important to note that while this function is available for editing, users aren’t required to use it when saving or exporting their SHP files or other formats. During export, the software automatically saves vertices according to the specifications of the file format.