Comments (6)
You need to add the -d
flag to your command to achieve your expected results:
-d Force output to 'double' raster map type (DCELL)
Try:
echo "0.0:18.7:0.0:1.0" | r.recode -d input=myinput output=myoutput rules=-
from grass.
You need to add the
-d
flag to your command to achieve your expected results:
-d Force output to 'double' raster map type (DCELL)
Try:
echo "0.0:18.7:0.0:1.0" | r.recode -d input=myinput output=myoutput rules=-
Thanks. I know you can use the -d flag (and I wrote that in the bug report), but the point I was trying to make is that based on the manual, I would not necessarily expect r.recode to convert the floating map to an integer map, as I used decimal numbers for the new minimum and maximum value. I think that either the behavior should be changed, or the behavior (when does the function change the data type) should be explained more explicitly.
from grass.
I know you can use the -d flag (and I wrote that in the bug report)
I see, I missed that.
based on the manual, I would not necessarily expect r.recode to convert the floating map to an integer map, as I used decimal numbers for the new minimum and maximum value. I think that either the behavior should be changed, or the behavior (when does the function change the data type) should be explained more explicitly.
I agree with this. I also find the manual confusing on this regard. The manual first states that r.recode is for recoding categorical maps, which it seems to be made for, but then gives an example of rescaling, for which r.mapcalc is more convenient.
from grass.
This seems like a bug to me.
r.recode
appears to be intended to produce FCELL results too. See e.g.: https://github.com/OSGeo/grass/blob/25961a86c26765f293d582900b00bb37403a780d/raster/r.recode/read_rules.c#L143C25-L143C29
from grass.
It seems that the problem lies in parsing or managing the input, as numbers ending in zero are not interpreted as float.
Example:
echo "0.0:18.7:0.0:1.0" | r.recode input=r output=test rules=- --overwrite
produces a raster of type CELL
while
echo "0.0:18.7:0.01:1.0" | r.recode input=r output=test rules=- --overwrite
or
echo "0.0:18.7:0.0:1.01" | r.recode input=r output=test rules=- --overwrite
produce rasters of type FCELL
Edit: deleted reference to rules, as I could not trace the exact source of the problem.
from grass.
It seems to me that this part in read_rules.c
is not working as intended:
grass/raster/r.recode/read_rules.c
Lines 136 to 146 in f4d8c62
Perhaps line 142 could be replaced with a call to a function to tell if val
is a float or integer. . I am not so fluent in C but it seems that is not so straightforward.
A simple work around could be to default output to integer, unless it is forced to double using the -d
switch, or to float using a new switch, for example: -f. This I just tested and works. But it is perhaps not the expected behaviour? Also it adds a new switch and may break backwards compatibility.
from grass.
Related Issues (20)
- [Bug] db.univar: fails on Windows due to unix style sort being used HOT 10
- Remove special display size for arm from init HOT 1
- Use sys.executable instead of hardcoded python for GRASS_PYTHON
- Setup and use for macOS of GRASS_HTML_BROWSER in init and g.manual
- Update list to translate from commit email to GitHub user name HOT 1
- [Bug] Reduce or remove hardcoded versions in Dockerfiles
- [Feat] Remove version from executable on Windows HOT 6
- [Feat] Use Ubuntu 24.04 runners in CI
- [Bug] r.texture: test_sv fails on Mac with arm64 HOT 2
- [Feat] v.rectify: output Affine a,b,c,d coefficients to RMS errors file HOT 2
- docker: Set up reproducible docker image build workflows
- [Bug] i.atcorr: create_iwave does not work with sentinel_2B
- r.in.pdal handling the number of returns HOT 6
- [Bug] g.gui.gmodeler: defining relations fails
- [Bug] g.gui.gmodeler: adding solely data fails HOT 1
- [Bug] v.db.join fails, existing cat HOT 4
- [Bug] g.gui.gmodeler: parameters get deleted from the module call when opening it twice
- [Bug] g.gui.gmodeler: having `%` in module's arguments makes the model invalid
- Getting (also) the installed extensions with get_commands()
- [Doc] Update Unit Test documentation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grass.