[GRASS-dev] New: v.db.droprow

Hi,

to be able to easily filter vector maps geometrically (i.e. remove
vectors) I have
written the v.db.droprow script (G6.5; needs a Python port for GRASS 7).
It removes vector objects (point, line, area, face etc.) from a vector
map through
attribute selection in the table.

Example: remove all vector with a certain attribute missing (nice when doing
random sampling).

cheers
Markus

On 11/08/09 14:49, Markus Neteler wrote:

Hi,

to be able to easily filter vector maps geometrically (i.e. remove
vectors) I have
written the v.db.droprow script (G6.5; needs a Python port for GRASS 7).
It removes vector objects (point, line, area, face etc.) from a vector
map through
attribute selection in the table.

Example: remove all vector with a certain attribute missing (nice when doing
random sampling).

Can't you do that with v.extract ?

Moritz

On Tue, Aug 11, 2009 at 5:53 PM, Moritz
Lennert<mlennert@club.worldonline.be> wrote:

On 11/08/09 14:49, Markus Neteler wrote:

...

Example: remove all vector with a certain attribute missing (nice when
doing random sampling).

Can't you do that with v.extract ?

It is using v.extract. But IMHO most non-power users won't get the idea to
use a reverse extraction to remove vectors via attribute selection...

Markus

On 11/08/09 19:29, Markus Neteler wrote:

On Tue, Aug 11, 2009 at 5:53 PM, Moritz
Lennert<mlennert@club.worldonline.be> wrote:

On 11/08/09 14:49, Markus Neteler wrote:

...

Example: remove all vector with a certain attribute missing (nice when
doing random sampling).

Can't you do that with v.extract ?

It is using v.extract. But IMHO most non-power users won't get the idea to
use a reverse extraction to remove vectors via attribute selection...

Shouldn't this then be better documented ?

Just wondering whether multiplying the number of small scripts is really the best way to go...

Moritz

On Tue, Aug 11, 2009 at 8:10 PM, Moritz
Lennert<mlennert@club.worldonline.be> wrote:

On 11/08/09 19:29, Markus Neteler wrote:

On Tue, Aug 11, 2009 at 5:53 PM, Moritz Lennert wrote:

On 11/08/09 14:49, Markus Neteler wrote:

...

Example: remove all vector with a certain attribute missing (nice when
doing random sampling).

Can't you do that with v.extract ?

It is using v.extract. But IMHO most non-power users won't get the idea to
use a reverse extraction to remove vectors via attribute selection...

Shouldn't this then be better documented ?

Please suggest where... (if I/user don't know that I have to use
v.extract for this
in the first place since I want to *delete*, it needs to be documented
elsewhere).

Just wondering whether multiplying the number of small scripts is really the
best way to go...

Well, since we have
r.mfilter + r.mfilter.fp or
r.colors + r.colors.stddev
r.grow + r.grow.distance
r.rescale + r.rescale.eq
r.surf.idw + r.surf.idw2
r.what + r.what.color
...

Luckily the v.* family looks better...

With vector objects removal I don't see the problem (while I agree in general).

Markus

Hi,

2009/8/11 Markus Neteler <neteler@osgeo.org>:

to be able to easily filter vector maps geometrically (i.e. remove
vectors) I have

written the v.db.droprow script (G6.5; needs a Python port for GRASS 7).

Done in r38716.

It removes vector objects (point, line, area, face etc.) from a vector
map through
attribute selection in the table.

Also not sure if we need this script. In any case the name is probably
misleading. Prefix 'v.db' indicates that the module modifies only
attribute data, not geometry(?)

I have some questions regarding Bash script:

* are these extra checks needed (it's done by v.extract) [1,2]
* unused variables [3]
* G_OPT_OUTPUT instead of G_OPT_INPUT? [4]

Thanks, Martin

[1] http://trac.osgeo.org/grass/browser/grass/branches/develbranch_6/scripts/v.db.droprow/v.db.droprow#L86
[2] http://trac.osgeo.org/grass/browser/grass/branches/develbranch_6/scripts/v.db.droprow/v.db.droprow#L92
[3] http://trac.osgeo.org/grass/browser/grass/branches/develbranch_6/scripts/v.db.droprow/v.db.droprow#L97
[4] http://trac.osgeo.org/grass/browser/grass/branches/develbranch_6/scripts/v.db.droprow/v.db.droprow#L116
--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa

On Fri, Aug 14, 2009 at 10:15 AM, Martin Landa<landa.martin@gmail.com> wrote:

2009/8/11 Markus Neteler <neteler@osgeo.org>:

It removes vector objects (point, line, area, face etc.) from a vector
map through attribute selection in the table.

Also not sure if we need this script.

How would you do vector removal based on attributes?

In any case the name is probably
misleading. Prefix 'v.db' indicates that the module modifies only
attribute data, not geometry(?)

Perhaps yes (I considered it a v.db.* since it uses the attribute table).

I have some questions regarding Bash script:

* are these extra checks needed (it's done by v.extract) [1,2]

Yes, I think so: if you create a map with v.random it won't have
a connected table, so better don't badly crash. Likewise with
a non-existing map. I used existing msg strings (for translation).

* unused variables [3]

Removed.

* G_OPT_OUTPUT instead of G_OPT_INPUT? [4]

Right, fixed.

Thanks, Martin

[1] http://trac.osgeo.org/grass/browser/grass/branches/develbranch_6/scripts/v.db.droprow/v.db.droprow#L86
[2] http://trac.osgeo.org/grass/browser/grass/branches/develbranch_6/scripts/v.db.droprow/v.db.droprow#L92
[3] http://trac.osgeo.org/grass/browser/grass/branches/develbranch_6/scripts/v.db.droprow/v.db.droprow#L97
[4] http://trac.osgeo.org/grass/browser/grass/branches/develbranch_6/scripts/v.db.droprow/v.db.droprow#L116

thanks
Markus

Hi,

2009/8/14 Markus Neteler <neteler@osgeo.org>:

* are these extra checks needed (it's done by v.extract) [1,2]

Yes, I think so: if you create a map with v.random it won't have
a connected table, so better don't badly crash. Likewise with
a non-existing map. I used existing msg strings (for translation).

Badly crash? After r38718:

$ v.db.droprow in=x out=x1 w='x' --o
ERROR: Vector map <x> not found

$ v.db.droprow in=p out=x1 w='x' --o
ERROR: Database connection not defined for layer 1

It seems reasonable to me.

Martin

--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa

Hi,

2009/8/14 Martin Landa <landa.martin@gmail.com>:

* are these extra checks needed (it's done by v.extract) [1,2]

Yes, I think so: if you create a map with v.random it won't have
a connected table, so better don't badly crash. Likewise with
a non-existing map. I used existing msg strings (for translation).

BTW, why are you requesting the input vector map from the current mapset?

Martin

--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa

On Fri, Aug 14, 2009 at 12:16 PM, Martin Landa<landa.martin@gmail.com> wrote:

Hi,

2009/8/14 Martin Landa <landa.martin@gmail.com>:

* are these extra checks needed (it's done by v.extract) [1,2]

Yes, I think so: if you create a map with v.random it won't have
a connected table, so better don't badly crash. Likewise with
a non-existing map. I used existing msg strings (for translation).

BTW, why are you requesting the input vector map from the current mapset?

Fixed.

Markus

On 14/08/09 10:43, Markus Neteler wrote:

On Fri, Aug 14, 2009 at 10:15 AM, Martin Landa<landa.martin@gmail.com> wrote:

2009/8/11 Markus Neteler <neteler@osgeo.org>:

It removes vector objects (point, line, area, face etc.) from a vector
map through attribute selection in the table.

Also not sure if we need this script.

How would you do vector removal based on attributes?

v.extract -r ... where=

Moritz

On Fri, Aug 14, 2009 at 3:30 PM, Moritz
Lennert<mlennert@club.worldonline.be> wrote:

On 14/08/09 10:43, Markus Neteler wrote:

On Fri, Aug 14, 2009 at 10:15 AM, Martin Landa<landa.martin@gmail.com>
wrote:

2009/8/11 Markus Neteler <neteler@osgeo.org>:

It removes vector objects (point, line, area, face etc.) from a vector
map through attribute selection in the table.

Also not sure if we need this script.

How would you do vector removal based on attributes?

v.extract -r ... where=

Ok, while I disagree that this is obvious (especially to newcomers),
I'll remove the module now in 6.5.

Markus