[GRASS-dev] new addon: v.faultdirections

Dear all,

As a result of some work with a student, I've just committed a small and very simple addon that takes azimuths of lines from the attribute table and draws a polar bar frequency plot in order to be able to visually determine the dominant direction(s).

As this is generally used for geological faults, I called it v.faultdirections.

It is really in a very simple and basic state, but I thought that I'd better upload it before I forget it. Hope it might be useful to some. If anyone wants to work on it, please feel free...

Moritz

Hi Moritz,

Moritz Lennert wrote

Dear all,

As a result of some work with a student, I've just committed a small and
very simple addon that takes azimuths of lines from the attribute table
and draws a polar bar frequency plot in order to be able to visually
determine the dominant direction(s).

As this is generally used for geological faults, I called it
v.faultdirections.

It is really in a very simple and basic state, but I thought that I'd
better upload it before I forget it. Hope it might be useful to some. If
anyone wants to work on it, please feel free...

just wanted to test it on windows, but see:

https://wingrass.fsv.cvut.cz/grass73/x86_64/addons/grass-7.3.svn/logs/v.faultdirections.log

[snip]
Traceback (most recent call last):
  File
"C:/Users/landa/grass_packager/grass73/x86_64/addons/v.faultdirections/scripts/v.faultdirections.py",
line 50, in <module>
    import matplotlib.pyplot as plt
  File
"C:\OSGeo4W64\apps\Python27\lib\site-packages\matplotlib-1.3.1-py2.7-win-amd64.egg\matplotlib\pyplot.py",
line 98, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show =
pylab_setup()
  File
"C:\OSGeo4W64\apps\Python27\lib\site-packages\matplotlib-1.3.1-py2.7-win-amd64.egg\matplotlib\backends\__init__.py",
line 28, in pylab_setup
    globals(),locals(),[backend_name],0)
  File
"C:\OSGeo4W64\apps\Python27\lib\site-packages\matplotlib-1.3.1-py2.7-win-amd64.egg\matplotlib\backends\backend_qt4agg.py",
line 13, in <module>
    from backend_qt4 import QtCore, QtGui, FigureManagerQT, FigureCanvasQT,\
  File
"C:\OSGeo4W64\apps\Python27\lib\site-packages\matplotlib-1.3.1-py2.7-win-amd64.egg\matplotlib\backends\backend_qt4.py",
line 25, in <module>
    from qt4_compat import QtCore, QtGui, _getSaveFileName, __version__
  File
"C:\OSGeo4W64\apps\Python27\lib\site-packages\matplotlib-1.3.1-py2.7-win-amd64.egg\matplotlib\backends\qt4_compat.py",
line 36, in <module>
    import sip
ImportError: No module named sip
[snip]

maybe some issue with the matplotlib backend?

see

https://trac.osgeo.org/grass/browser/grass-addons/grass7/raster/r.width.funct/r.width.funct.py#L46
https://trac.osgeo.org/grass/browser/grass-addons/grass7/raster/r.hypso/r.hypso.py#L52

where I've added some lines that it works also on windows.

-----
best regards
Helmut
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/new-addon-v-faultdirections-tp5294302p5294461.html
Sent from the Grass - Dev mailing list archive at Nabble.com.

Le Sat, 5 Nov 2016 14:37:22 -0700 (MST),
Helmut Kudrnovsky <hellik@web.de> a écrit :

Hi Moritz,

Moritz Lennert wrote
> Dear all,
>
> As a result of some work with a student, I've just committed a
> small and very simple addon that takes azimuths of lines from the
> attribute table and draws a polar bar frequency plot in order to be
> able to visually determine the dominant direction(s).
>
> As this is generally used for geological faults, I called it
> v.faultdirections.
>
> It is really in a very simple and basic state, but I thought that
> I'd better upload it before I forget it. Hope it might be useful to
> some. If anyone wants to work on it, please feel free...

just wanted to test it on windows, but see:

https://wingrass.fsv.cvut.cz/grass73/x86_64/addons/grass-7.3.svn/logs/v.faultdirections.log

[snip]
Traceback (most recent call last):
  File
"C:/Users/landa/grass_packager/grass73/x86_64/addons/v.faultdirections/scripts/v.faultdirections.py",
line 50, in <module>
    import matplotlib.pyplot as plt
  File
"C:\OSGeo4W64\apps\Python27\lib\site-packages\matplotlib-1.3.1-py2.7-win-amd64.egg\matplotlib\pyplot.py",
line 98, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show =
pylab_setup()
  File
"C:\OSGeo4W64\apps\Python27\lib\site-packages\matplotlib-1.3.1-py2.7-win-amd64.egg\matplotlib\backends\__init__.py",
line 28, in pylab_setup
    globals(),locals(),[backend_name],0)
  File
"C:\OSGeo4W64\apps\Python27\lib\site-packages\matplotlib-1.3.1-py2.7-win-amd64.egg\matplotlib\backends\backend_qt4agg.py",
line 13, in <module>
    from backend_qt4 import QtCore, QtGui, FigureManagerQT,
FigureCanvasQT,\ File
"C:\OSGeo4W64\apps\Python27\lib\site-packages\matplotlib-1.3.1-py2.7-win-amd64.egg\matplotlib\backends\backend_qt4.py",
line 25, in <module>
    from qt4_compat import QtCore, QtGui, _getSaveFileName,
__version__ File
"C:\OSGeo4W64\apps\Python27\lib\site-packages\matplotlib-1.3.1-py2.7-win-amd64.egg\matplotlib\backends\qt4_compat.py",
line 36, in <module>
    import sip
ImportError: No module named sip
[snip]

maybe some issue with the matplotlib backend?

see

https://trac.osgeo.org/grass/browser/grass-addons/grass7/raster/r.width.funct/r.width.funct.py#L46
https://trac.osgeo.org/grass/browser/grass-addons/grass7/raster/r.hypso/r.hypso.py#L52

where I've added some lines that it works also on windows.

Thanks Helmut ! I've just committed the same. Could you try if that
makes it work ?

Moritz

Moritz Lennert wrote

maybe some issue with the matplotlib backend?

see

https://trac.osgeo.org/grass/browser/grass-addons/grass7/raster/r.width.funct/r.width.funct.py#L46
https://trac.osgeo.org/grass/browser/grass-addons/grass7/raster/r.hypso/r.hypso.py#L52

where I've added some lines that it works also on windows.

Thanks Helmut ! I've just committed the same. Could you try if that
makes it work ?

https://wingrass.fsv.cvut.cz/grass73/x86_64/addons/grass-7.3.svn/logs/

it compiles now also on windows.

a quick test with

v.report map=test@user1 option=length
cat|vazimuth|length
1|244.950779|9348.35400342
2|221.312441|9951.01054944
3|199.83213|9730.81864487
4|175.322582|9600.70580563
5|141.98849|3207.86482835
6|94.698681|2123.01170046
7|277.507347|3772.31624213
8|285.610989|2051.88943075
9|71.113913|1169.71795667
10|78.146996|2419.67219737
11|90|2231.6347053
12|164.298026|7512.31179866
13|213.13561|7509.69092987
14|241.484453|8406.23126945
15|247.890552|7014.05058479
16|251.482848|6388.22365365

v.faultdirections map=test@user1 column=vazimuth
C:\OSGEO4~1\apps\Python27\lib\site-
packages\matplotlib-1.3.1-py2.7-win-
amd64.egg\matplotlib\cbook.py:1711:
VisibleDeprecationWarning: using a non-integer number
instead of an integer will result in an error in the future
  result = np.zeros(new_shape, a.dtype)

some matplotlib warning, but a nice polar barplot is created.

polar barplot polar barplot
<http://osgeo-org.1560.x6.nabble.com/file/n5294559/figure_1.png&gt;

but I get an error when using

-a Use absolute values in legend, instead of percentages

  v.faultdirections -a map=test@user1 column=vazimuth
Traceback (most recent call last):
  File "C:\Users\hkmyr\AppData\Roaming\GRASS7\addons/scripts
/v.faultdirections.py", line 100, in <module>
    sys.exit(main())
  File "C:\Users\hkmyr\AppData\Roaming\GRASS7\addons/scripts
/v.faultdirections.py", line 87, in main
    labelradii = [x for x in np.arange(0,
int(np.ceil(max(radii))), labelstep) if x > 0]
ZeroDivisionError: division by zero

-----
best regards
Helmut
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/new-addon-v-faultdirections-tp5294302p5294559.html
Sent from the Grass - Dev mailing list archive at Nabble.com.

On 07/11/16 10:25, Helmut Kudrnovsky wrote:

Moritz Lennert wrote

maybe some issue with the matplotlib backend?

see

https://trac.osgeo.org/grass/browser/grass-addons/grass7/raster/r.width.funct/r.width.funct.py#L46
https://trac.osgeo.org/grass/browser/grass-addons/grass7/raster/r.hypso/r.hypso.py#L52

where I've added some lines that it works also on windows.

Thanks Helmut ! I've just committed the same. Could you try if that
makes it work ?

https://wingrass.fsv.cvut.cz/grass73/x86_64/addons/grass-7.3.svn/logs/

it compiles now also on windows.

a quick test with

v.report map=test@user1 option=length
cat|vazimuth|length
1|244.950779|9348.35400342
2|221.312441|9951.01054944
3|199.83213|9730.81864487
4|175.322582|9600.70580563
5|141.98849|3207.86482835
6|94.698681|2123.01170046
7|277.507347|3772.31624213
8|285.610989|2051.88943075
9|71.113913|1169.71795667
10|78.146996|2419.67219737
11|90|2231.6347053
12|164.298026|7512.31179866
13|213.13561|7509.69092987
14|241.484453|8406.23126945
15|247.890552|7014.05058479
16|251.482848|6388.22365365

v.faultdirections map=test@user1 column=vazimuth
C:\OSGEO4~1\apps\Python27\lib\site-
packages\matplotlib-1.3.1-py2.7-win-
amd64.egg\matplotlib\cbook.py:1711:
VisibleDeprecationWarning: using a non-integer number
instead of an integer will result in an error in the future
  result = np.zeros(new_shape, a.dtype)

some matplotlib warning, but a nice polar barplot is created.

I don't see these warnings, but then again, I have matplotlib 1.5.3...

polar barplot polar barplot
<http://osgeo-org.1560.x6.nabble.com/file/n5294559/figure_1.png&gt;

but I get an error when using

-a Use absolute values in legend, instead of percentages

  v.faultdirections -a map=test@user1 column=vazimuth
Traceback (most recent call last):
  File "C:\Users\hkmyr\AppData\Roaming\GRASS7\addons/scripts
/v.faultdirections.py", line 100, in <module>
    sys.exit(main())
  File "C:\Users\hkmyr\AppData\Roaming\GRASS7\addons/scripts
/v.faultdirections.py", line 87, in main
    labelradii = [x for x in np.arange(0,
int(np.ceil(max(radii))), labelstep) if x > 0]
ZeroDivisionError: division by zero

This was due to the fact that in your example there are only very few lines per direction. I believe I solved this issue in r69786.

Thanks for testing !

Moritz

Moritz Lennert wrote

but I get an error when using

-a Use absolute values in legend, instead of percentages

  v.faultdirections -a map=test@user1 column=vazimuth
Traceback (most recent call last):
  File "C:\Users\hkmyr\AppData\Roaming\GRASS7\addons/scripts
/v.faultdirections.py", line 100, in

<module>

    sys.exit(main())
  File "C:\Users\hkmyr\AppData\Roaming\GRASS7\addons/scripts
/v.faultdirections.py", line 87, in main
    labelradii = [x for x in np.arange(0,
int(np.ceil(max(radii))), labelstep) if x > 0]
ZeroDivisionError: division by zero

This was due to the fact that in your example there are only very few
lines per direction. I believe I solved this issue in r69786.

Thanks for testing !

confirmed, it works now.

-----
best regards
Helmut
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/new-addon-v-faultdirections-tp5294302p5294779.html
Sent from the Grass - Dev mailing list archive at Nabble.com.

On Fri, 4 Nov 2016, Moritz Lennert wrote:

As a result of some work with a student, I've just committed a small and
very simple addon that takes azimuths of lines from the attribute table
and draws a polar bar frequency plot in order to be able to visually
determine the dominant direction(s).

As this is generally used for geological faults, I called it v.faultdirections.

Moritz,

   Will this create wind rose diagrams, too? Air pollution modeling depends
on those.

Regards,

Rich

Hi Rich,

On 04/11/16 13:31, Rich Shepard wrote:

On Fri, 4 Nov 2016, Moritz Lennert wrote:

As a result of some work with a student, I've just committed a small and
very simple addon that takes azimuths of lines from the attribute table
and draws a polar bar frequency plot in order to be able to visually
determine the dominant direction(s).

As this is generally used for geological faults, I called it
v.faultdirections.

   Will this create wind rose diagrams, too? Air pollution modeling depends
on those.

Well, in its current form it takes a vector map with lines and the azimuth of these lines in the attribute table. It then creates a frequency plot of the lines according to direction as a polar bar plot. Nothing more. So, if you have, e.g., each day's wind of the year as a line in a vector map, you could use this to create a frequency plot of the winds, but there is currently no way to color bar in a differentiated symbology for something like speed.

If you have a list of winds with their direction and speed, you'd probably be better off directly using matplotlib. You can look at the source code of v.faultdirections for inspiration, if needed.

But maybe this module could be improved and complexified to suit more uses...

Moritz

On Fri, 4 Nov 2016, Moritz Lennert wrote:

Well, in its current form it takes a vector map with lines and the azimuth
of these lines in the attribute table. It then creates a frequency plot of
the lines according to direction as a polar bar plot. Nothing more. So, if
you have, e.g., each day's wind of the year as a line in a vector map, you
could use this to create a frequency plot of the winds, but there is
currently no way to color bar in a differentiated symbology for something
like speed.

Moritz,

   Yes, there are existing alternatives yet I was curious about
v.faultdirections current capabilities.

Many thanks,

Rich