[GRASSLIST:3668] Re: v.extract (5.7) doesn't work on extra fields?
Radim Blazek
blazek at itc.it
Tue Jun 15 10:48:56 EDT 2004
1) It is not guranteed that pairs cat-POLYID in tgr_2 and tgr_3 are
identical. It seems that in this case it is true but you should not
rely on that.
2) There are no elements with category of field 4, if you link a table
to field 4, it has no effect, you could overwrite the link of
field 3, but that is not secure as I said above.
3) > v.extract -d in=tgr out=tgrzip type=area,centroid field=4 list=1-99999
This is wrong as it groups areas by category, not by ZIP.
4) There was a bug in v.extract -d, I fixed that in cvs.
5) ZCTA5 is varchar and v.reclass does not work with varchar column.
Here is an example how to do that (Postgres, MySQL will be similar),
I know that it is not simple solution for simple task,
support for varchar columns and dissolve option in v.reclass
should make it easier:
v.in.ogr -o dsn=TGR37013/ layer=CompleteChain,PIP,Polygon output=tgr1 \
type=boundary,centroid snap=-1
echo "create table tgr1_4 as select distinct ZCTA5 from tgr1_3" | db.execute
echo "create table tgr1_5 as select tgr1_2.cat, tgr1_3.ZCTA5, tgr1_4.oid
as zcta5id from tgr1_2, tgr1_3, tgr1_4 where tgr1_2.POLYID = tgr1_3.POLYID
and tgr1_3.ZCTA5 = tgr1_4.ZCTA5" | db.execute
v.db.connect -o map=tgr1 table=tgr1_5 key=cat field=2
v.reclass input=tgr1 output=tgr2 field=2 col=zcta5id type=area
v.extract -d in=tgr2 out=tgr3 type=area list=0-10000000 new=-1
Radim
On Wednesday 09 June 2004 20:08, William K wrote:
> Here's what I've done so far (ultimately I want to test dissolve TIGER
> polygons by ZIP code):
>
> - use native GRASS 5.7 geometry, and store attribs in MySQL (so I can
> do some table cleanup).
> - import TIGER CompleteChain, PIP, Polygon layers, with type boundary
> and centroid.
> - now I have 3 fields - the 3rd is extra polygon attributes, where the
> ZIP codes are
> - use SQL copy to create a new table from field 3 with cat and ZCTA5
> columns only
> - register new table with GRASS vectors as field 4
> - extract with dissolve:
>
> v.extract -d in=tgr out=tgrzip type=area,centroid field=4 list=1-99999
>
> and I get 0 everything output.
>
> I've tried type=boundary,centroid and boundary,area,centroid.
> I've tried where="cat > 0" instead of a list.
> I've tried without dissolving, just to see if I could get anything.
>
> If I leave out the field I get a copy of all areas/centroids and field
> 1 (the boundary attribs), which is not quite as expected (for areas I'd
> expect field 2, the area/centroid attribs), but it's something. And
> nothing is dissolved of course since all attribs are unique.
>
> So, ignoring the dissolve option for now (just testing), nothing is
> getting selected when a field other than 1 is used.
>
> Bug? Am I missing something? The imported TIGER vector seem to be OK
> - v.info reports boundaries, areas and centroids and vector level 2.
>
> -----
> William Kyngesburye <kyngchaos at charter.net>
> http://webpages.charter.net/kyngchaos/
>
> "Time is an illusion - lunchtime doubly so."
>
> - Ford Prefect
More information about the grass-user
mailing list