[GRASS-user] Generating categorical int values from a string attribute for use with v.to.rast

Damian Maddalena damianmaddalena at gmail.com
Thu Nov 15 09:06:08 PST 2018


Hi Helmut,

Thank you for your reply. There are many potential categories and 
thousands of polygons, do you have insight on how to assign int values 
on-the-fly using v.db.update? Hard coding all potential values would be 
cumbersome in this application. :)

-Damian


On 11/15/18 11:36 AM, Helmut Kudrnovsky wrote:
> Damian Maddalena wrote
>> I am trying to convert vector SSURGO soils data to a raster using
>> v.to.rast. The attribute I want to use for the conversion is a
>> categorical string describing soil type, so I need to generate int
>> categories before converting. I explored v.category for doing this, but
>> I'm not sure it's what I'm looking for. I want to assign all polygons
>> with the same soil description the same number. For example, output from
>> `v.db.select map=soils | head` is below.  I want to create a new
>> attribute based on "sm_soil_se" called "sm_soil_se_int" that is a
>> categorical int value for each string category. I don't care what the
>> numbers are, so long as each of the polygons with the same string value
>> have the same categorical int value. (I will assign the string values to
>> each int category using the "label_column" parameter.)
>>
>> Is there an existing GRASS command that will do this? If not, should I
>> be using Python?
>>
>> Thank  you!!
>>
>> -Damian
>>
>> cat|sm_mapunit|sm_mapun_1|sm_soil_se|sm_csr|rating
>> 1|160|456713|"Xerorthents-Millsholm complex, 50 to 75 percent slopes"||10
>> 2|TaE|455865|"Tierra loam, 15 to 30 percent slopes, MLRA 14"||40
>> 3|CoF|455785|"Cut and fill land-Millsholm complex, 30 to 50 percent
>> slopes"||20
>> 4|MeG|455829|"Millsholm loam, 20 to 60 percent slopes, moist, MLRA 15"||10
>> 5|LeF|455816|"Los Gatos loam, 30 to 50 percent slopes"||20
>> 6|GcF|455802|"Los Gatos loam, 30 to 50 percent slopes"||20
>>
>> -- 
>> “Science knows it doesn't know everything; otherwise, it'd stop." ~Dara
>> O'Briain
>>
>> _______________________________________________
>> grass-user mailing list
>> grass-user at .osgeo
>> https://lists.osgeo.org/mailman/listinfo/grass-user
> See
>
> https://grass.osgeo.org/grass76/manuals/v.db.update.html
>
>
>
> -----
> best regards
> Helmut
> --
> Sent from: http://osgeo-org.1560.x6.nabble.com/Grass-Users-f3884509.html
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/grass-user

-- 
“Science knows it doesn't know everything; otherwise, it'd stop." ~Dara O'Briain

Dr. Damian Maddalena
5020 Huntingdon Dr.
Raleigh, NC 27606

phone: 919-264-1974
email: damianmaddalena at gmail.com



More information about the grass-user mailing list