[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 08:10:44 PST 2018


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



More information about the grass-user mailing list