r-spatial / link2GI

Simplify the linking of GIS/RS and CLI tools
https://r-spatial.github.io/link2GI
GNU General Public License v3.0
25 stars 8 forks source link

osgeo4w's grass-7.2.0 cannot be found #2

Closed jannes-m closed 6 years ago

jannes-m commented 7 years ago

Thank you for developing the link2GI package! I am trying to use rgrass7 in combination with GRASS7 installed by OSGEO4W (QGIS). link2GI can locate my GRASS installations:

library("link2GI")
searchGRASSW()

searching for GRASS installations - this may take a while
For providing the path manually see ?searchGRASSW 
                                   instDir         version installation_type
1                            C:\\OSGeo4W64     grass-6.4.3           osgeo4W
2                            C:\\OSGeo4W64     grass-7.2.0           osgeo4W
3                            C:\\OSGeo4W64   grass-7.3.svn           osgeo4W
4 C:\\Program Files (x86)\\GRASS GIS 6.4.4 GRASS GIS 6.4.4              NSIS

However, if I try to run linkGRASS7, I run into following error message:

data("meuse", package = "sp")
linkGRASS7(meuse, c("C:\\OSGeo4W64", "grass-7.2.0", "ossgeo4w"))
Error in rgrass7::initGRASS(gisBase = gisbase_GRASS, home = tmpDir(),  : 
### rgrass7 is not compatible with the GRASS GIS version 'GRASS 6.4.3 (2013) '!
### Please use the package appropriate to the GRASS GIS version:
### GRASS GIS Version 5.x.y  --  GRASS
### GRASS GIS Version 6.x.y  --  spgrass6
### GRASS GIS Version 7.x.y  --  rgrass7

Do you have any idea why link2GI tells me to use GRASS6, i.e. why it is not able to use GRASS7 installed by OSGEO4W?

All the best,

Jannes

jannes-m commented 7 years ago

sorry, my mistake, writing it the correct way helps -:):

library("link2GI")
library("sp")
data(meuse) 
coordinates(meuse) <- ~x+y 
proj4string(meuse) <-CRS("+init=epsg:28992")     
linkGRASS7(meuse, c("C:/OSGeo4W64","grass-7.2.0","osgeo4W"))

Perfect, this works but still results in this strange error message:

               -={ OSGeo4W Shell Commands }=-
  Syntaxfehler.

Do you have any idea what that means? If we can ignore it safely, maybe suppressing the error message would be an option. Using double backslahes the error message becomes larger:

linkGRASS7(meuse, c("C:\\OSGeo4W64","grass-7.2.0","osgeo4W"))

               -={ OSGeo4W Shell Commands }=-
Syntaxfehler.
Der Befehl "find" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.

And not specifying anything at all, produces the error message mentioned in the first comment:

linkGRASS7(meuse)

searching for GRASS installations - this may take a while
For providing the path manually see ?searchGRASSW 
                   -={ OSGeo4W Shell Commands }=-
Der Befehl "find" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
Error in rgrass7::initGRASS(gisBase = gisbase_GRASS, home = tmpDir(),  : 
 ### rgrass7 is not compatible with the GRASS GIS version 'GRASS 6.4.3 (2013) '!
 ### Please use the package appropriate to the GRASS GIS version:
 ### GRASS GIS Version 5.x.y  --  GRASS
 ### GRASS GIS Version 6.x.y  --  spgrass6
 ### GRASS GIS Version 7.x.y  --  rgrass7
 In addition: Warning message:
 running command 'C:\OSGeo4W64/bin/o-help.bat' had status 255 

Is this because of the OSGeo4W-installation of GRASS? That is, do I always have to specify the arguments of linkGRASS7 manually when working with OSGeo4W?

In any case, I really like that using link2GI I can finally make use of GRASS coming with the OSGeo4W-installation instead of having to install it again in another location!

gisma commented 7 years ago

Hi Jannis, have to apologize because I just forget to answer at once because I was kind of busy and now I am on Sardinia without both a working Windows system and programming on my mind ;-) I will check it tonight but without looking at the code I assume an mistake while checking the OS. The find command should be used on Linux only I have to check why it is used on a Windows system. cheers Chris

gisma commented 7 years ago

Update:

according to the second error message assume a bug because am I am not really handling the parallel installation of both GRASS-6.x and GRASS-7. The find error message probably is a result of calling the common osgeo4w batch file . I will check...

cheers Chris

keltoskytoi commented 7 years ago

Hi Jannes, I am also trying to bind in Grass 7.2 in R with Link2GI and I got the same warning message. I think that it has to do with the Installation of Grass and QGIS through OSGEO. Did you install the QGIS versions manually? I wanted to use QGIS 2.14 and GRASS 7.2 and install "some" RGDAL and OTB dependencies too, but I ended up with two GRASS versions (GRASS 6.x and GRASS 7.x) and R/Link2GI always tried to use Grass 6.x version. So I deinstalled OSGEO and reinstalled the Programs and versions in various combinations, but in the end I found that I had to surrender to use the fast installation resulting in QGIS 2.18, because then there is only GRASS7.2 installed through OSGEO.

This way if you call:

linkGRASS7(Duenns1, c("C:/OSGeo4W64", "grass-7.2.0", "osgeo4W")) -={ OSGeo4W Shell Commands }=- Syntaxfehler. GDAL 2.1.3, released 2017/20/01 gisdbase C:/Users/KELTOS~1/AppData/Local/Temp/RtmpkHclAD location file3b383ce566b2 mapset PERMANENT rows 5001 columns 5001 north 5610001 south 5605000 west 464999.5 east 470000.5 nsres 1 ewres 1 projection +proj=utm +no_defs +zone=32 +a=6378137 +rf=298.257223563 +towgs84=0.000,0.000,0.000 +to_meter=1

BUT:

If you call:

linkGRASS7(Duenns1, c("C:\OSGeo4W64", "grass-7.2.0", "osgeo4W")) -={ OSGeo4W Shell Commands }=-

   assistant              ogrinfo
   avcexport              ogrlineref
   avcimport              ogrtindex
   bmp2tiff               osgeo4w-setup
   cs2cs                  pal2rgb
   curl                   pixeltool
   designer               ppm2tiff
   dllupdate              proj
   example1               psql
   example2               pylupdate4
   fax2ps                 pyrcc4
   fax2tiff               python
   fftw-wisdom            pythonw
   gdaladdo               qcatool
   gdalbuildvrt           qcollectiongenerator
   gdaldem                qdoc3
   gdalenhance            qgis-bin
   gdalinfo               qgis-browser-bin
   gdallocationinfo       qhelpconverter
   gdalmanage             qhelpgenerator
   gdalserver             qmake
   gdalsrsinfo            qmlplugindump
   gdaltindex             qmlviewer
   gdaltransform          qt3to4
   gdalwarp               qttracereplay
   gdal_contour           ras2tiff
   gdal_grid              raw2tiff
   gdal_rasterize         rcc
   gdal_translate         rgb2ycbcr
   geod                   rpcgen
   geotifcp               sip
   gif2tiff               testepsg
   gltpd                  textreplace
   gpsbabel               thumbnail
   gswin32c               tiff2bw
   idc                    tiff2pdf
   las2las                tiff2ps
   las2ogr                tiff2rgba
   las2txt                tiffcmp
   lasblock               tiffcp
   lasinfo                tiffcrop
   lconvert               tiffdither
   linguist               tiffdump
   listgeo                tiffinfo
   lrelease               tiffmedian
   lupdate                tiffset
   moc                    tiffsplit
   mozcerts               ts2las
   nad2bin                txt2las
   nccopy                 uic
   ncdump                 uic3
   ncgen                  xmlcatalog
   ncgen3                 xmllint
   nearblack              xmlpatterns
   nircmd                 xmlpatternsvalidator
   nircmdc                xmlwf
   ogdi_import            xxmklink
   ogdi_info              
   ogr2ogr                

 epsg_tr               gdal_pansharpen       ps2pdf14
   esri2wkt              gdal_polygonize       ps2pdfxx
   gcps2vec              gdal_proximity        python-qgis
   gcps2wld              gdal_retile           pyuic4
   gdal2tiles            gdal_sieve            qgis-browser-grass7
   gdal2xyz              grass72               qgis-browser
   gdalchksum            gssetgs               qgis-designer
   gdalcompare           liblas                qgis-grass7
   gdalident             make-bat-for-py       qgis
   gdalimport            mkgraticule           rgb2pct
   gdalmove              o-help                saga-ltr_gui
   gdal_auth             o4w_env               setup-test
   gdal_calc             pct2rgb               setup
   gdal_edit             ps2pdf                
   gdal_fillnodata       ps2pdf12              
   gdal_merge            ps2pdf13              

GDAL 2.1.3, released 2017/20/01 gisdbase C:/Users/KELTOS~1/AppData/Local/Temp/RtmpkHclAD location file3b386c604655 mapset PERMANENT rows 5001 columns 5001 north 5610001 south 5605000 west 464999.5 east 470000.5 nsres 1 ewres 1 projection +proj=utm +no_defs +zone=32 +a=6378137 +rf=298.257223563 +towgs84=0.000,0.000,0.000 +to_meter=1

there seems to be no syntax error. And it seems to work now :)

Summa summarum: you should check how you installed the GI programmes through OSGEO and which one or which version relies on GRASS 6.x and not install that one.

Best wishes, Agnes

gisma commented 7 years ago

Thanks for both of yours contributions. The addressed errors and problems are caused by some inconsistencies in the program. Actually it is pretty simple to explain and a bit more expensive to fix. I did not think about the situation that anybody would have installed all possible GRASS versions via OSGeo4W within the same root directory. @jannes-m so the error message

rgrass7 is not compatible with the GRASS GIS version 'GRASS 6.4.3 (2013) '!

is a result of the missing check if different versions of GRASS are found in the same root directory and it takes the first version found in this directory. Unfortunately this is a GRASS-6.x version but up to now only GRASS 7 is fully supported...

@keltoskytoi you are right I have to polish the handling of the backslashes ;-) .

I will fix this bugs asap. Up to this you can use only one osgeo4w version GRASS -7.x at a time.

cheers Chris