Coder Social home page Coder Social logo

Comments (10)

newcomb-d avatar newcomb-d commented on July 18, 2024

Upon further investigation, it was noted that rgeos was not loaded,
Checking rgeos availability: FALSE
Note: when rgeos is not available, polygon geometry computations in maptools depend on gpclib,
which has a restricted licence. It is disabled by default;
to enable gpclib, type gpclibPermit()
and the reason that the raster module was failing was that the sp libary sp() was not being used.
When line 236 if the script was modified from :
libs = ['GWmodel', 'data.table', 'rgrass7', 'rgdal', 'raster']
to:
libs = ['GWmodel', 'data.table', 'sp', 'rgeos', 'rgrass7', 'rgdal', 'raster']
and the following line was added after line 248
r_file.write('use_sp()\n')

The script was then able to get past this error. However, in line 293
predict = g.read_command("g.tempfile", pid=os.getpid()).strip() + '.txt'
a temporary file is written to hold the results of the GWR analysis.
On windows, this leads to a filename like this:
D:\grass\lake\u18wgs84\bathy.tmp/unknown\13752.5.txt , which throws an escape character error in R on windows.
This was worked around by setting a static filename in the directory that the script is run from:
predict="tempgwr.txt"
While this works for a desktop user and makes things os-independent, it requires the user have write access to the directory the script is running in.
It might be better to set the filename with a suffix more dynamically from the os.getpid process for a result like tempgwr13725.txt in more dynamic settings.

from grass-addons.

neteler avatar neteler commented on July 18, 2024

Please consider to edit the Python script directly here and submit the changes as a pull request:
https://github.com/OSGeo/grass-addons/blob/master/grass7/imagery/i.image.bathymetry/i.image.bathymetry.py

from grass-addons.

newcomb-d avatar newcomb-d commented on July 18, 2024

from grass-addons.

tmszi avatar tmszi commented on July 18, 2024

The script was then able to get past this error. However, in line 293
predict = g.read_command("g.tempfile", pid=os.getpid()).strip() + '.txt'
a temporary file is written to hold the results of the GWR analysis.
On windows, this leads to a filename like this:
D:\grass\lake\u18wgs84\bathy.tmp/unknown\13752.5.txt , which throws an escape character error in R on windows.

This is bug in the G__temp_element() function (line 121).

from grass-addons.

neteler avatar neteler commented on July 18, 2024

On windows, this leads to a filename like this:
D:\grass\lake\u18wgs84\bathy.tmp/unknown\13752.5.txt , which throws an escape character error in R on windows.

This is bug in the G__temp_element() function (line 121).

Probably G_convert_dirseps_to_host() is missing? See
https://grass.osgeo.org/programming7/paths_8c.html#a0bd23f09c109997ed8ddc25c5d650698

from grass-addons.

tmszi avatar tmszi commented on July 18, 2024

On windows, this leads to a filename like this:
D:\grass\lake\u18wgs84\bathy.tmp/unknown\13752.5.txt , which throws an escape character error in R on windows.

This is bug in the G__temp_element() function (line 121).

Probably G_convert_dirseps_to_host() is missing? See
https://grass.osgeo.org/programming7/paths_8c.html#a0bd23f09c109997ed8ddc25c5d650698

Yes you are right or use HOST_DIRSEP.

Yesterday I prepared patch (need test on MS Win), but I have trouble with Cross-Compilation (environment) GRASS GIS for Windows OS on GNU/Linux. Otherwise I would have opened a new PR.

from grass-addons.

neteler avatar neteler commented on July 18, 2024

Right, HOST_DIRSEP is widely used in GRASS-core.

from grass-addons.

neteler avatar neteler commented on July 18, 2024

Yes you are right or use HOST_DIRSEP.

Yesterday I prepared patch (need test on MS Win), but I have trouble with Cross-Compilation (environment) GRASS GIS for Windows OS on GNU/Linux. Otherwise I would have opened a new PR.

While checking the entire core source code I found, besides lib/gis/tempfile.c two more files in which HOST_DIRSEP seems to be missing (unrelated but like worth to also fix in the same PR):

  • lib/display/r_raster.c (2 times)
  • display/d.mon/list.c (4 times)

from grass-addons.

wenzeslaus avatar wenzeslaus commented on July 18, 2024

Isn't the issue more that the backslash is used rather than missing? If the error is about "an escape character" in R on Windows, that suggests that the backslashes in path are not escaped or that the string in generated R code (is there some in this case?) needs to be raw. It seems to me then that if you want to change it in grass core, you need to remove the backslashes from path rather than adding more of them and use forward slashes instead.

The question also is if g.tempfile is the right tool. Is the file huge or copied to mapset non-temporary directories? If not, standard Python temporary directory object used with a with statement and a hardcoded file name might be a better option.

from grass-addons.

newcomb-d avatar newcomb-d commented on July 18, 2024

I just noticed a similar error for r.in.wms for 7.8.7 on Windows.

from grass-addons.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.