[GRASS-user] how does one merge two street maps?

James Powell powellj at pdx.edu
Sun Aug 25 18:31:42 PDT 2013

Hi list!  I'm a long-time listener, first-time poster.

I have struggled long with a simple problem, and I beg you to help me.

I have two separate shapefiles,

1) streets: a street map with attributes list like address range
for a segment, zip code, length, and (most importantly for me) road

2) segment: a second street map covering the same area, but with a
completely different (and complementary) set of attributes.

I want to merge these two into a new shapefile whose attribute table
has all of the attributes of both streets and segment, with a single
row for each feature.

I've tried all kinds of variations of v.patch and v.clean.  I've
successfully given segment and streets both separately the identical
attribute table structure (identical schema in SQL) because as man
v.patch says

  If the table structures are identical, attributes are transferred to
  the new table.

I've used v.category to make sure the category numbers of the two
don't overlap.  By the way, there is absolutely no key allowing to
find a streets record from a segment record or vice-versa except for
the geometry.

My process looks like this:

  :  v.patch --overwrite input=segment at PERMANENT,streets at PERMANENT output=segstr -e
  :  v.clean --overwrite input=segstr at PERMANENT output=segstr_clean tool=break,snap,rmdupl

or similarly, but different,

  :  g.remove vect=segstr
  :  g.copy vect=streets,segstr
	:  v.category option=sum cat=200000 input=segstr output=segstr_cats --overwrite
  :  v.patch -a --overwrite input=segment at PERMANENT output=segstr_cats -e
  :  v.clean --overwrite input=segstr_cats at PERMANENT output=segstr_clean tool=break,snap,rmdupl

Note I'm hardcoding 200000.  I am pretty sure that's safely high
enough to separate the two.  I recall from

   If you're on a *nix command line, you can do this:

	 v.category in=gr_help1 out=gr_help1_cat option=sum value=`echo 'SELECT 
	 MAX(cat) FROM gr_help1' | db.select -c`

and that's useful, but let's assume for now that my 200000 is
separating the categories so that there is no overlap.

I do not know what v.patch does with the overlapping cats in the
non-append (no -a) case, thus I am not sure how the two approaches
above differ.

In any case, either way, after, the resulting attribute table is a
concatenation of the input tables, i.e. there are two rows for each
line segment but as far as I can tell only one piece of line segment
geometry remaining (as you'd expect from rmdupl in v.clean) which
itself points to exactly one of the two rows by category.

The other row is orphaned it seems like.  I try v.what with

v.what --q -a map=segstr_clean at PERMANENT east_north=7627976.73,709484.80 distance=0.37619

and I get just one of the records (the one from segment).  I do not see
any way to progress.

What I would like to have happen is either there are two rows per
feature where each row one cross references the other (via perhaps a
"cat_b" attribute in analogy with a_ and b_ in v.overlay) or one row
per feature which merges all of the attributes.

How may I accomplish this action?

Many thanks in advance.

yours truly,
  James P.

James Powell
Portland State University
Department of Physics
Applied Physics PhD Student
Office hours: 10-11 AM every Friday morning in SRTC 409A
Public key: http://web.pdx.edu/~powellj/public_key.txt

More information about the grass-user mailing list