Coder Social home page Coder Social logo

Comments (6)

ecodiv avatar ecodiv commented on July 19, 2024 1

Thanks, I wonder if I introduced an error in #931. I'll do some further testing.

from grass-addons.

wenzeslaus avatar wenzeslaus commented on July 19, 2024 1

@ecodiv You can link the issue from the PR using "Closes #XYZ". Merging PR with this in the commit message will close the issue automatically. You can also link them from the web interface under Development. That may save you some writing and clicks overall. This will also ensure the standard behavior: it is customary to close the issue only after the PR was merged.

from grass-addons.

YannChemin avatar YannChemin commented on July 19, 2024

Using code from August 22, rebuilt grass + grass-addons from main, using the blue band of BMNG https://visibleearth.nasa.gov/images/57752/blue-marble-land-surface-shallow-water-and-shaded-topography.

Make it Float

r.mapcalc expression="bmngfloat=bmng.blue/100.0"

Map 1

r.fuzzy.set --overwrite input=bmngfloat@PERMANENT output=out1 points=0.5,0.6 side=left shape=0.5

image

Map 2

r.fuzzy.set --overwrite input=bmngfloat@PERMANENT output=out points=0.5,0.6 side=left shape=0.1

image

from grass-addons.

ecodiv avatar ecodiv commented on July 19, 2024

Hi @YannChemin, below a reproducible example.

The example data used in this example is the landsat layer lsat5_1987_10@landsat from the North Carolina full dataset (https://grass.osgeo.org/download/data/).

Step 1. Set the region to match the raster layer and create a floating raster layer.

g.region raster=lsat5_1987_10
r.mapcalc "inputmap = lsat5_1987_10 / 10.0"

Step 2. Install the r.fuzzy_set addon, if not done already.

g.extension extension=r.fuzzy.set                                               

Step 3. Run the function using as input the lsat5_1987_10 raster layer as input. Fill in the output name test01, set minimum (A) and maximum inflection points to match the minimum and maximum value of the raster layer and the side to left. Keep the default input for the other parameters. That is, shape modifier (shape) = 0 and membership height (height) = 1.

# Get the minimum, maximum and mean values
r.univar map=inputmap

The minimum = 4.5 and maximum = 25.4. Use this to set the A (lower boundary) and B (upper boundary) inflection points.

r.fuzzy.set input=inputmap output=test00 points=4.5,25.4 side=left

Step 4. Repeat the above twice, changing the shape modifier (shape) to 0.1, 0.5 and 0.9.

r.fuzzy.set input=inputmap output=test01 points=4.5,25.4 side=left shape=0.1 --overwrite
r.fuzzy.set input=inputmap output=test05 points=4.5,25.4 side=left shape=0.5 --overwrite
r.fuzzy.set input=inputmap output=test09 points=4.5,25.4 side=left shape=0.9 --overwrite

Check if there are differences between the output maps.

r.mapcalc "diff00_01 = test00 - test01"
r.univar map=diff00_01
r.mapcalc "diff00_05 = test00 - test05"
r.univar map=diff00_05
r.mapcalc "diff01_05 = test01 - test05"
r.univar map=diff00_05
r.mapcalc "diff01_09 = test01 - test09"
r.univar map=diff01_09

The r.univar outcomes show that the maps are identical. Results correspond to what one would expect when using the shape=0 parameter.

Step 5. Now, let's try with negative values for the shape parameter.

r.fuzzy.set input=inputmap output=testmin01 points=4.5,25.4 side=left shape=-0.1 --overwrite
r.fuzzy.set input=inputmap output=testmin05 points=4.5,25.4 side=left shape=-0.5 --overwrite
r.fuzzy.set input=inputmap output=testmin09 points=4.5,25.4 side=left shape=-0.9 --overwrite

Check if there are differences between the output maps.

r.mapcalc "diffmin09_09 = testmin09 - test09"
r.univar map=diffmin09_09
r.mapcalc "diffmin01_min05 = testmin01 - testmin05"
r.univar map=diffmin01_min05
r.mapcalc "diffmin01_min09 = testmin01 - testmin09"
r.univar map=diffmin01_min09

Results based on negative shape values differ from those based on positive shape values. But, results show that outcomes for negative shape values are all the same, corresponding to what one would expect when using the shape=-1 parameter (note that there is a unrelated error in how the values are calculated as described in #931).

I am on Ubuntu 22.04, GRASS GIS 8.3.1dev (ce5a0a5694). Results are the same on Windows 10, GRASS GIS 8.3.

from grass-addons.

ecodiv avatar ecodiv commented on July 19, 2024

The problem was the use of the abs function, which works for integer values. Replacing it with the fabs function, which works with floating and double values, solves the problem. Tested using the code above. Solution included in the PR #931

from grass-addons.

ecodiv avatar ecodiv commented on July 19, 2024

Closing since the issue is solved with PR #931

from grass-addons.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.