Skip to content

[Bug] r.sun gives erroneous results when used with r.horizon for a 15 deg slope hillock #2935

@girishnand

Description

@girishnand

Describe the bug

Output of r.sun is radically different based on whether r.horizon is or is not used. The difference is significant both qualitatively as well as quantitatively.

rsun1

rsun2

The elevation raster is a small square hillock with a flat square central region and surfaces sloping downward at 15 degrees towards north, south, east and west to its north, south, east and west respectively. The location lat-long are Latitude : 34.179N, and Longtitude : -118.556. The output rasters above show Global Insolation for April 15th.

Here's the input raster file: hot.txt

For this location at 34 deg N, we can expect the south face to have the greatest insolation and the north face to have the least. This is what the output without r.horizon shows, but the case where r.horizon is used shows the exact opposite. I have used r.horizon with 10 degree horizon steps, but the result with horizon_step=5 is the same.

To Reproduce

#I use epsg:32611 corresponding to UTM zone 11N for the above lat-long.  
g.proj -c epsg=32611 location=MyLocation
g.mapset mapset=PERMANENT location=MyLocation

r.in.gdal -o input=file-path\hot.txt output=hotraster
g.region raster=hotraster

r.latlong input=hotraster output=hotlatitude
r.latlong input=hotraster output=hotlongitude -l
r.slope.aspect elevation=hotraster slope=slope aspect=aspect

r.horizon elevation=hotraster step=10 output=hor10angle distance=0.5

r.sun elevation=hotraster horizon_basename=hor10angle horizon_step=10 slope=slope aspect=aspect lat=hotlatitude long=hotlongitude step=0.25 nprocs=10 day=105 glob_rad=Apr15h10 --verbose

r.sun elevation=hotraster slope=slope aspect=aspect lat=hotlatitude long=hotlongitude step=0.25 nprocs=10 day=105 glob_rad=Apr15 --verbose

Expected behavior
The output with and without r.horizon should be identical for the most part. The south facing slope should show the greatest global insolation compared to the other faces. There is also a slight east-west asymmetry in the output when r.horizon is used. For a symmetric raster aligned with the cardinal directions, this should not be so.

System description (please complete the following information):
I am using Windows 11 with the following GRASS GIS 8.3 developmental build - WinGRASS-8.3.dev-c05cc14387-42-Setup.exe But results with 8.2.1 which has been released are identical.

C:\Users\Girish>g.version -rge
version=8.3.dev
date=2023
revision=c05cc14387
build_date=2023-04-24
build_platform=x86_64-w64-mingw32
build_off_t_size=8
libgis_revision=a82501dc85
libgis_date=2023-02-27T12:45:25+00:00
proj=9.2.0
gdal=3.6.4
geos=3.11.2
sqlite=3.41.1

regards,
Girish.

Metadata

Metadata

Assignees

No one assigned

    Labels

    CRelated code is in CbugSomething isn't workingrasterRelated to raster data processing

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions