I'd like to calculate the orientation of line segments relative to north direction using open source tools. Which tools or functions would you recommend?
[GIS] How to calculate orientation of line segments using open source GIS
open-source-gisvector
Related Solutions
Depending on which Kriging type you want to apply, there are different packages to choose from:
The most common version is implemented for example in:
- GRASS - v.krige
- SAGA - Module: Ordinary Kriging
- HPGL - ordinary-kriging() (PDF page 12)
- gstat - krige
Simple Kriging uses the average of the entire data set while Ordinary Kriging uses a local average. Therefore, Simple Kriging can be less accurate, but it generally produces "smoother" results. It's implemented in:
- HPGL - simple_kriging() (PDF page 12)
- gstat krige
Universal Kriging allows for consideration of drift in data. Implementations are included in:
Other Kriging Types
GRASS v.krige also supports Block Kriging.
HPGL implements a big number of less known Kriging methods (check the manual for more information on those):
- Indicator Kriging (IK)
- Local Varying Mean Kriging (LVM Kriging)
- Simple CoKriging (Markov Models 1 & 2)
- Sequential Indicator Simulation (SIS)
- Corellogram Local Varying Mean SIS (CLVM SIS)
- Local Varying Mean SIS (LVM SIS)
- Sequential Gaussian Simulation (SGS)
- Truncated Gaussian Simulation (GTSIM) [in Python scripts collection]
SAGA offers different versions of both Ordinary and Universal Kriging.
Gstat krige additionally supports Block and Point Kriging.
FWIW, in Postgis is a function since 1.5, ST_Longestline that returns the longestline between two geometries. If you feed that function with the same geometry twice instead of two different, you will get the longest line in that geometry. http://postgis.net/docs/ST_LongestLine.html
@Whuber. you write above that the longest line doesn't have to start and end in the polygons vertexes. You use the letter I as example. I don't get it. If I is represented by a Line with two vertexes, then that line has to be the longest line itself, right?
If the I letter is represented by a thin polygon, the longestline will be a diagonal line from say left upper vertex to right lower vertex.
But I cannot understand how there could be a longest line that doesn't end and start in polygon vertexes.
Do I miss understand something?
/Nicklas
Ok, Whuber, I misunderstood you, I read your answer once more. I was talking about what you call the diameter and you were talking about something else. Sorry
/Nicklas
Best Answer
To get an angle from a line you just need to find the angle of the normalized direction. The Atan2 function is available on every computing platform I have used, even calculators. The basic idea is to get a normalized vector for the direction of that line then get the angle.
For your case since you need it to be north (+y hopefully) relative and possibly clockwise you could reverse the inputs to Atan2 like so:
And if you need counter-clockwise negate the result of Atan2. For degrees just multiply by 180 then divide by
PI
. Also note that when the result is negative you can add2*PI
.Edited: to correct an error for counter-clockwise.
Note: only works if
North
is alwaysup
.