[GRASSLIST:673] Re: raster categories and floating point attribute values

Michel Wurtz mjwurtz at wanadoo.fr
Wed Jul 9 16:01:07 EDT 2003


Steven Stoddard wrote:
> I am currently in the process of learning grass and trying to assemble a 
> database to work off of for my research.  I am importing many files and 
> trying to get them into a raster format that is amenable to 
> analysis--floating point or integer maps.  I have maps though that were 
> imported from .e00 that are in raster format, but are categorized 
> sequentially (e.g. 1-120) and their labels are a floating point value.  
> How do I get rid of the category number and instead have only the fp 
> value so I can do manipulations with mapcalc etc?
> Just for background, the imported map was first in vector format and all 
> polygons were assigned a unique id with a floating point value as the 
> attribute.  I reclassified this map so that the categories at least 
> corresponded to same floating point values and were sorted in increasing 
> fashion.

You can use r.reclass the same way as v.reclass on the file imported with
m.in.e00 : just transform the cat file in soething usable as input for
r.reclass.  What I don't know is how to force the resulting file to be
a floating value raster...  Maybe it is easier to start from the vector
file and use v.to.rast (with the appropriate dig_cats file) to produce
the raster file...

Here follows a copy a message I posted some days ago :

As a reminder : If there is only one attribute (other than the standard ESRI
attributes for lines or areas), ther is only one dig_cats file created, and
its name is like the dig file name.  If there is many attributes, there is
as many dig_cats files, named <vector_file_name>.<attribute_name>.  In this case
the first thing to do is to go in the dig_cats directory and set a symbolic
link to the dig_cats file you want as the new dig_att values.

After that, you need only a two line command to change the att values.  The
best is to take an example :

dig file name is brucom,
dig_att/brucom looks like :

# 48 categories
brucom

0.00 0.00 0.00 0.00
1:67482
2:67492
3:67354
4:67240
etc.

What you have to type :

export LOCATION=<your mpaset location>
sed -e '1,4d' -e 's/:/ = /' $LOCATION/dig_cats/brucom | v.reclass input=brucom 
output=brucom1 type=area
v.support brucom1

The first line was added since $LOCATION is no longer set at grass startup...
The second one do the job : sed convert the dig_att file in a form usable by
v.reclass. You have to change
  - the file names and the location (obviously)
  - the type=area in type=line if you have lines instead of areas

The third line is mandatory for some other programs to work (v.digit, d.what.vect,
etc.)

-- 
Michel Wurtz - Auzeville-Tolosane




More information about the grass-user mailing list