New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
readRAST
and writeRAST
support for raster
and terra
#42
Comments
Indeed, dplyr etc. are completely irrelevant, and should be avoided, as should non-native pipes, because they may create extra copies of large objects. For now, simply coerce and ask terra to provide a method from Support for terra might be provided if someone conntributes a full PR, for example using terra to read the temporary file written as part of It is more likely that support for stars will emerge, but both really need a proxy approach, leaving the data in GRASS without bringing it into the R workspace. However, the GDAL plugin driver for GRASS is not under active maintenance. For this reason there are no specific plans now. |
Thanks, @rsbivand . I'll raise an issue at the |
Yes, but all are welcome to contribute code. I am retired, and will cease supporting this package soon. Contribute a PR, please. Consider such contributions as a reasonable charge on your time. |
Do you refer to the temporary file that is produced with
And according to the GRASS manual that creates a flat binary with hdr and world files. Surely raster/terra/stars can read that file? |
Currently read by Lines 283 to 288 in c10d347
So not simple to unpick, someone should contribute a back-end perhaps within Since |
Could I wondered if
I first updated the package from CRAN, and then from github, and in both cases I get:
|
Either |
Ay, sorry, missed that after the update! Now getting this error again:
|
Yes, seeing the same here:
so
|
This works - the problem was that GRASS locations must have a defined CRS, but
|
Thanks very much and apologies for stumbling over these novice issues. I see that I added an argument This appears to work fine for this example, insofar that I get the same result as with
|
I just pushed some edits to
Yes, it should be possible to return the temporary file name as you suggest for numerical layers. A lot of the extra code is special casing systems with odd paths, like cygwin, added years ago when it was commonly used. However, I think that:
is simpler and more idiomatic - the user would have to choose |
I probably also should look at whether GRASS 8 supports the instantiation of a location from a file name, rather than needing to read it into R first. |
Applying the same changes to the "rgrass7" branch (rhijmans@96f9d58), and using your code (except for the GRASS path), I now get
So, it seems that the filename method works, but that there is still something else that goes wrong because the BIL file only has a single cell. |
I haven't checked, but |
The files are there, I took care of that so in that sense it "works". But note that the SGDF is the same. It only has once grid cell and that is not correct. |
GRASS will export rasters with the resolution and extent of the computational region. When you create a new location, say a latlon one with EPSG 4326, the default region will be of one cell (one degree, which is the unit of the CRS). If it were a metric CRS, the one cell would be one meter. To get from GRASS the same raster that you imported into it, you need to set the computational region to the extent and res of your raster first: HTH :) |
Thanks @veroandreo, now I got it to work:
By having |
Yes but not at all is this simple. Rasters with category labels are harder than numeric rasters, so any implementation has to handle them. The
is correct, and the original implementation is wrong. I can't read this *.grd correctly with This also works:
with the raster-native format, but with slightly changed flags. It would be interesting to see whether the |
RRASTER could be an option, I think. But If using |
I'll try to push a branch tomorrow with a skeleton implementation for GRASS to R. So far SpatRaster is well-behaved wrt. to cats, based on RRASTER and the RAT representation. I use the GRASS nc basic location for finding corner cases. |
The
Comments please @bniebuhr ! For now use |
And
|
rgrass7_0.2-8 submitted to CRAN. |
rgrass7_0.2-8 on CRAN. |
@rsbivand , that is fantastic! I followed the discussion in PR #45, but just to make sure if I understand. Now using |
I do not think use_sp() is needed. However, this is a process, so maybe wating for reactions to changes so far is fair to legacy users. |
Really fair, indeed! |
Hi,
Is there any plan to support reading and writing rasters to/from R using the
raster
andterra
packages?For instance, if I have to read a raster from GRASS GIS and I want to use
terra
within R, so far I need the following:Even though I could drop the use of
dplyr
here, that is quite some code for a simple reading command.Any support in this direction would be a super nice feature!
The text was updated successfully, but these errors were encountered: