[GRASS5] Asking about feasibility of an addition to r.recode

Michael Barton michael.barton at asu.edu
Tue Apr 4 01:10:18 EDT 2006


Helena already suggested your first idea, using v.in.ascii, v.to.rast, and
either r.mapcalc or r.patch. We'll try that to get started. However, I'll
probably need to script it to make it easier to do from an external Java
program. I don't know what the performance hit will be to do it this way,
but at least it should work so that we can get started.

Your second suggestion is interesting, that it would be better to do it in a
separate module than alter r.recode. Your points about feature creep is
well-taken, though I'm not sure that it would apply here in the modeling
case. In fact, a simple xy cat list might actually be better for modeling
than defining a geometric area.

However, what you suggest in the 'feature creep' section sounds like a
command-line module to replace r.digit and which could be run from any
generic GUI. That could be useful for dual purposes in this event. ;-)


On 4/3/06 8:53 PM, "Glynn Clements" <glynn at gclements.plus.com> wrote:

> Michael Barton wrote:
>> I�m involved in a project to develop a linkage between agent based modeling
>> platforms and GRASS. One item that seems will be very important is way to
>> change a group of cell values (i.e., cat values) given their xy coordinates.
>> I realize that it is possible to use the map calculator to create a new map
>> with 1 new cell changed. But AFAICT, there is no way to send a set of xy
>> values, along with new cat values for each xy pair and change cells in an
>> existing map or create a new map with the changed cells (and old values for
>> the rest of the cells).
> If you can create a raster map containing only the new cells, with
> null elsewhere, you can patch it together with the old map to get the
> updated map. In 5.3, the first step could be done with s.in.ascii +
> s.to.rast; does v.in.ascii + v.to.rast not work with points?
>> Markus suggested that I run this by the developers
>> list. I can make this a formal �wish� if it helps.
>>> From the perspective of someone who is fairly ignorant of C, it seems to me
>> that the (conceptually at least) easiest thing to do is to alter r.recode to
>> accept input (stdin or text file) in the form of
>> x1,y1,val1
>> x2,y2,val2
> r.recode doesn't seem like a significantly better match than any other
> raster processing tool. IMHO, this should be a separate tool rather
> than a modification to r.recode.
>> or even better, if we want to keep a similar format to that now used for cat
>> value recoding
>> x1:x2:y1:y2 val1
>> x3:x4:y3:y4 val2
>> where x1:x2 defines a range of x coordinates and y1:y2 defines a range of y
>> coordinates. This way single cells or blocks of cells could be referenced
>> and changed. This mode would probably open up a number of new modeling
>> possibilities within GRASS too.
>> This mode could be controlled by a flag. What do you all think? Is this
>> feasible? Is it fairly easy or fairly difficult? Is there a better way to
>> change a group of cell values based on their xy coordinates?
> The implementation is straightforward enough, at least for individual
> pixels. Primarily, the input list needs to be sorted in descending
> order of y coordinate (i.e. ascending row numbers), so that the map
> can be processed one row at a time.
> For rectangles, the process is similar, but you need to maintain a
> list of "active" rectangles (those which intersect the current row).
> The list would need to be sorted in order of the top edge.
> I wouldn't make it read an existing map, just write out nulls for
> cells which aren't defined by the input. r.patch can be used to update
> an existing map if desired.
> The main problems I foresee is feature creep. If you support points
> and rectangles, you will end up getting requests to add circles,
> lines, polygons, etc. There will always be a point at which the
> specific tool is inadequate and you need to import your updates as a
> vector map then rasterise it with v.to.rast.

Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University

WWW - http://www.public.asu.edu/~cmbarton
Phone: 480-965-6262
Fax: 480-965-7671

More information about the grass-dev mailing list