[GRASS-user] How to find all vectors that overlay a given region

Hi,

I'm trying to find out how to determine how many vectors in an entire mapset overlay a given region. What is the best approach to do this - import the current region as a vector using v.in.region (type parameter as area), then run v.select on every vector in the mapset in a loop, or is there a better way? I see that v.overlay/v.select takes one map as input for both the ainput and binput parameters.

How hard would it be to change the structures in v.select to accept multiple inputs, or is this even feasible?

Thanks,

~ Eric.

It also depends on what you mean by 'how many vectors'. Number of points,
lines, segments, areas, centroids, etc. v.info gives some of this
information.

Michael

On 9/17/07 11:29 AM, "Patton, Eric" <epatton@nrcan.gc.ca> wrote:

Hi,

I'm trying to find out how to determine how many vectors in an entire mapset
overlay a given region. What is the best approach to do this - import the
current region as a vector using v.in.region (type parameter as area), then
run v.select on every vector in the mapset in a loop, or is there a better
way? I see that v.overlay/v.select takes one map as input for both the ainput
and binput parameters.

How hard would it be to change the structures in v.select to accept multiple
inputs, or is this even feasible?

Thanks,

~ Eric.

__________________________________________
Michael Barton, Professor of Anthropology
Director of Graduate Studies
School of Human Evolution & Social Change
Center for Social Dynamics and Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

Sorry; I'll clarify. I meant how to find the number of vector maps, regardless of vector type, that overlay a given region. I'm really only interested in the map names.

~ Eric.

-----Original Message-----
From: Michael Barton [mailto:michael.barton@asu.edu]
Sent: Mon 9/17/2007 4:25 PM
To: Patton, Eric; grassuser@grass.itc.it
Subject: Re: [GRASS-user] How to find all vectors that overlay a given region

It also depends on what you mean by 'how many vectors'. Number of points,
lines, segments, areas, centroids, etc. v.info gives some of this
information.

Michael

On 9/17/07 11:29 AM, "Patton, Eric" <epatton@nrcan.gc.ca> wrote:

Hi,

I'm trying to find out how to determine how many vectors in an entire mapset
overlay a given region. What is the best approach to do this - import the
current region as a vector using v.in.region (type parameter as area), then
run v.select on every vector in the mapset in a loop, or is there a better
way? I see that v.overlay/v.select takes one map as input for both the ainput
and binput parameters.

How hard would it be to change the structures in v.select to accept multiple
inputs, or is this even feasible?

Thanks,

~ Eric.

__________________________________________
Michael Barton, Professor of Anthropology
Director of Graduate Studies
School of Human Evolution & Social Change
Center for Social Dynamics and Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

Eric wrote:

> I'm trying to find out how to determine how many vectors in an entire
> mapset
> overlay a given region. What is the best approach to do this - import the
> current region as a vector using v.in.region (type parameter as area), then
> run v.select on every vector in the mapset in a loop, or is there a better
> way? I see that v.overlay/v.select takes one map as input for both the
> ainput and binput parameters.

..

Sorry; I'll clarify. I meant how to find the number of vector maps,
regardless of vector type, that overlay a given region. I'm really only
interested in the map names.

Write a shell script using 'g.mlist vect'. As a fist pass use 'v.info -g' to
get the outer bounding box region of the map to be tested. If there is no rough
overlap between the two maps then quickly continue on to the next. If the
bounding boxes do overlap you have to run v.select. If the result of v.select
$TESTMAP + v.in.region box contains >= 1 area (test result map with 'v.info
-t'), count that as a hit & log the name of the map.

> How hard would it be to change the structures in v.select to accept
> multiple inputs, or is this even feasible?

probably possible, but not worth the trouble when a shell script can do the
job?? If work is being done on v.select a high priority should be to add a
operator="no overlap". (what to call that? "op=discrete"?)

Hamish

      ____________________________________________________________________________________
Don't let your dream ride pass you by. Make it a reality with Yahoo! Autos.
http://autos.yahoo.com/index.html

Sounds simple, but I think it may be tricky.

Running v.info will give you the extents of a vector file. You can parse
this and compare the extents to the region extents to see if they overlap.

You could also use the approach I gave for finding the intersection of 2
raster maps.

parse g.region -ugp vect=vector1
parse g.region -ugp vect=vector2

compare the extents of the regions defined by the vectors with extents of
the current region

parse g.region -ugp

Michael

On 9/18/07 3:57 AM, "Patton, Eric" <epatton@nrcan.gc.ca> wrote:

Sorry; I'll clarify. I meant how to find the number of vector maps, regardless
of vector type, that overlay a given region. I'm really only interested in the
map names.

~ Eric.

-----Original Message-----
From: Michael Barton [mailto:michael.barton@asu.edu]
Sent: Mon 9/17/2007 4:25 PM
To: Patton, Eric; grassuser@grass.itc.it
Subject: Re: [GRASS-user] How to find all vectors that overlay a given region

It also depends on what you mean by 'how many vectors'. Number of points,
lines, segments, areas, centroids, etc. v.info gives some of this
information.

Michael

On 9/17/07 11:29 AM, "Patton, Eric" <epatton@nrcan.gc.ca> wrote:

Hi,

I'm trying to find out how to determine how many vectors in an entire mapset
overlay a given region. What is the best approach to do this - import the
current region as a vector using v.in.region (type parameter as area), then
run v.select on every vector in the mapset in a loop, or is there a better
way? I see that v.overlay/v.select takes one map as input for both the ainput
and binput parameters.

How hard would it be to change the structures in v.select to accept multiple
inputs, or is this even feasible?

Thanks,

~ Eric.

__________________________________________
Michael Barton, Professor of Anthropology
Director of Graduate Studies
School of Human Evolution & Social Change
Center for Social Dynamics and Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

__________________________________________
Michael Barton, Professor of Anthropology
Director of Graduate Studies
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

Michael Barton wrote:

Running v.info will give you the extents of a vector file. You can parse
this and compare the extents to the region extents to see if they overlap.

You could also use the approach I gave for finding the intersection of 2
raster maps.

parse g.region -ugp vect=vector1
parse g.region -ugp vect=vector2

compare the extents of the regions defined by the vectors with extents of
the current region

parse g.region -ugp

beware the case where the bounding boxes overlap but the vector features within
do not.

Hamish

____________________________________________________________________________________
Yahoo! oneSearch: Finally, mobile search
that gives answers, not web links.
http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC

Michael Barton wrote:

Running v.info will give you the extents of a vector file. You can parse
this and compare the extents to the region extents to see if they overlap.

You could also use the approach I gave for finding the intersection of 2
raster maps.

parse g.region -ugp vect=vector1
parse g.region -ugp vect=vector2

compare the extents of the regions defined by the vectors with extents of
the current region

parse g.region -ugp

beware the case where the bounding boxes overlap but the vector features within
do not.

Hamish

I'm using the approach that Hamish suggested; I have the script almost finished
and I just have to debug it now. Any vector map region extents that overlap the
Grass region extent get their names populated in a list of candidates which each
get further checked for overlapping geometry with v.select. If a vector has
geometry which passes this check, its name gets printed to the terminal.

This same approach could be used for answering the question "Find me all the
raster data sets that falls within the current region, with some modification.

Frequently I have several hundred vector maps representing ship naivgation
tracklines from multiple surveys and I need to know when the vessel was in a
certain region of interest, hence the need for this kind of script.

Thanks for the feedback,

--
Eric Patton
Technologist
Geological Survey of Canada (Atlantic)
Bedford Institute of Oceanography
Dartmouth, Nova Scotia, Canada
902.426.7732
epatton@nrcan.gc.ca
     

On 9/19/07 4:36 AM, "Hamish" <hamish_nospam@yahoo.com> wrote:

Michael Barton wrote:

Running v.info will give you the extents of a vector file. You can parse
this and compare the extents to the region extents to see if they overlap.

You could also use the approach I gave for finding the intersection of 2
raster maps.

parse g.region -ugp vect=vector1
parse g.region -ugp vect=vector2

compare the extents of the regions defined by the vectors with extents of
the current region

parse g.region -ugp

beware the case where the bounding boxes overlap but the vector features
within
do not.

Good point. I don't know how to account for that since vectors are not a
continuous field.

Michael

__________________________________________
Michael Barton, Professor of Anthropology
Director of Graduate Studies
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

Michael Barton wrote:

beware the case where the bounding boxes overlap but the vector features
within
do not.

Good point. I don't know how to account for that since vectors are not a
continuous field.

Michael

Using v.select on the list of candidate maps whose regions superficially overlap and then v.info -t on the output will tell you if you have any vector geometry in the region.

~ Eric.