[GRASS-dev] Inclusion of additional files with add-on

Hello,

I’m getting around to completing my TODO list for the add-on r.terrain.texture, which includes generating the additional terrain metrics (terrain surface concavity and convexity), and calculating the nested 8,12 or 16 class terrain classification as per Iwahashi and Pike (2007). Everything is working but the script uses r.mfilter, which I supply a matrix filter to, stored as a text file.

Is there a makefile command that can be used to bundle a text file with the add on, which can then be found using set_path?

Steve

On 12/08/17 16:45, Steven Pawley wrote:

Hello,

I'm getting around to completing my TODO list for the add-on r.terrain.texture, which includes generating the additional terrain metrics (terrain surface concavity and convexity), and calculating the nested 8,12 or 16 class terrain classification as per Iwahashi and Pike (2007). Everything is working but the script uses r.mfilter, which I supply a matrix filter to, stored as a text file.

Is there a makefile command that can be used to bundle a text file with the add on, which can then be found using set_path?

Can't you include the filter as a string directly in the code ?

Moritz

Thanks Moritz, that’s one option although I dropping large blobs of text strings into the script might not be very ‘clean’ (I also have three files representing color rules, and three category files that are applied to the 8, 12 or 16 terrain classification results). If there is no alternative I’ll go with that (or create some additional python files containing the strings that are imported), but I was wondering if there is a way to package the typical GRASS rule files in the add-on.

Steve

···

On Sat, Aug 12, 2017 at 9:00 AM, Moritz Lennert <mlennert@club.worldonline.be> wrote:

On 12/08/17 16:45, Steven Pawley wrote:

Hello,

I’m getting around to completing my TODO list for the add-on r.terrain.texture, which includes generating the additional terrain metrics (terrain surface concavity and convexity), and calculating the nested 8,12 or 16 class terrain classification as per Iwahashi and Pike (2007). Everything is working but the script uses r.mfilter, which I supply a matrix filter to, stored as a text file.

Is there a makefile command that can be used to bundle a text file with the add on, which can then be found using set_path?

Can’t you include the filter as a string directly in the code ?

Moritz

On Aug 12, 2017 4:45 PM, “Steven Pawley” <dr.stevenpawley@gmail.com> wrote:

Hello,

I’m getting around to completing my TODO list for the add-on r.terrain.texture, which includes generating the additional terrain metrics (terrain surface concavity and convexity), and calculating the nested 8,12 or 16 class terrain classification as per Iwahashi and Pike (2007). Everything is working but the script uses r.mfilter, which I supply a matrix filter to, stored as a text file.

Is there a makefile command that can be used to bundle a text file with the add on, which can then be found using set_path?

You may want to check how the color files are installed. Should work pretty much the same.

Markus

Steve


grass-dev mailing list
grass-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-dev

(I also have three files representing color rules, and three category >files

that are applied to the 8, 12 or 16 terrain classification >results)

https://trac.osgeo.org/grass/browser/grass-addons/grass7/raster/r.euro.ecosystem/r.euro.ecosystem.py#L72

an example where I've embeded color and category rules in the script.

-----
best regards
Helmut
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Inclusion-of-additional-files-with-add-on-tp5331342p5331362.html
Sent from the Grass - Dev mailing list archive at Nabble.com.

Thanks Markus for the pointer, I will take a look.

Steve

···

On Sat, Aug 12, 2017 at 1:35 PM, Markus Neteler <neteler@osgeo.org> wrote:

On Aug 12, 2017 9:34 PM, “Markus Neteler” <neteler@osgeo.org> wrote:

On Aug 12, 2017 4:45 PM, “Steven Pawley” <dr.stevenpawley@gmail.com> wrote:

Hello,

I’m getting around to completing my TODO list for the add-on r.terrain.texture, which includes generating the additional terrain metrics (terrain surface concavity and convexity), and calculating the nested 8,12 or 16 class terrain classification as per Iwahashi and Pike (2007). Everything is working but the script uses r.mfilter, which I supply a matrix filter to, stored as a text file.

Is there a makefile command that can be used to bundle a text file with the add on, which can then be found using set_path?

You may want to check how the color files are installed. Should work pretty much the same.

I meant the Makefile in lib/gis/

Markus

Steve


grass-dev mailing list
grass-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-dev

Thanks Helmut,

I have gone with your's and Moritz's suggestion and have completed r.terrain.texture with the Iwahashi and Pike nested-means terrain classification method in the add-ons.

Best regards,

Steve

Sent from my iPhone

On Aug 12, 2017, at 2:22 PM, Helmut Kudrnovsky <hellik@web.de> wrote:

(I also have three files representing color rules, and three category >files

that are applied to the 8, 12 or 16 terrain classification >results)

https://trac.osgeo.org/grass/browser/grass-addons/grass7/raster/r.euro.ecosystem/r.euro.ecosystem.py#L72

an example where I've embeded color and category rules in the script.

-----
best regards
Helmut
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Inclusion-of-additional-files-with-add-on-tp5331342p5331362.html
Sent from the Grass - Dev mailing list archive at Nabble.com.
_______________________________________________
grass-dev mailing list
grass-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-dev

I have gone with your's and Moritz's suggestion and have completed

r.terrain.texture with the Iwahashi >and Pike nested-means terrain
classification method in the add-ons.

addon tested here with

System Info
GRASS version: 7.3.svn
GRASS SVN revision: r71384
Build date: 2017-08-11
Build platform: x86_64-w64-mingw32
GDAL: 2.2.1
PROJ.4: 4.9.3
GEOS: 3.5.0
SQLite: 3.17.0
Python: 2.7.5
wxPython: 2.8.12.1
Platform: Windows-8-6.2.9200 (OSGeo4W)

and

r.terrain.texture elevation=elevation@PERMANENT slope=myslope@user1
classes=12 texture=terr_tex convexity=terr_convex concavity=terr_concav
features=terr_class

I get

------
r.terrain.texture elevation=elevation@PERMANENT slope=myslope@user1
classes=12 texture=terr_tex convexity=terr_convex concavity=terr_concav
features=terr_class
Calculating terrain surface texture...
1. Smoothing input DEM with a 3x3 median filter...
2. Extracting pits and peaks with difference > thres...
3. Using resampling filter to create terrain texture...
4. Converting to percentage...
Calculating terrain convexity and concavity...
1. Calculating terrain curvature using laplacian filter...
2. Extracting convexities and concavities...
3. Using resampling filter to create surface convexity/concavity...
4. Converting to percentages...
Performing terrain surface classification...
Traceback (most recent call last):
  File
"C:\OSGEO4~1\apps\grass\grass-7.3.svn/scripts/m.proj.py",
line 308, in <module>
    main()
  File
"C:\OSGEO4~1\apps\grass\grass-7.3.svn/scripts/m.proj.py",
line 243, in main
    inf = file(infile)
IOError: [Errno 13] Permission denied: 'c:\\users\\xxx\\ap
pdata\\local\\temp\\grass7-hkmyr-6804\\tmpl1pwdf'
ERROR: cs2cs failed
Deleting intermediate files...
WARNING: No data base element files found
Traceback (most recent call last):
  File "C:\Users\xxx\AppData\Roaming\GRASS7\addons/scripts
/r.terrain.texture.py", line 575, in <module>
    sys.exit(main())
  File "C:\Users\xxx\AppData\Roaming\GRASS7\addons/scripts
/r.terrain.texture.py", line 471, in main
    flags='g', quiet=True,
stdout_=PIPE).outputs.stdout.split(os.linesep)[:-1]
  File "C:\OSGEO4~1\apps\grass\grass-7.3.svn\etc\python\gras
s\pygrass\modules\interface\module.py", line 648, in
__call__
    return self.run()
  File "C:\OSGEO4~1\apps\grass\grass-7.3.svn\etc\python\gras
s\pygrass\modules\interface\module.py", line 769, in run
    self.wait()
  File "C:\OSGEO4~1\apps\grass\grass-7.3.svn\etc\python\gras
s\pygrass\modules\interface\module.py", line 790, in wait
    module=self.name, errors=stderr)
grass.exceptions.CalledModuleError: Module run r.tileset
r.tileset sourceproj=+proj=lcc +lat_1=36.16666666666666
+lat_2=34.33333333333334 +lat_0=33.75 +lon_0=-79
+x_0=609601.22 +y_0=0 +no_defs +a=6378137 +rf=298.257222101
+towgs84=0.000,0.000,0.000 +to_meter=1 sourcescale=1
maxcols=1500 maxrows=1352 overlap=0 separator=pipe -g --q
ended with error
Process ended with non-zero return code 1. See errors in the
(error) output.
------

C:\>where cs2cs
C:\OSGeo4W64\bin\cs2cs.exe
C:\>cs2cs
Rel. 4.9.3, 15 August 2016
usage: cs2cs [ -eEfIlrstvwW [args] ] [ +opts[=arg] ]
                   [+to [+opts[=arg] [ files ]

cs2cs seems to be available.

-----
best regards
Helmut
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Inclusion-of-additional-files-with-add-on-tp5331342p5331497.html
Sent from the Grass - Dev mailing list archive at Nabble.com.

This seems to be an issue on windows that is related to r.tileset not r.terrain.texture. Infact on windows I can’t get r.tileset to function at all on a windows system, but it works on linux:

r.tileset sourceproj=“+proj=tmerc +lat_0=0 +lon_0=-115 +k=0.9992 +x_0=500000 +y_0=0 +no_defs +a=6378137 +rf=298.257222101 +towgs84=0.000,0.000,0.000 +to_meter=1”

Traceback (most recent call last):
File
“C:\OSGEO4~1\apps\grass\grass-7.3.svn/scripts/m.proj.py”,
line 308, in
main()
File
“C:\OSGEO4~1\apps\grass\grass-7.3.svn/scripts/m.proj.py”,
line 243, in main
inf = file(infile)
IOError: [Errno 13] Permission denied: ‘c:\users\cb2dd\ap
pdata\local\temp\grass7-cb2dd-10432\tmpovmbzm’
ERROR: cs2cs failed

···

On Tue, Aug 15, 2017 at 1:31 AM, Helmut Kudrnovsky <hellik@web.de> wrote:

I have gone with your’s and Moritz’s suggestion and have completed
r.terrain.texture with the Iwahashi >and Pike nested-means terrain
classification method in the add-ons.

addon tested here with

System Info
GRASS version: 7.3.svn
GRASS SVN revision: r71384
Build date: 2017-08-11
Build platform: x86_64-w64-mingw32
GDAL: 2.2.1
PROJ.4: 4.9.3
GEOS: 3.5.0
SQLite: 3.17.0
Python: 2.7.5
wxPython: 2.8.12.1
Platform: Windows-8-6.2.9200 (OSGeo4W)

and

r.terrain.texture elevation=elevation@PERMANENT slope=myslope@user1
classes=12 texture=terr_tex convexity=terr_convex concavity=terr_concav
features=terr_class

I get


r.terrain.texture elevation=elevation@PERMANENT slope=myslope@user1
classes=12 texture=terr_tex convexity=terr_convex concavity=terr_concav
features=terr_class
Calculating terrain surface texture…

  1. Smoothing input DEM with a 3x3 median filter…
  2. Extracting pits and peaks with difference > thres…
  3. Using resampling filter to create terrain texture…
  4. Converting to percentage…
    Calculating terrain convexity and concavity…
  5. Calculating terrain curvature using laplacian filter…
  6. Extracting convexities and concavities…
  7. Using resampling filter to create surface convexity/concavity…
  8. Converting to percentages…
    Performing terrain surface classification…
    Traceback (most recent call last):
    File
    “C:\OSGEO4~1\apps\grass\grass-7.3.svn/scripts/m.proj.py”,
    line 308, in
    main()
    File
    “C:\OSGEO4~1\apps\grass\grass-7.3.svn/scripts/m.proj.py”,
    line 243, in main
    inf = file(infile)
    IOError: [Errno 13] Permission denied: ‘c:\users\xxx\ap
    pdata\local\temp\grass7-hkmyr-6804\tmpl1pwdf’
    ERROR: cs2cs failed
    Deleting intermediate files…
    WARNING: No data base element files found
    Traceback (most recent call last):
    File “C:\Users\xxx\AppData\Roaming\GRASS7\addons/scripts
    /r.terrain.texture.py”, line 575, in
    sys.exit(main())
    File “C:\Users\xxx\AppData\Roaming\GRASS7\addons/scripts
    /r.terrain.texture.py”, line 471, in main
    flags=‘g’, quiet=True,
    stdout_=PIPE).outputs.stdout.split(os.linesep)[:-1]
    File “C:\OSGEO4~1\apps\grass\grass-7.3.svn\etc\python\gras
    s\pygrass\modules\interface\module.py”, line 648, in
    call
    return self.run()
    File “C:\OSGEO4~1\apps\grass\grass-7.3.svn\etc\python\gras
    s\pygrass\modules\interface\module.py”, line 769, in run
    self.wait()
    File “C:\OSGEO4~1\apps\grass\grass-7.3.svn\etc\python\gras
    s\pygrass\modules\interface\module.py”, line 790, in wait
    module=self.name, errors=stderr)
    grass.exceptions.CalledModuleError: Module run r.tileset
    r.tileset sourceproj=+proj=lcc +lat_1=36.16666666666666
    +lat_2=34.33333333333334 +lat_0=33.75 +lon_0=-79
    +x_0=609601.22 +y_0=0 +no_defs +a=6378137 +rf=298.257222101
    +towgs84=0.000,0.000,0.000 +to_meter=1 sourcescale=1
    maxcols=1500 maxrows=1352 overlap=0 separator=pipe -g --q
    ended with error
    Process ended with non-zero return code 1. See errors in the
    (error) output.

C:>where cs2cs
C:\OSGeo4W64\bin\cs2cs.exe
C:>cs2cs
Rel. 4.9.3, 15 August 2016
usage: cs2cs [ -eEfIlrstvwW [args] ] [ +opts[=arg] ]
[+to [+opts[=arg] [ files ]

cs2cs seems to be available.


best regards
Helmut

View this message in context: http://osgeo-org.1560.x6.nabble.com/Inclusion-of-additional-files-with-add-on-tp5331342p5331497.html
Sent from the Grass - Dev mailing list archive at Nabble.com.


grass-dev mailing list
grass-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-dev

stevenpawley wrote

This seems to be an issue on windows that is related to r.tileset not
r.terrain.texture. Infact on windows I can't get r.tileset to function at
all on a windows system, but it works on linux:

r.tileset sourceproj="+proj=tmerc +lat_0=0 +lon_0=-115 +k=0.9992
+x_0=500000 +y_0=0 +no_defs +a=6378137 +rf=298.257222101
+towgs84=0.000,0.000,0.000 +to_meter=1"

Traceback (most recent call last):
  File
"C:\OSGEO4~1\apps\grass\grass-7.3.svn/scripts/m.proj.py",
line 308, in
<module>
    main()
  File
"C:\OSGEO4~1\apps\grass\grass-7.3.svn/scripts/m.proj.py",
line 243, in main
    inf = file(infile)
IOError: [Errno 13] Permission denied: 'c:\\users\\cb2dd\\ap
pdata\\local\\temp\\grass7-cb2dd-10432\\tmpovmbzm'
ERROR: cs2cs failed

would you mind to open a bug report about r.tileset?

-----
best regards
Helmut
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Inclusion-of-additional-files-with-add-on-tp5331342p5331574.html
Sent from the Grass - Dev mailing list archive at Nabble.com.

On 16/08/17 00:48, Steven Pawley wrote:

This seems to be an issue on windows that is related to r.tileset not r.terrain.texture. Infact on windows I can't get r.tileset to function at all on a windows system, but it works on linux:

r.tileset sourceproj="+proj=tmerc +lat_0=0 +lon_0=-115 +k=0.9992 +x_0=500000 +y_0=0 +no_defs +a=6378137 +rf=298.257222101 +towgs84=0.000,0.000,0.000 +to_meter=1"

Traceback (most recent call last):
   File
"C:\OSGEO4~1\apps\grass\grass-7.3.svn/scripts/m.proj.py <http://m.proj.py>",
line 308, in <module>
     main()
   File
"C:\OSGEO4~1\apps\grass\grass-7.3.svn/scripts/m.proj.py <http://m.proj.py>",
line 243, in main
     inf = file(infile)
IOError: [Errno 13] Permission denied: 'c:\\users\\cb2dd\\ap
pdata\\local\\temp\\grass7-cb2dd-10432\\tmpovmbzm'
ERROR: cs2cs failed

IIUC, this means that the call to m.proj in r.tileset has failed:

Could someone try if m.proj works on Windows ?

Moritz

Moritz Lennert wrote

On 16/08/17 00:48, Steven Pawley wrote:

This seems to be an issue on windows that is related to r.tileset not
r.terrain.texture. Infact on windows I can't get r.tileset to function
at all on a windows system, but it works on linux:

r.tileset sourceproj="+proj=tmerc +lat_0=0 +lon_0=-115 +k=0.9992
+x_0=500000 +y_0=0 +no_defs +a=6378137 +rf=298.257222101
+towgs84=0.000,0.000,0.000 +to_meter=1"

Traceback (most recent call last):
   File
"C:\OSGEO4~1\apps\grass\grass-7.3.svn/scripts/m.proj.py
&lt;http://m.proj.py&gt;",
line 308, in

<module>

     main()
   File
"C:\OSGEO4~1\apps\grass\grass-7.3.svn/scripts/m.proj.py
&lt;http://m.proj.py&gt;",
line 243, in main
     inf = file(infile)
IOError: [Errno 13] Permission denied: 'c:\\users\\cb2dd\\ap
pdata\\local\\temp\\grass7-cb2dd-10432\\tmpovmbzm'
ERROR: cs2cs failed

IIUC, this means that the call to m.proj in r.tileset has failed:

Could someone try if m.proj works on Windows ?

C:\>v.out.ascii bridges | m.proj -o input=-

and

m.proj -o input=D:\wd\testepsg\coor.txt
81d37'10.19915"W|36d35'10.7323"N|1.000
81d37'47.06273"W|36d35'1.19866"N|2.000
81d33'45.90899"W|36d34'47.26688"N|3.000

works here with

System Info
GRASS version: 7.3.svn
GRASS SVN revision: r71384
Build date: 2017-08-11
Build platform: x86_64-w64-mingw32
GDAL: 2.2.1
PROJ.4: 4.9.3
GEOS: 3.5.0
SQLite: 3.17.0
Python: 2.7.5
wxPython: 2.8.12.1
Platform: Windows-8-6.2.9200 (OSGeo4W)

IOError: [Errno 13] Permission denied: 'c:\\users\\cb2dd\\ap
pdata\\local\\temp\\grass7-cb2dd-10432\\tmpovmbzm'

maybe there is some issue with the temporary file as input for cs2cs, but I
can't find where ...

-----
best regards
Helmut
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Inclusion-of-additional-files-with-add-on-tp5331342p5331585.html
Sent from the Grass - Dev mailing list archive at Nabble.com.

I'll open a ticket for r.tileset.

Sent from my iPhone

On Aug 16, 2017, at 2:36 AM, Helmut Kudrnovsky <hellik@web.de> wrote:

Moritz Lennert wrote

On 16/08/17 00:48, Steven Pawley wrote:
This seems to be an issue on windows that is related to r.tileset not
r.terrain.texture. Infact on windows I can't get r.tileset to function
at all on a windows system, but it works on linux:

r.tileset sourceproj="+proj=tmerc +lat_0=0 +lon_0=-115 +k=0.9992
+x_0=500000 +y_0=0 +no_defs +a=6378137 +rf=298.257222101
+towgs84=0.000,0.000,0.000 +to_meter=1"

Traceback (most recent call last):
  File
"C:\OSGEO4~1\apps\grass\grass-7.3.svn/scripts/m.proj.py
&lt;http://m.proj.py&gt;",
line 308, in

<module>

    main()
  File
"C:\OSGEO4~1\apps\grass\grass-7.3.svn/scripts/m.proj.py
&lt;http://m.proj.py&gt;",
line 243, in main
    inf = file(infile)
IOError: [Errno 13] Permission denied: 'c:\\users\\cb2dd\\ap
pdata\\local\\temp\\grass7-cb2dd-10432\\tmpovmbzm'
ERROR: cs2cs failed

IIUC, this means that the call to m.proj in r.tileset has failed:

Could someone try if m.proj works on Windows ?

C:\>v.out.ascii bridges | m.proj -o input=-

and

m.proj -o input=D:\wd\testepsg\coor.txt
81d37'10.19915"W|36d35'10.7323"N|1.000
81d37'47.06273"W|36d35'1.19866"N|2.000
81d33'45.90899"W|36d34'47.26688"N|3.000

works here with

System Info
GRASS version: 7.3.svn
GRASS SVN revision: r71384
Build date: 2017-08-11
Build platform: x86_64-w64-mingw32
GDAL: 2.2.1
PROJ.4: 4.9.3
GEOS: 3.5.0
SQLite: 3.17.0
Python: 2.7.5
wxPython: 2.8.12.1
Platform: Windows-8-6.2.9200 (OSGeo4W)

IOError: [Errno 13] Permission denied: 'c:\\users\\cb2dd\\ap
pdata\\local\\temp\\grass7-cb2dd-10432\\tmpovmbzm'

maybe there is some issue with the temporary file as input for cs2cs, but I
can't find where ...

-----
best regards
Helmut
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Inclusion-of-additional-files-with-add-on-tp5331342p5331585.html
Sent from the Grass - Dev mailing list archive at Nabble.com.
_______________________________________________
grass-dev mailing list
grass-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-dev