[GRASSLIST:222] Re: [GRASS5] Built-in vector documentation extended

Thomas Adams Thomas.Adams at noaa.gov
Fri Mar 17 14:55:52 EST 2006


Michael,

Your instructions did not help... I'm sorry to be a bother about this, 
so, I'll restate the problem I'm having.

I have a Postgres database with a table called 'location', which 
consists of meteorological observation points with lat-long coordinates 
along with various other attributes:

CHARACTER|lid
CHARACTER|county
CHARACTER|coe
CHARACTER|cpm
CHARACTER|detail
DOUBLE PRECISION|elev
CHARACTER|hdatum
CHARACTER|hsa
CHARACTER|hu
DOUBLE PRECISION|lat
DOUBLE PRECISION|lon
CHARACTER|lremark
DATE|lrevise
CHARACTER|name
CHARACTER|network
CHARACTER|rb
CHARACTER|rfc
DATE|sbd
CHARACTER|sn
CHARACTER|state
CHARACTER|waro
CHARACTER|wfo
CHARACTER|wsfo
CHARACTER|type
CHARACTER|des
CHARACTER|det
INTEGER|post
CHARACTER|stntype
CHARACTER|tzone

Please notice that only one field is type integer, namely, the 'post' 
field; it is a boolean (1 or 0).

When I use the GRASS v.in.db command:

v.in.db driver=pg database=host=dell3-tir,dbname=hd_ob6tir 
table=location x=-1*lon y=lat z=elev key=1 where=rfc='OHRFC' 
output=locations

I am forced to supply key=???; the only thing that works for me is key=0 
or key=1, etc. since I have no integer field with unique integer values. 
If I run v.in.db (above), I get:

GRASS_INFO_MESSAGE(19616,1): 5030 points written to vector
Building topology ...egistering lines: 1000 2000 3000 4000 5000
5030 primitives registered
Building areas:


0 areas built
0 isles built
Attaching islands:
Attaching centroids:
Topology was built.
Number of nodes : 4729
Number of primitives: 5030
Number of points : 5030
Number of lines : 0
Number of boundaries: 0
Number of centroids : 0
Number of areas : 0
Number of isles : 0


GRASS_INFO_MESSAGE(19616,2): Vector import complete

Which, I guess, looks OK. If I then use v.category:

v.category input=locations output=locations_new 
type=point,line,boundary,centroid,area option=add cat=1 layer=1 step=1
DBMI-Postgres driver error:
Cannot create index:
create unique index locations_new_1 on locations_new ( 1 )
ERROR: syntax error at or near "1" at character 56



GRASS_INFO_WARNING(19064,1): Cannot create index
0 new centroids placed in output map
Building topology ...egistering lines: 1000 2000 3000 4000 5000
5030 primitives registered
Building areas:


0 areas built
0 isles built
Attaching islands:
Attaching centroids:
Topology was built.

Number of nodes : 4729
Number of primitives: 5030
Number of points : 5030
Number of lines : 0
Number of boundaries: 0
Number of centroids : 0
Number of areas : 0
Number of isles : 0

Which has errors, and does nothing for solving my problem. If I use the 
GRASS query tool for the 'locations' or my newly created 'locations_new' 
vector maps, the x,y,z data is correct from v.in.db, but all the 
category data is the same, namely, for the first record of my Postgres 
table.

Consequently, trying to re-project the points into a LCC location using 
v.proj fails. Not to mention the fact that all the attribute data for my 
points in my lat-long location is useless because it's all the same.

How do I deal with this? Your help is appreciated.

Regards,
Tom


Michael Barton wrote:
> Thomas,
>
> See below.
>
> Michael
> __________________________________________
> Michael Barton, Professor of Anthropology
> School of Human Evolution and Social Change
> Arizona State University
> Tempe, AZ 85287-2402
>
> phone: 480-965-6213
> fax: 480-965-7671
> www: http://www.public.asu.edu/~cmbarton
>
>
>
>   
>> From: Thomas Adams <Thomas.Adams at noaa.gov>
>> Date: Fri, 17 Mar 2006 12:37:20 -0500
>> To: Michael Barton <michael.barton at asu.edu>
>> Cc: Markus Neteler <neteler at itc.it>, grass developers list
>> <grass5 at grass.itc.it>, Multiple recipients of list <grasslist at baylor.edu>
>> Subject: Re: [GRASS5] Built-in vector documentation extended
>>
>> Michael,
>>
>> This is very helpful and answers many questions I have about the new
>> vector format, especially points. I do want to confirm my understanding
>> from "Vector data processing in GRASS GIS" (please pardon my being
>> obtuse). SoŠ
>>
>> In order to get a Postgres table consisting of point coordinates and
>> various attributes to import into my lat-long location using v.in.db, I
>> had to put a "1" in the field for the "category column name (string
>> required)"; when I put "lid" in the field, I got an error saying the
>> type was not an integer. It seems GRASS is expecting a string for the
>> field name that has integer as its type. My problem is that none of my
>> fields meet this requirement for the key field, the only column that
>> does, "lid", has type string.
>>     
>
> The GRASS vector key field ("category") MUST be an integer. The matching key
> field in your attribute table must also be integer to make a join.
>
>   
>> Now, my question is, for 5030 records, how do I add an integer key
>> field? My guess is that I would have to write a script that (1) created
>> a new column (type integer) for the Postgres table and (2) looped,
>> sequentially filling the new field for each record with a unique integer
>> value ‹ or I could drop the table, and do all of this outside of the
>> Postgres/GRASS environment and reload the table. The problem I have with
>> doing either is that the table design is not my own and is controlled by
>> 'outsiders'.
>>     
>
> Use v.category to do this in GRASS.
>
> Michael 
>
>   
>> Regards,
>> Tom
>>
>> Michael Barton wrote:
>>     
>>> Markus,
>>>
>>> This is very helpful. It will make learning GRASS vector architecture much
>>> easier for people.
>>>
>>> Michael
>>> __________________________________________
>>> Michael Barton, Professor of Anthropology
>>> School of Human Evolution and Social Change
>>> Arizona State University
>>> Tempe, AZ 85287-2402
>>>
>>> phone: 480-965-6213
>>> fax: 480-965-7671
>>> www: http://www.public.asu.edu/~cmbarton
>>>
>>>
>>>
>>>   
>>>       
>>>> From: Markus Neteler <neteler at itc.it>
>>>> Date: Thu, 16 Mar 2006 22:35:22 +0100
>>>> To: grass developers list <grass5 at grass.itc.it>
>>>> Cc: GRASS user list <grasslist at baylor.edu>
>>>> Subject: [GRASS5] Built-in vector documentation extended
>>>>
>>>> Hi,
>>>>
>>>> I have extended the vector overview document in
>>>> 6.1-CVS, find also here:
>>>>
>>>>  http://grass.itc.it/grass61/manuals/html61_user/vectorintro.html
>>>>
>>>> While it covers most modules, each now in a thematic
>>>> context, it may be fine tuned, improved.
>>>> Text pieces welcome (preferably CVS patches).
>>>>
>>>> The idea is to give a short overview.
>>>>
>>>> Currently the page is even W3 conformant :-)
>>>>
>>>> Cheers
>>>>
>>>>  Markus
>>>>
>>>>     
>>>>         
>>> _______________________________________________
>>> grass5 mailing list
>>> grass5 at grass.itc.it
>>> http://grass.itc.it/mailman/listinfo/grass5
>>>
>>>   
>>>       
>> -- 
>> Thomas E Adams
>> National Weather Service
>> Ohio River Forecast Center
>> 1901 South State Route 134
>> Wilmington, OH 45177
>>
>> EMAIL: thomas.adams at noaa.gov
>>
>> VOICE: 937-383-0528
>> FAX: 937-383-0033
>>
>>     
>
>
>   


-- 
Thomas E Adams
National Weather Service
Ohio River Forecast Center
1901 South State Route 134
Wilmington, OH 45177

EMAIL:	thomas.adams at noaa.gov

VOICE:	937-383-0528
FAX:	937-383-0033




More information about the grass-user mailing list