[R-sig-Geo] Reading vector data from GRASS GIS.-

Freddy López freddy.vate01 at gmail.com
Thu Jun 16 18:23:59 CEST 2011


> you have to be in the location and mapset where the vector is you want to read. In your case location=venest3, mapset=PERMANENT. Then start R, then
> library(spgrass6)
> readVECT6("yourvector")


Thank you Tom, but it is what is not working. I'm of course in
venest3/PERMANENT but readVECT6() does not read the vector.

I will suppose is a file or data problem because it works for example
North Carolina and spearfish60 mapsets and I'm following the same
steps with venest3.

Cheers.

On Thu, Jun 16, 2011 at 11:23, Gottfried, Tom <tom.gottfried at tum.de> wrote:
> Hi,
>
> you have to be in the location and mapset where the vector is you want to read. In your case location=venest3, mapset=PERMANENT. Then start R, then
> library(spgrass6)
> readVECT6("yourvector")
>
> regards,
> Tom
> ________________________________________
> Von: Freddy López [freddy.vate01 at gmail.com]
> Gesendet: Donnerstag, 16. Juni 2011 14:44
> Bis: r-sig-geo at r-project.org
> Cc: Gottfried, Tom
> Betreff: Re: [R-sig-Geo] Reading vector data from GRASS GIS.-
>
> Dear Tom,
>
> Excuse me for the misuse of terms. I create a new location with a
> shapefile (using v.in.ogr) and it creates automatically a mapset (am I
> wrong?) in /home/vate01/grassdata/venest3/PERMANENT/vector/.
>
> Just to be nasty: PERMANENT is the (default) mapset.
>
> When I use the same steps with example datasets, this time North
> Carolina data, I get:
>
> # once inside gisdemo_ncspm location, I run R and...
>> library(spgrass6)
> Loading required package: sp
> Loading required package: rgdal
> Geospatial Data Abstraction Library extensions to R successfully loaded
> Loaded GDAL runtime: GDAL 1.8.0, released 2011/01/12
> Path to GDAL shared files: /usr/share/gdal/1.8
> Loaded PROJ.4 runtime: Rel. 4.7.1, 23 September 2009
> Path to PROJ.4 shared files: (autodetected)
> Loading required package: XML
> GRASS GIS interface loaded with GRASS version: 6.4.1
> and location: gisdemo_ncspm
>
> # one test...
>> plot(readVECT6('geology'))
> OGR data source with driver: GRASS
> Source: "/home/vate01/grassdata/gisdemo_ncspm/PERMANENT/vector/geology/head",
> layer: "1"
> with 1832 features and 8 fields
> Feature type: wkbPolygon with 2 dimensions
>
> # another test...
>> plot(readVECT6('firestations'))
> OGR data source with driver: GRASS
> Source: "/home/vate01/grassdata/gisdemo_ncspm/PERMANENT/vector/firestations/head",
> layer: "1"
> with 71 features and 22 fields
> Feature type: wkbPoint with 2 dimensions
>
> #  idem...
>> plot(readVECT6('elev_points'))
> OGR data source with driver: GRASS
> Source: "/home/vate01/grassdata/gisdemo_ncspm/PERMANENT/vector/elev_points/head",
> layer: "1"
> with 6000 features and 2 fields
> Feature type: wkbPoint with 2 dimensions
>
> Beautiful maps; but following the same steps with venest3, it reports
> the message
>
> Error en ogrInfo(dsn = dsn, layer = layer, input_field_name_encoding =
> input_field_name_encoding) :
>  Cannot open layer
>
> Additionally, when I use readShapePoly() function (with the original
> shapefile) there are no problems. I can plot the map perfectly
> (indeed, I have used this shape several times from either R or GRASS
> but never working one from another).
>
> Thanks for your attention.
>
> Cheers.
>
>
> On Thu, Jun 16, 2011 at 02:01, Tom Gottfried <tom.gottfried at tum.de> wrote:
>> Hi Freddy,
>>
>> if, as you have written, venest3 is a location, then you can't read it as
>> vector. You have to create a mapset in your location and a vector dataset in
>> the mapset. Then you can read the vector dataset.
>>
>> regards,
>> Tom
>>
>> Am 16.06.2011 04:36, schrieb Freddy López:
>>>
>>> Hello guys,
>>>
>>> I think this question is in the border: r-sig-geo or grass-user list...
>>>
>>> I want to do some interpolation using GRASS' graphical features but
>>> using code and libraries written in R and I'm trying to follow section
>>> 10.2.1 from 3rd edition GRASS BOOK (Open Source GIS: A GRASS GIS
>>> Approach).
>>>
>>> I create a location into GRASS, venest3, apparently with no problem
>>> and I can plot it using d.vect.
>>>
>>> After starting R and run the readVECT6 function I get
>>>
>>>> readVECT6('venest3')
>>>
>>> Error en ogrInfo(dsn = dsn, layer = layer, input_field_name_encoding =
>>> input_field_name_encoding) :
>>>  Cannot open layer
>>>
>>> I have experimented using the spearfish60 file and it works perfectly
>>> (I selected randomly geology...):
>>>
>>>> readVECT6('geology'))
>>>
>>> OGR data source with driver: GRASS
>>> Source:
>>> "/home/vate01/grassdata/spearfish60/PERMANENT/vector/geology/head",
>>> layer: "1"
>>> with 422 features and 2 fields
>>> Feature type: wkbPolygon with 2 dimensions
>>> ...
>>>
>>>
>>> Both locations (venest3 and spearfish60), inside its 'vector'
>>> directory have the same six files: cidx, coor, dbln, head, hist, topo.
>>>
>>> Have you any ideas how can I solve this situation? How to read my vector
>>> data?
>>>
>>> Thanks in advance.-
>>>
>>>
>>> --
>>> «But Gwindor answered: 'The doom lies in yourself, not in your name.'»
>>>
>>> JRR Tolkien
>>>
>>> _______________________________________________
>>> R-sig-Geo mailing list
>>> R-sig-Geo at r-project.org
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>> --
>> Technische Universität München
>> Department für Pflanzenwissenschaften
>> Lehrstuhl für Grünlandlehre
>> Alte Akademie 12
>> 85350 Freising / Germany
>> Phone: ++49 (0)8161 715324
>> Fax:   ++49 (0)8161 713243
>> email: tom.gottfried at wzw.tum.de
>> http://www.wzw.tum.de/gruenland
>>
>
>
>
> --
> «But Gwindor answered: 'The doom lies in yourself, not in your name.'»
>
> JRR Tolkien



-- 
«But Gwindor answered: 'The doom lies in yourself, not in your name.'»

JRR Tolkien



More information about the R-sig-Geo mailing list