Mapset issue with vector data via OGR plugin

5 messages Options
Embed this post
Permalink
Markus Neteler

Mapset issue with vector data via OGR plugin

Reply Threaded More More options
Print post
Permalink
Hi,

I have some troubles when the vector map name contains the
@mapset part:


R
R version 2.9.1 (2009-06-26)
...
> library(spgrass6)
Loading required package: sp
Loading required package: rgdal
Geospatial Data Abstraction Library extensions to R successfully loaded
Loaded GDAL runtime: GDAL 1.7.0dev, released 2008/11/26
Path to GDAL shared files: /usr/local/share/gdal
Loaded PROJ.4 runtime: Rel. 4.6.1, 21 August 2008
Path to PROJ.4 shared files: (autodetected)
Loading required package: XML

> data <- readVECT6("rand5k_elev_filt@neteler", type= 'point')
Error in ogrInfo(dsn = dsn, layer = layer, input_field_name_encoding =
input_field_name_encoding) :
  Cannot open file

while this works:

> data <- readVECT6("rand5k_elev_filt", type= 'point')
OGR data source with driver: GRASS
Source: "/home/neteler/grassdata/spearfish60/neteler/vector/rand5k_elev_filt/head",
layer: "1"
with 4885 features and 5 fields
Feature type: wkbPoint with 2 dimensions

I have used update.packages() and should have the latest sp* packages.
I tried to debug the problem but failed...

Can anyone confirm this problem?

thanks
Markus
_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Roger Bivand

Re: Mapset issue with vector data via OGR plugin

Reply Threaded More More options
Print post
Permalink
On Fri, 14 Aug 2009, Markus Neteler wrote:

> Hi,
>
> I have some troubles when the vector map name contains the
> @mapset part:
>

Hi,

This is a consequence of the plugin only searching in the current user's
mapset, so using extra code to scan other mapsets:

         if (is.null(mapset)) mapset <- .g_findfile(vname[1], type="vector")
         dsn <- paste(gg$GISDBASE, gg$LOCATION_NAME, mapset,
             "vector", vname, "head", sep="/")

where .g_findfile() runs g.findfile. This seems to fail when @mapset is
given. I guess that the work-around is to use the argument
mapset="neteler" in readVECT6() and readRAST6() for now, but I could look
at trying to detect the @ and use it (in the plugin case only) to assign
to a null mapset, throwing an error if mapset is non-null and @ is used.

Hope this helps,

Roger

>
> R
> R version 2.9.1 (2009-06-26)
> ...
>> library(spgrass6)
> Loading required package: sp
> Loading required package: rgdal
> Geospatial Data Abstraction Library extensions to R successfully loaded
> Loaded GDAL runtime: GDAL 1.7.0dev, released 2008/11/26
> Path to GDAL shared files: /usr/local/share/gdal
> Loaded PROJ.4 runtime: Rel. 4.6.1, 21 August 2008
> Path to PROJ.4 shared files: (autodetected)
> Loading required package: XML
>
>> data <- readVECT6("rand5k_elev_filt@neteler", type= 'point')
> Error in ogrInfo(dsn = dsn, layer = layer, input_field_name_encoding =
> input_field_name_encoding) :
>  Cannot open file
>
> while this works:
>
>> data <- readVECT6("rand5k_elev_filt", type= 'point')
> OGR data source with driver: GRASS
> Source: "/home/neteler/grassdata/spearfish60/neteler/vector/rand5k_elev_filt/head",
> layer: "1"
> with 4885 features and 5 fields
> Feature type: wkbPoint with 2 dimensions
>
> I have used update.packages() and should have the latest sp* packages.
> I tried to debug the problem but failed...
>
> Can anyone confirm this problem?
>
> thanks
> Markus
> _______________________________________________
> grass-stats mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/grass-stats
>

--
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: [hidden email]

_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Roger Bivand
Economic Geography Section
Department of Economics
Norwegian School of Economics and Business Administration
Helleveien 30
N-5045 Bergen, Norway
Markus Neteler

Re: Mapset issue with vector data via OGR plugin

Reply Threaded More More options
Print post
Permalink
On Fri, Aug 14, 2009 at 11:40 AM, Roger Bivand<[hidden email]> wrote:

> On Fri, 14 Aug 2009, Markus Neteler wrote:
>> I have some troubles when the vector map name contains the
>> @mapset part:
>
> This is a consequence of the plugin only searching in the current user's
> mapset, so using extra code to scan other mapsets:
>
>        if (is.null(mapset)) mapset <- .g_findfile(vname[1], type="vector")
>        dsn <- paste(gg$GISDBASE, gg$LOCATION_NAME, mapset,
>            "vector", vname, "head", sep="/")
>
> where .g_findfile() runs g.findfile. This seems to fail when @mapset is
> given.

I have made a test:

GRASS 6.5.svn (spearfish60):~ > g.findfile element=vector
file=rand5k_elev_filt@neteler mapset=neteler
name='rand5k_elev_filt@neteler'
mapset='neteler'
fullname='rand5k_elev_filt@neteler'
file='/home/neteler/grassdata/spearfish60/neteler/vector/rand5k_elev_filt'

GRASS 6.5.svn (spearfish60):~ > g.findfile element=vector
file=rand5k_elev_filt@claus mapset=neteler
ERROR: Parameter 'file' contains reference to <claus> mapset, but mapset
       parameter <neteler> does not correspond

At least it does not crash...

> I guess that the work-around is to use the argument mapset="neteler"
> in readVECT6() and readRAST6() for now, but I could look at trying to detect
> the @ and use it (in the plugin case only) to assign to a null mapset,
> throwing an error if mapset is non-null and @ is used.

This would be nice. I am currently testing "v.krige.py" from Anne
and it (I guess the underlying GRASS wxGUI part) adds automatically
the @mapset part to the map even when it is in the current mapset.

I am not sure how to solve that in order to make the R code overly
complex.

> Hope this helps,

Thanks for you explanations (and potential error trapping),
Markus
_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Roger Bivand

Re: Mapset issue with vector data via OGR plugin

Reply Threaded More More options
Print post
Permalink
On Fri, 14 Aug 2009, Markus Neteler wrote:

> On Fri, Aug 14, 2009 at 11:40 AM, Roger Bivand<[hidden email]> wrote:
>> On Fri, 14 Aug 2009, Markus Neteler wrote:
>>> I have some troubles when the vector map name contains the
>>> @mapset part:
>>
>> This is a consequence of the plugin only searching in the current user's
>> mapset, so using extra code to scan other mapsets:
>>
>>        if (is.null(mapset)) mapset <- .g_findfile(vname[1], type="vector")
>>        dsn <- paste(gg$GISDBASE, gg$LOCATION_NAME, mapset,
>>            "vector", vname, "head", sep="/")
>>
>> where .g_findfile() runs g.findfile. This seems to fail when @mapset is
>> given.
Could you try out the revisions on sourceforge CVS:

cvs -z3 \
-d:pserver:[hidden email]:/cvsroot/r-spatial co \
-P spgrass6

I think it works, but checking wouldn't hurt!

Best wishes,

Roger

>
> I have made a test:
>
> GRASS 6.5.svn (spearfish60):~ > g.findfile element=vector
> file=rand5k_elev_filt@neteler mapset=neteler
> name='rand5k_elev_filt@neteler'
> mapset='neteler'
> fullname='rand5k_elev_filt@neteler'
> file='/home/neteler/grassdata/spearfish60/neteler/vector/rand5k_elev_filt'
>
> GRASS 6.5.svn (spearfish60):~ > g.findfile element=vector
> file=rand5k_elev_filt@claus mapset=neteler
> ERROR: Parameter 'file' contains reference to <claus> mapset, but mapset
>       parameter <neteler> does not correspond
>
> At least it does not crash...
>
>> I guess that the work-around is to use the argument mapset="neteler"
>> in readVECT6() and readRAST6() for now, but I could look at trying to detect
>> the @ and use it (in the plugin case only) to assign to a null mapset,
>> throwing an error if mapset is non-null and @ is used.
>
> This would be nice. I am currently testing "v.krige.py" from Anne
> and it (I guess the underlying GRASS wxGUI part) adds automatically
> the @mapset part to the map even when it is in the current mapset.
>
> I am not sure how to solve that in order to make the R code overly
> complex.
>
>> Hope this helps,
>
> Thanks for you explanations (and potential error trapping),
> Markus
>
--
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: [hidden email]

_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Roger Bivand
Economic Geography Section
Department of Economics
Norwegian School of Economics and Business Administration
Helleveien 30
N-5045 Bergen, Norway
Markus Neteler

Re: Mapset issue with vector data via OGR plugin

Reply Threaded More More options
Print post
Permalink
Dear Roger,

On Fri, Aug 14, 2009 at 6:22 PM, Roger Bivand<[hidden email]> wrote:

> On Fri, 14 Aug 2009, Markus Neteler wrote:
>
>> On Fri, Aug 14, 2009 at 11:40 AM, Roger Bivand<[hidden email]> wrote:
>>>
>>> On Fri, 14 Aug 2009, Markus Neteler wrote:
>>>>
>>>> I have some troubles when the vector map name contains the
>>>> @mapset part:
>>>
>>> This is a consequence of the plugin only searching in the current user's
>>> mapset, so using extra code to scan other mapsets:
>>>
>>>        if (is.null(mapset)) mapset <- .g_findfile(vname[1],
>>> type="vector")
>>>        dsn <- paste(gg$GISDBASE, gg$LOCATION_NAME, mapset,
>>>            "vector", vname, "head", sep="/")
>>>
>>> where .g_findfile() runs g.findfile. This seems to fail when @mapset is
>>> given.
>
> Could you try out the revisions on sourceforge CVS:
>
> cvs -z3 \
> -d:pserver:[hidden email]:/cvsroot/r-spatial co \
> -P spgrass6
>
> I think it works, but checking wouldn't hurt!

Great, it works now:

# Test 1, now ok:
> data <- readVECT6("rand5k_elev_filt@neteler", type= 'point')
OGR data source with driver: GRASS
Source: "/home/neteler/grassdata/spearfish60/neteler/vector/rand5k_elev_filt/head",
layer: "1"
with 4885 features and 5 fields
Feature type: wkbPoint with 2 dimensions

# Test2, ok as before
> data <- readVECT6("rand5k_elev_filt", type= 'point')
OGR data source with driver: GRASS
Source: "/home/neteler/grassdata/spearfish60/neteler/vector/rand5k_elev_filt/head",
layer: "1"
with 4885 features and 5 fields
Feature type: wkbPoint with 2 dimensions

# Test 3: nonsense input
> data <- readVECT6("rand5k_elev_filt@neteler", type= 'point', mapset="benno")
Error in ogrInfo(dsn = dsn, layer = layer, input_field_name_encoding =
input_field_name_encoding) :
  Cannot open file

Thanks for the quick fix,
Markus
_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats