[GRASS-user] Clipping shapefiles

Hi,
   I'm trying to clip a largeish shapefile (100Mb) containing contour lines of a reasonably hilly area, into an area that is about 1/12 of it. I'm finding v.overlay very slow (in excess of 17 hours on a quad core 4GB Windows machine), am I doing something wrong?

g.region vect=NZMG_s27
v.in.region output=cutter type=line --overwrite
v.overlay ainput=wellington_contours atype=line binput=cutter output=clipped operator=and

I'm using GRASS 6.3 (both on Windows Vista 64 (but as a 32 bit exe), and on Mac OSX

Thanks in advance

Matthew

Hi Matthew,

I'm trying to clip a largeish shapefile (100Mb) containing contour
lines of a reasonably hilly area, into an area that is about 1/12 of
it. I'm finding v.overlay very slow (in excess of 17 hours on a quad
core 4GB Windows machine), am I doing something wrong?

v.overlay is just slow. see:
  http://trac.osgeo.org/grass/browser/grass/trunk/doc/vector/TODO#L219
and v.in.ogr note on line 242.

g.region vect=NZMG_s27
v.in.region output=cutter type=line --overwrite
v.overlay ainput=wellington_contours atype=line \
   binput=cutter output=clipped operator=and

Solution:

during import with v.in.ogr use the spatial=w,s,e,n option to import only
relevant lines, or after import use v.select to crop out only lines which
fully or partly fall into your region. Then clip off fringes if needed
with v.overlay and a box created with v.in.region. It will be much faster
this time.

Hamish
(Dunedin)

> g.region vect=NZMG_s27
> v.in.region output=cutter type=line --overwrite
> v.overlay ainput=wellington_contours atype=line \
> binput=cutter output=clipped operator=and

and I think you'll want v.in.region to use type=area, not line, otherwise
you risk only to get contour lines which cross the boundary and not those
that fall within it.

Hamish

Unfortunately when I do that [use spatial, and use type=are] it's very fast, but all I end up with is a box (no contour lines).

My steps at the moment are:
v.in.ogr contour.shp out=S28 spatial=2690000,5950000,2730000,5980000
g.region vect=NZMG_bounds_s28
v.in.region output=cutter type=area --overwrite

v.overlay ainput=S28 atype=area binput=cutter output=S28_Clipped operator=and
    ->This makes a blank square

v.overlay ainput=S28 atype=line binput=cutter output=S28_Clipped operator=and
   ->Takes ages, but looks more promising (prints things like "Breaking lines...", just too slow.

Thanks in advance.

Matthew

On 13/09/2008, at 8:27 AM, Hamish wrote:

g.region vect=NZMG_s27
v.in.region output=cutter type=line --overwrite
v.overlay ainput=wellington_contours atype=line \
  binput=cutter output=clipped operator=and

and I think you'll want v.in.region to use type=area, not line, otherwise
you risk only to get contour lines which cross the boundary and not those
that fall within it.

Hamish