[GRASS-user] Raster - assign interpolated values into range

Hi,

After creating a raster (2 or 3d) is there a way that interpolated values (floats) can be assigned a specific value based on range. example: 0.01, 0.2 0.52, 0.67, 0.99, values between 0.01 and 0.5 assign 0.25; values between 0.5 and 1, assign 0.75.

thanks,
F

Have you checked r.recode[0]?

HTH,
Vero

[0] https://grass.osgeo.org/grass76/manuals/r.recode.html

El sáb., 23 feb. 2019 09:45, Francois Chartier <fra.chartier@gmail.com> escribió:

Hi,

After creating a raster (2 or 3d) is there a way that interpolated values (floats) can be assigned a specific value based on range. example: 0.01, 0.2 0.52, 0.67, 0.99, values between 0.01 and 0.5 assign 0.25; values between 0.5 and 1, assign 0.75.

thanks,
F


grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user

On Sat, Feb 23, 2019 at 1:45 PM Francois Chartier <fra.chartier@gmail.com> wrote:

Hi,

After creating a raster (2 or 3d) is there a way that interpolated values (floats) can be assigned a specific value based on range. example: 0.01, 0.2 0.52, 0.67, 0.99, values between 0.01 and 0.5 assign 0.25; values between 0.5 and 1, assign 0.75.

if you want to assign values to 0.25, 0.75, 1.25, 1.75, etc., i.e. new values with a constant spacing of 0.5, you can use

r.mapcalc “output = round(input, 0.5, 0.25)”

Markus M

thanks,
F


grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user

El sáb., 23 feb. 2019 12:17, Markus Metz <markus.metz.giswork@gmail.com> escribió:

On Sat, Feb 23, 2019 at 1:45 PM Francois Chartier <fra.chartier@gmail.com> wrote:

Hi,

After creating a raster (2 or 3d) is there a way that interpolated values (floats) can be assigned a specific value based on range. example: 0.01, 0.2 0.52, 0.67, 0.99, values between 0.01 and 0.5 assign 0.25; values between 0.5 and 1, assign 0.75.

if you want to assign values to 0.25, 0.75, 1.25, 1.75, etc., i.e. new values with a constant spacing of 0.5, you can use

r.mapcalc “output = round(input, 0.5, 0.25)”

Ah! So cool!! 8)

What about if i dont want constant spacing but at certain ranges?

Le sam. 23 févr. 2019 à 11:00, Veronica Andreo <veroandreo@gmail.com> a écrit :

El sáb., 23 feb. 2019 12:17, Markus Metz <markus.metz.giswork@gmail.com> escribió:

On Sat, Feb 23, 2019 at 1:45 PM Francois Chartier <fra.chartier@gmail.com> wrote:

Hi,

After creating a raster (2 or 3d) is there a way that interpolated values (floats) can be assigned a specific value based on range. example: 0.01, 0.2 0.52, 0.67, 0.99, values between 0.01 and 0.5 assign 0.25; values between 0.5 and 1, assign 0.75.

if you want to assign values to 0.25, 0.75, 1.25, 1.75, etc., i.e. new values with a constant spacing of 0.5, you can use

r.mapcalc “output = round(input, 0.5, 0.25)”

Ah! So cool!! 8)

On 23/02/19 23:16, Francois Chartier wrote:

What about if i dont want constant spacing but at certain ranges?

Have you tried r.recode as Vero suggested ?

Moritz

Le sam. 23 févr. 2019 à 11:00, Veronica Andreo <veroandreo@gmail.com <mailto:veroandreo@gmail.com>> a écrit :

    El sáb., 23 feb. 2019 12:17, Markus Metz
    <markus.metz.giswork@gmail.com
    <mailto:markus.metz.giswork@gmail.com>> escribió:

        On Sat, Feb 23, 2019 at 1:45 PM Francois Chartier
        <fra.chartier@gmail.com <mailto:fra.chartier@gmail.com>> wrote:
         >
         > Hi,
         >
         > After creating a raster (2 or 3d) is there a way that
        interpolated values (floats) can be assigned a specific value
        based on range. example: 0.01, 0.2 0.52, 0.67, 0.99, values
        between 0.01 and 0.5 assign 0.25; values between 0.5 and 1,
        assign 0.75.

        if you want to assign values to 0.25, 0.75, 1.25, 1.75, etc.,
        i.e. new values with a constant spacing of 0.5, you can use

        r.mapcalc "output = round(input, 0.5, 0.25)"

    Ah! So cool!! 8)

_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user

doesnt work with 3d raster. only takes in 2d. i did it with access, more tedious but it works. i should be able to do this with the attribute table directly but havent tried yet.

On Mon, Feb 25, 2019, 05:57 Moritz Lennert <mlennert@club.worldonline.be wrote:

On 23/02/19 23:16, Francois Chartier wrote:

What about if i dont want constant spacing but at certain ranges?

Have you tried r.recode as Vero suggested ?

Moritz

Le sam. 23 févr. 2019 à 11:00, Veronica Andreo <veroandreo@gmail.com
mailto:[veroandreo@gmail.com](mailto:veroandreo@gmail.com)> a écrit :

El sáb., 23 feb. 2019 12:17, Markus Metz
<markus.metz.giswork@gmail.com
mailto:[markus.metz.giswork@gmail.com](mailto:markus.metz.giswork@gmail.com)> escribió:

On Sat, Feb 23, 2019 at 1:45 PM Francois Chartier
<fra.chartier@gmail.com mailto:[fra.chartier@gmail.com](mailto:fra.chartier@gmail.com)> wrote:

Hi,

After creating a raster (2 or 3d) is there a way that
interpolated values (floats) can be assigned a specific value
based on range. example: 0.01, 0.2 0.52, 0.67, 0.99, values
between 0.01 and 0.5 assign 0.25; values between 0.5 and 1,
assign 0.75.

if you want to assign values to 0.25, 0.75, 1.25, 1.75, etc.,
i.e. new values with a constant spacing of 0.5, you can use

r.mapcalc “output = round(input, 0.5, 0.25)”

Ah! So cool!! 8)


grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user

On 26/02/19 02:23, Francois Chartier wrote:

doesnt work with 3d raster. only takes in 2d. i did it with access, more tedious but it works. i should be able to do this with the attribute table directly but havent tried yet.

A raster doesn't have an attribute table, so this is not a solution. r3.mapcalc with nested rules such as this should work:

if(map >=0.01 && map < 0.5, 0.25, if(map < 1, 0.75, if(etc)))

But I do believe that r.reclass and r.recode are fundamental modules that should also exist for r3. So, I would suggest filling in an enhancement request ticket in trac.

Moritz

On Mon, Feb 25, 2019, 05:57 Moritz Lennert <mlennert@club.worldonline.be <mailto:mlennert@club.worldonline.be> wrote:

    On 23/02/19 23:16, Francois Chartier wrote:
     > What about if i dont want constant spacing but at certain ranges?

    Have you tried r.recode as Vero suggested ?

    Moritz

     >
     > Le sam. 23 févr. 2019 à 11:00, Veronica Andreo
    <veroandreo@gmail.com <mailto:veroandreo@gmail.com>
     > <mailto:veroandreo@gmail.com>> a
    écrit :
     >
     > El sáb., 23 feb. 2019 12:17, Markus Metz
     > <markus.metz.giswork@gmail.com
    <mailto:markus.metz.giswork@gmail.com>
     > <mailto:markus.metz.giswork@gmail.com
    <mailto:markus.metz.giswork@gmail.com>>> escribió:
     >
     > On Sat, Feb 23, 2019 at 1:45 PM Francois Chartier
     > <fra.chartier@gmail.com <mailto:fra.chartier@gmail.com>
    <mailto:fra.chartier@gmail.com>> wrote:
     > >
     > > Hi,
     > >
     > > After creating a raster (2 or 3d) is there a way that
     > interpolated values (floats) can be assigned a specific value
     > based on range. example: 0.01, 0.2 0.52, 0.67, 0.99, values
     > between 0.01 and 0.5 assign 0.25; values between 0.5 and 1,
     > assign 0.75.
     >
     > if you want to assign values to 0.25, 0.75, 1.25, 1.75, etc.,
     > i.e. new values with a constant spacing of 0.5, you can use
     >
     > r.mapcalc "output = round(input, 0.5, 0.25)"
     >
     > Ah! So cool!! 8)
     >
     > _______________________________________________
     > grass-user mailing list
     > grass-user@lists.osgeo.org <mailto:grass-user@lists.osgeo.org>
     > https://lists.osgeo.org/mailman/listinfo/grass-user
     >

thanks, i will submit a ticket in trac.

On Tue, Feb 26, 2019, 07:33 Moritz Lennert <mlennert@club.worldonline.be wrote:

On 26/02/19 02:23, Francois Chartier wrote:

doesnt work with 3d raster. only takes in 2d. i did it with access, more
tedious but it works. i should be able to do this with the attribute
table directly but havent tried yet.

A raster doesn’t have an attribute table, so this is not a solution.
r3.mapcalc with nested rules such as this should work:

if(map >=0.01 && map < 0.5, 0.25, if(map < 1, 0.75, if(etc)))

But I do believe that r.reclass and r.recode are fundamental modules
that should also exist for r3. So, I would suggest filling in an
enhancement request ticket in trac.

Moritz

On Mon, Feb 25, 2019, 05:57 Moritz Lennert <mlennert@club.worldonline.be
mailto:[mlennert@club.worldonline.be](mailto:mlennert@club.worldonline.be) wrote:

On 23/02/19 23:16, Francois Chartier wrote:

What about if i dont want constant spacing but at certain ranges?

Have you tried r.recode as Vero suggested ?

Moritz

Le sam. 23 févr. 2019 à 11:00, Veronica Andreo
<veroandreo@gmail.com mailto:[veroandreo@gmail.com](mailto:veroandreo@gmail.com)
<mailto:veroandreo@gmail.com mailto:[veroandreo@gmail.com](mailto:veroandreo@gmail.com)>> a
écrit :

El sáb., 23 feb. 2019 12:17, Markus Metz
<markus.metz.giswork@gmail.com
mailto:[markus.metz.giswork@gmail.com](mailto:markus.metz.giswork@gmail.com)
<mailto:markus.metz.giswork@gmail.com
mailto:[markus.metz.giswork@gmail.com](mailto:markus.metz.giswork@gmail.com)>> escribió:

On Sat, Feb 23, 2019 at 1:45 PM Francois Chartier
<fra.chartier@gmail.com mailto:[fra.chartier@gmail.com](mailto:fra.chartier@gmail.com)
<mailto:fra.chartier@gmail.com mailto:[fra.chartier@gmail.com](mailto:fra.chartier@gmail.com)>> wrote:

Hi,

After creating a raster (2 or 3d) is there a way that
interpolated values (floats) can be assigned a specific value
based on range. example: 0.01, 0.2 0.52, 0.67, 0.99, values
between 0.01 and 0.5 assign 0.25; values between 0.5 and 1,
assign 0.75.

if you want to assign values to 0.25, 0.75, 1.25, 1.75, etc.,
i.e. new values with a constant spacing of 0.5, you can use

r.mapcalc “output = round(input, 0.5, 0.25)”

Ah! So cool!! 8)


grass-user mailing list
grass-user@lists.osgeo.org mailto:[grass-user@lists.osgeo.org](mailto:grass-user@lists.osgeo.org)
https://lists.osgeo.org/mailman/listinfo/grass-user