Hi Anna
Just an idea I got when using r.ctp2grass for some climate data. Climate
data layers are often multiplied by a factor 10 so they can be
distributed as integer rasters while still maintaining a desired degree
of precision. This made me think that it would be nice if I could create
a color rules file using r.ctp2grass with the option to multiply the
default values as defined in the ctp file. Perhaps something along the
lines of attached patch file for r.ctp2grass (for illustrative purposes,
I am sure things can be done better)? Is that something that could be
implemented? Something similar could perhaps be nice for r.colors as
well when using one of the included color tables (but only those based
on values rather than percentages obviously).
Cheers,
Paulo
--- /home/paulo/Software/spatial/grass-addons/raster/r.cpt2grass/r.cpt2grass.py
+++ /home/paulo/.grass7/addons/scripts/r.cpt2grass
@@ -43,6 +43,13 @@
#%option G_OPT_F_OUTPUT
#% description: Name for new rules file
#% required: no
+#%end
+#%option
+#% key: multi
+#% type: integer
+#% description: multiply values
+#% required: no
+#% multiple: no
#%end
#%flag
#% key: s
@@ -139,6 +146,7 @@
else:
with open(input_file, 'r') as f:
txt = f.readlines()
+ multi = options['multi']
model = 'RGB' # assuming RGB
cpt_rules = []
@@ -174,6 +182,10 @@
if flags['s']:
v1 = 100 * (cpt_range - (cpt_max - v1)) / cpt_range
v2 = 100 * (cpt_range - (cpt_max - v2)) / cpt_range
+ else:
+ if len(multi)>0:
+ v1 = v1 * float(multi)
+ v2 = v2 * float(multi)
rules.append("{v:.3f}{perc} {r}:{g}:{b}".format(v=v1, perc='%' if flags['s'] else '',
r=r1, g=g1, b=b1))
rules.append("{v:.3f}{perc} {r}:{g}:{b}".format(v=v2, perc='%' if flags['s'] else '',
_______________________________________________
grass-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-dev