2

I want to calculate the sinuocity of each road segment of a vector shapefile which contains roads. I have downloaded the python script from enter link description here

but I don't know what to do after that. I open the python console from Geoprocessing->Python and dragged the file into it but nothing occured. What should I do to run this script and how can I choose the roads file which I want to process?

3

I have never used the tool you downlaoded, but you can use the following calculation to calculate sinuosity. Open the Attribute Table of the Road feature class, right click the column heading of the Double field you want to hold the Sinuosity value and choose Field Calculator... from the context menu:

Field Calculator...

Select the Python option at the top of the Field Calculator dialog and paste the code below into the expression:

!Shape.Length! / (math.sqrt(math.pow((float( !Shape.FirstPoint.X!) - float( !Shape.LastPoint.X!)), 2) + math.pow((float( !Shape.FirstPoint.Y!) - float( !Shape.LastPoint.Y!)), 2)))

Sinuosity Calculation

Press the OK button and it will calculate the sinuosity value. A value of 1 is for a straight line, This assumes you are using a Projected Coordinate System where the length and coordinates are in the same unit type (meters, feet, etc.)

The sinuosity values will range from 1 (a straight line) to infinity or error (a closed circle or loop).

Here are what some other values can represent:

A quarter circle (90 degree arc) = 1.11072

Two equal straight lines forming a 90 degree angle = 1.41421

A half circle (180 degree arc) = 1.57096

A 3/4 circle (270 degree arc) = 3.33216

5/6th of a circle (300 degree arc) = 5.23598

  • error 999999. The popup window writes "There was a failure during processing, chech the Geoprocessing Results winow for details". The field is not nullable. – ilias m Jul 18 '16 at 13:30
  • I just ran it on my data, and it ran fine. I have no closed loops in my roads. Do you have closed loops in yours? You probably have some bad features with Null geometry. They would have zero length (sort on length and look for 0). Run the Repair Geometry tool on your data to get rid of those features. – Richard Fairhurst Jul 18 '16 at 14:20
  • I have run the geometry repair. After that I tried to calculate the sinuocity according to your guidelines but the same problem occured. – ilias m Jul 18 '16 at 15:00
  • Select just one feature which you know is basically a straight line and calculate the sinuosity value just for it. Does that throw the error or do you get a value calculated? I just reran the calculation from the code I posted as a test and I have verified that it works (with good geometry and no closed loop roads). – Richard Fairhurst Jul 18 '16 at 15:34
  • Are all of your roads single part polyline features? Please run the Multipart to Singlepart tool on it to verify that no lines are multipart lines. Multipart lines can have strange start and end positions since although paths may appear to follow a straightforward path they can actually have their line directions scrambled at each self-intersection and gap. – Richard Fairhurst Jul 18 '16 at 15:48
0

Open ArcGIS (author says it requires Arc 10.1). On the Standard Toolbar, select/click on the ArcToolbox button (ArcToolbox icon has little red toolbox on it).

enter image description here

When the ArcToolbox Dialog window opens, right-click in it and select "Add Toolbox". Browse to where you extracted the Sinuosity.pyt file, click "Open". This adds the toolbox to your ArcGIS environment.

enter image description here

  • I have run the script but the sinuocity of the road segments is smaller than one which is not acceptable. Have you run the script without facing this problem? – ilias m Jul 22 '16 at 22:01
0

Here is the sinuosity solution for QGIS field calculator.

to_real( $length )  / sqrt( ( ( to_real( $x_at( 0 ) )  - to_real( $x_at( -1 ) ) ) ^2 ) + ( ( to_real( $y_at( 0 ) )  - to_real( $y_at( -1) ) )^2 ) )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.