[R-sig-Geo] rgdal and grass rasters
Roger Bivand
Roger.Bivand at nhh.no
Tue Mar 2 20:46:03 CET 2010
On Mon, 1 Mar 2010, Jonathan Greenberg wrote:
> As far as sample code goes, simply getting
> grass_to_raster=raster("somegrassfile") is my goal -- my understanding
> is anything rgdal can read, raster can read. Running your command I
> do get:
>
> GRASS (ro): GRASS Database Rasters (5.7+)
>
> But with rgdal:
>
> require(rgdal)
> gdaldrivers=getGDALDriverNames()
> gdaldrivers$create[gdaldrivers$name=="GRASS"]
> [1] FALSE
> gdaldrivers$copy[gdaldrivers$name=="GRASS"]
> [1] FALSE
> gdaldrivers$create[gdaldrivers$name=="GTiff"]
> [1] TRUE
> gdaldrivers$copy[gdaldrivers$name=="GTiff"]
> [1] TRUE
>
> Am I perhaps missing an rgdal installation flag that is required to
> enable GRASS rasters?
Unless rgdal was built against and is seeing a different GDAL, there is no
good reason. gdalDrivers() will list all the drivers that the GDAL rgdal
is using sees. However, beware of the plugin, which is notorious for
refering to stale GRASS binaries, and for its choice of exporting the
whole raster with its original resolution, which most often is not the
same as the output of g.region.
To mimic raster, you would use g.region to set the tile size and shape
before using readRAST6() with a temporary file. This could be automated
too, I think.
Hope this helps,
Roger
>
> --j
>
> On Mon, Mar 1, 2010 at 6:04 PM, Dylan Beaudette
> <dylan.beaudette at gmail.com> wrote:
>> Roger can likely point out the problem after some example code is
>> posted. In the mean time I would suggest checking to make sure your
>> GDAL is compiled _without_ GRASS support, and that the GDAL GRASS
>> plugin is correctly installed.
>>
>> This is how I check on my machine:
>>
>> gdal_translate --formats | grep -i grass
>> GRASS (ro): GRASS Database Rasters (5.7+)
>>
>> Cheers,
>> Dylan
>>
>> On Mon, Mar 1, 2010 at 5:44 PM, Alex Mandel <tech_dev at wildintellect.com> wrote:
>>> spgrass6 is a an R package and has read/write access to GRASS datasets.
>>> It's usage would be instead of rgdal(well sorta, rgdal is required by
>>> spgrass6). Both write objects to sp types.
>>> You can use it from within R to start a GRASS session or within GRASS to
>>> start a linked R session.
>>> http://cran.r-project.org/web/packages/spgrass6/index.html
>>>
>>> I got GDALinfo to work on my machine, I wonder if your just missing the
>>> gdal-grass library, or libgrass.
>>>
>>> On ubuntu it's something like libgdal1-1.6.0-grass
>>> I know qgis needs this to work with GRASS not sure about gdal itself but
>>> based on http://gdal.org/frmt_grass.html probably. Also note that page
>>> talks about the path to a dataset that should be used.
>>>
>>>
>>> Thanks,
>>> Alex
>>>
>>>> Hmm, I'm trying to use the raster package via rgdal to access these
>>>> files -- I'm trying to avoid having to export then to another format
>>>> (I'm dealing with gigabytes of rasters), although I suppose I could do
>>>> this. Does spgrass6 "enable" rgdal to access GRASS rasters, or is it
>>>> its own standalone program? How does the base gdal package work with
>>>> grass rasters?
>>>>
>>>> --j
>>>>
>>>> On Mon, Mar 1, 2010 at 2:35 PM, Sarah Goslee <sarah.goslee at gmail.com> wrote:
>>>>> I think you need to export it from grass first, with r.out.gdal
>>>>>
>>>>> Or you can use spgrass6 to work with R and GRASS directly.
>>>>>
>>>>> Sarah
>>>>>
>>>>> On Mon, Mar 1, 2010 at 5:17 PM, Jonathan Greenberg
>>>>> <greenberg at ucdavis.edu> wrote:
>>>>>> Folks: when trying to import or GDALinfo a grass raster, where,
>>>>>> exactly, should I be pointing to in the grass directory? I tried
>>>>>> pointing to the file with the same name as the raster I want to work
>>>>>> with in the fcell, cellhd, and cell directories
>>>>>> (grass/location/mapset), but none of these are working... thanks!
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Sarah Goslee
>>>>> http://www.functionaldiversity.org
>>>>>
>>>>
>>>> _______________________________________________
>>>> R-sig-Geo mailing list
>>>> R-sig-Geo at stat.math.ethz.ch
>>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>>
>>> _______________________________________________
>>> R-sig-Geo mailing list
>>> R-sig-Geo at stat.math.ethz.ch
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>>
>>
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no
More information about the R-sig-Geo
mailing list