[SOLVED] db.sel syntax

If you have problems using RGeostats package or if you simply need some help on an unlisted subject.

[SOLVED] db.sel syntax

Postby MatthewCobb » Wed Jul 24, 2013 2:48 am

Hello everyone,

I have been bumbling around RGeoS for a couple of months now, yet still haven't discovered a way properly utilise the selection function for the db-class.

What I have done is select those nodes from both a grid db (the target) and a point db (the input data) inside a 2D polygon (the ore outline of a single mining bench).
My aim is to inform only the selected nodes in the target db, using only the selected input data (via simulation, though this is somewhat irrelevant).

The problem is, while I can create a selection variable in each db, I have not yet figured out how to filter both the input and output db's to use only the selected samples. Similarly, I have yet to figure out how (and indeed if it is possible) to extract all vectors from a db where db.sel=TRUE.

If anyone can offer help it would be greatly appreciated.

Many thanks,

Matt.
MatthewCobb
 
Posts: 5
Joined: Mon Jul 22, 2013 5:36 am

Re: db.sel syntax

Postby Didier Renard » Thu Aug 01, 2013 9:46 pm

Hello Matt

Sorry for the delay in answering your interesting question concerning the selections.
Each Db can contain at most ONE active selection: this corresponds to a variable with a locator set to "sel".
A sample is considered as masked off if the value of the selection variable is equal to 0; otherwise the sample is active.

When a selection variable is defined within a Db, all the procedures using that Db (usually) take this selection into account:
- if the Db is used as input, only the active samples can be used
- if the Db uis used as output, only the active samples are processed.

For demonstration sake, I imagined the following small case study.

# Create the input data set (100 random points in a [0,1] 2-D square, called "data" #
data <- db.create(x1=runif(100),x2=runif(100),z1=runif(100))

# create an output grid covering the area, called "grid" #
grid <- db.create(flag.grid=T,nx=c(100,100),dx=c(0.01,0.01))

# Define a model, called "model" #
### This can be done by using the interactive procedure model.input() ###
### I have created a model composed of a cubic isotropic structure with range 0.3 and sill 1 ###

# Define a Neighborhood, called "neigh" #
### This can be done by using the interactive procedure neigh.input() ###
### I have created a Unique neighborhood ###

# Create a simple polygon (triangle) interactively, called "polygon" #
polygon = polygon.create(x=c(0.1,0.9,0.5),y=c(0.1,0.1,0.9))

# Apply the selection on the input and the output Db #
data = db.polygon(data,polygon)
grid = db.polygon(grid,polygon)
# As you can check, a selection has been created in each Db #

# We can now check the usage of the selection in the output file, using the conditional simulations #
plot(simtub(data,grid,model,neigh))
### We can see that only the nodes of the output Db (Grid) located inside the polygon have been processed ###

# We now check the usage of the selection in the input Db, using the kriging test performed for the grid node #5000 #a <-
a <- krigtest(data,grid,model,neigh,iech0=5000)
### The result is a list (stored in the object "a") which contains several fields ###
### The field xyz corresponds to the locations of the data information used for this estimation ###
plot(a$xyz)
plot(polygon,add=T)
### By displaying the information used for kriging the grid node #5000 (using Unique Neighborhood) ###
### we can check that it correspond to the subset of the data which belong to the polygon ###

Obviously, the selection applied to the input and output Db do not have to be the same...

Now that you have understood the usage of the selection, I can introduce the concept of the DOMAINING.
Suppose that you have assigned a DOMAIN number to each sample of the input Db and to each grid node of the output Db,
(this variable must be defined as the locator "dom"in each Db),
you can run the simulation or estimation procedure several times, by specifying the value of the target DOMAIN.
This number is provided throught the argument "domain" whih is available in most of the procedures.
Say you run the estimation with domain=21, then a temporary selection is created on the fly, where the only samples
whose domain value is equal to 21 are active. At the same time, a selection is created on the fly regrouping the only
nodes of the output Db for which the domain value is equal to 21. And the procedure takes place.

If the locator "dom" is not created in a Db, the argument "domain" has no impact.

Hoping all this information will be of some help..
Didier Renard
 
Posts: 337
Joined: Thu Sep 20, 2012 4:22 pm

Re: db.sel syntax

Postby MatthewCobb » Sun Aug 11, 2013 5:52 am

Thanks Didier,

I too must apologise for not replying sooner, but have been busy further forging my way through RGeoS.

That selection info was useful, particularly the domaining feature which I was not aware of.

You'll see that I have also posted another question relating to limiting the ranges used in model.auto(), and I shall ensure that I check back a little more frequently this time.

Regards,

Matt.
MatthewCobb
 
Posts: 5
Joined: Mon Jul 22, 2013 5:36 am


Return to Other Troubleshooting

Who is online

Users browsing this forum: No registered users and 1 guest

cron