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

Freddy López freddy.vate01 at gmail.com
Thu Jun 16 14:43:42 CEST 2011


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/.

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



More information about the R-sig-Geo mailing list