# Wradlib.vis.plot\_scan\_strategy - wrong altitude

**URL:** <https://openradar.discourse.group/t/wradlib-vis-plot-scan-strategy-wrong-altitude/343>\
**Category:** General\
**Created:** [November 15, 2023, 10:58am UTC](https://openradar.discourse.group/t/wradlib-vis-plot-scan-strategy-wrong-altitude/343 "2023-11-15T10:58:20Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![lou](https://avatars.discourse-cdn.com/v4/letter/l/ea666f/32.png) [@lou](https://openradar.discourse.group/u/lou)\
**Post date:** [November 15, 2023, 10:58am UTC](https://openradar.discourse.group/t/wradlib-vis-plot-scan-strategy-wrong-altitude/343/1 "2023-11-15T10:58:20Z")

</div>

Hello everyone,

I am new to this area, but i am wondering if someone else has as well encountered the error message by plotting the scan\_strategy-function?

Plotting the scan strategy with: ax = wradlib.vis.plot\_scan\_strategy(ranges, elevs, sitecoords, beamwidth=vol.how.beamwH) works fine. But if I want to use:

ax = wradlib.vis.plot\_scan\_strategy(ranges, elevs, sitecoords, cg=True, terrain=True) → I get: TypeError: download\_srtm() takes 2 positional arguments but 3 were given.

Now, ax = wradlib.vis.plot\_scan\_strategy(ranges, elevs, sitecoords, beamwidth=vol.how.beamwH, cg=True) runs fine BUT the altitude is shifted by -1000 as MSL is now there.

The variables in the scan strategy are given by:

‘’’  
ranges = swp\_0.range.values  
sitecoords = (  
swp\_0.longitude.values.item(),  
swp\_0.latitude.values.item(),  
swp\_0.altitude.values.item(),  
)  
sweeps = list(vol.keys())[:-3]  
elevs =   
for dataset in sweeps:  
elangle = vol[dataset][“where”].elangle  
elevs.append(elangle)  
‘’’

I hope that someone can help me out on how to fix this issue.

Best, Julian

---

<div class="post-metadata">

**Author:** ![kmuehlbauer](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/kmuehlbauer/32/439_2.png) [@kmuehlbauer](https://openradar.discourse.group/u/kmuehlbauer)\
**Post date:** [November 15, 2023, 1:58pm UTC](https://openradar.discourse.group/t/wradlib-vis-plot-scan-strategy-wrong-altitude/343/2 "2023-11-15T13:58:17Z")

</div>

This should be fixed in wradlib 2.0.2

But you’ll need a EARTHDATA account correctly setup:

See [Plotting Radar Scan Strategy — wradlib](https://docs.wradlib.org/en/latest/notebooks/visualisation/plot_scan_strategy.html#Plot-Terrain).

HTH,  
Kai

---

<div class="post-metadata">

**Author:** ![lou](https://avatars.discourse-cdn.com/v4/letter/l/ea666f/32.png) [@lou](https://openradar.discourse.group/u/lou)\
**Post date:** [November 16, 2023, 8:55am UTC](https://openradar.discourse.group/t/wradlib-vis-plot-scan-strategy-wrong-altitude/343/3 "2023-11-16T08:55:45Z")

</div>

Hi Kai,

thanks a lot. I updated wradlib to 2.0.2, but I still get some errors. If I use:

```auto
ax = wradlib.vis.plot_scan_strategy(ranges,
                                    elevs,
                                    sitecoords,
                                    cg=True,
                                    az=180,                                    
                                    cmap="viridis",
                                    units='km',
                                    terrain=True)

```

everything works “fine”, but the MSL is still leveled at -1km. WHY? It is the same in the last figure of the wradlib-link you added above, and I don’t understand why it should be like this?

Furthermore, if i change az to something different than az=180, it gives me the following error message:

```auto
RuntimeError: No usable source images.

```

I am happy to hear from you,  
Julian

---

<div class="post-metadata">

**Author:** ![kmuehlbauer](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/kmuehlbauer/32/439_2.png) [@kmuehlbauer](https://openradar.discourse.group/u/kmuehlbauer)\
**Post date:** [November 16, 2023, 9:13am UTC](https://openradar.discourse.group/t/wradlib-vis-plot-scan-strategy-wrong-altitude/343/4 "2023-11-16T09:13:02Z")

</div>

Hi Julian,

not sure, it would be great, if you can make a little [MCVE](https://stackoverflow.com/help/minimal-reproducible-example) from your example. So at least give the input data you have used. This will help to reproduce issue and find a way around it.

This might be a bug using `units='km'`. Does it work if you omit that kwarg? Another possible cause might be broken `site_coords`.

Best,  
Kai

---

<div class="post-metadata">

**Author:** ![lou](https://avatars.discourse-cdn.com/v4/letter/l/ea666f/32.png) [@lou](https://openradar.discourse.group/u/lou)\
**Post date:** [November 16, 2023, 9:56am UTC](https://openradar.discourse.group/t/wradlib-vis-plot-scan-strategy-wrong-altitude/343/5 "2023-11-16T09:56:44Z")

</div>

That’s what I have so far:

```auto
import xarray as xr
import datatree
import wradlib
import os

os.environ["WRADLIB_EARTHDATA_BEARER_TOKEN"] = "my_bearer_token"
os.environ["WRADLIB_DATA"] = "/path/to/my/folder"

fname = "/home/ba9817/phd/finland/radar/hdf5/20220126/202201260930_fiika_PVOL.h5" # can be downloaded here: http://fmi-opendata-radar-volume-hdf5.s3-website-eu-west-1.amazonaws.com/?prefix=2022/01/26/fiika/

vol = datatree.open_datatree(fname)

# Calculating the elevation angles
sweeps = list(vol.keys())[:-3] 
elevs = []
for dataset in sweeps:
    elangle = vol[dataset]["where"].elangle
    elevs.append(elangle)

# Reading data from first sweep
swp_0 = xr.open_dataset(fname, engine="odim")

ranges = swp_0.range.values
sitecoords = (
    swp_0.longitude.values.item(),
    swp_0.latitude.values.item(),
    swp_0.altitude.values.item() 
)

ax = wradlib.vis.plot_scan_strategy(ranges,
                                    elevs,
                                    sitecoords,
                                    maxalt=15.0,
                                    cg=True,
                                    az=180,                                    
                                    cmap="viridis",
                                    units='km',
                                    terrain=True)

```

---

<div class="post-metadata">

**Author:** ![kmuehlbauer](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/kmuehlbauer/32/439_2.png) [@kmuehlbauer](https://openradar.discourse.group/u/kmuehlbauer)\
**Post date:** [November 16, 2023, 10:24am UTC](https://openradar.discourse.group/t/wradlib-vis-plot-scan-strategy-wrong-altitude/343/6 "2023-11-16T10:24:45Z")

</div>

@lou Code looks good. The `RuntimeError: No usable source images.` might it have to do with the coverage of the SRTM data? IIRC it’s only covered to 60deg north.

Do you have a local DEM covering whole of Finland? We might just skip the automated SRTM download and prepare the terrain ourselves from local DEM data. If you need help with that you might have a glimpse at [Beam Blockage Calculation using a DEM — wradlib](https://docs.wradlib.org/en/stable/notebooks/beamblockage/beamblockage.html#Preprocessing-the-digitial-elevation-model) how to interpolate a given DEM  
onto the radar polar layout.

The other thing, `maxalt` would still have to be given in meters (even if you specify ‘km’).

The altitude-problem is probably a bug in the curvelinear grid code, as the issue also shows up in the docs. Good catch! Would you mind opening an issue on the wradlib github issue tracker [Issues · wradlib/wradlib · GitHub](https://github.com/wradlib/wradlib/issues)?

---

<div class="post-metadata">

**Author:** ![kmuehlbauer](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/kmuehlbauer/32/439_2.png) [@kmuehlbauer](https://openradar.discourse.group/u/kmuehlbauer)\
**Post date:** [November 16, 2023, 10:32am UTC](https://openradar.discourse.group/t/wradlib-vis-plot-scan-strategy-wrong-altitude/343/7 "2023-11-16T10:32:11Z")

</div>

> [@kmuehlbauer](#):
>
> The altitude-problem is probably a bug in the curvelinear grid code, as the issue also shows up in the docs. Good catch! Would you mind opening an issue on the wradlib github issue tracker [Issues · wradlib/wradlib · GitHub](https://github.com/wradlib/wradlib/issues)?

Confirmed, it’s a bug, we get this offset of 1000m because we use two different earth radius in calculation and plotting (6370000 and 6371000). If you feel capable enough you can change the values to 6371000 as a quick fix:

> <https://github.com/wradlib/wradlib/blob/37bd09a39e31d74b43e1fbbe41cb4360acb402c4/wradlib/vis.py#L467-L468>

---

<div class="post-metadata">

**Author:** ![lou](https://avatars.discourse-cdn.com/v4/letter/l/ea666f/32.png) [@lou](https://openradar.discourse.group/u/lou)\
**Post date:** [November 16, 2023, 11:16am UTC](https://openradar.discourse.group/t/wradlib-vis-plot-scan-strategy-wrong-altitude/343/8 "2023-11-16T11:16:52Z")

</div>

Indeed, I forgot about that the SRTM data covers only the area up to 60deg north. I don’t have a local DEM covering Finland - I’ll have a look if I can find one and implement it.

Good to know about maxalt!

I think I don’t feel capable of fixing this in the code as I don’t know what the right way would be to do so.

---

<div class="post-metadata">

**Author:** ![kmuehlbauer](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/kmuehlbauer/32/439_2.png) [@kmuehlbauer](https://openradar.discourse.group/u/kmuehlbauer)\
**Post date:** [November 16, 2023, 3:55pm UTC](https://openradar.discourse.group/t/wradlib-vis-plot-scan-strategy-wrong-altitude/343/9 "2023-11-16T15:55:08Z")

</div>

@lou The altitude issue is fixed in wradlib 2.0.3, already available in PyPI. Next day in conda-forge.

---

<div class="post-metadata">

**Author:** ![syedhamidali](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/syedhamidali/32/377_2.png) [@syedhamidali](https://openradar.discourse.group/u/syedhamidali)\
**Post date:** [November 17, 2023, 5:15pm UTC](https://openradar.discourse.group/t/wradlib-vis-plot-scan-strategy-wrong-altitude/343/10 "2023-11-17T17:15:24Z")

</div>

You might wanna take a look at this topography:  
[https://portal.opentopography.org/datasets?minX=7.2674560546874565&minY=63.01448255321023&maxX=41.27563476562497&maxY=71.86221497468833](https://portal.opentopography.org/datasets?minX=7.2674560546874565&minY=63.01448255321023&maxX=41.27563476562497&maxY=71.86221497468833)

---

<div class="post-metadata">

**Author:** ![lou](https://avatars.discourse-cdn.com/v4/letter/l/ea666f/32.png) [@lou](https://openradar.discourse.group/u/lou)\
**Post date:** [November 21, 2023, 9:31am UTC](https://openradar.discourse.group/t/wradlib-vis-plot-scan-strategy-wrong-altitude/343/11 "2023-11-21T09:31:01Z")

</div>

I have as well found: [Karttapaikka - Maanmittauslaitos](https://asiointi.maanmittauslaitos.fi/karttapaikka/tiedostopalvelu/korkeusmalli)

I downloaded some Geo-Tiff files that I need. But I could not figure out how I should now process these data in order to implement it into the scan\_strategy-function? Would you mind to help me out?

And, @kmuehlbauer, is there a way to add a star or a dot on the MSL (e.g. a location that is 60km away from the radar station) with some text?

---

<div class="post-metadata">

**Author:** ![kmuehlbauer](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/kmuehlbauer/32/439_2.png) [@kmuehlbauer](https://openradar.discourse.group/u/kmuehlbauer)\
**Post date:** [November 21, 2023, 10:04am UTC](https://openradar.discourse.group/t/wradlib-vis-plot-scan-strategy-wrong-altitude/343/12 "2023-11-21T10:04:23Z")

</div>

> [@lou](#):
>
> And, @kmuehlbauer, is there a way to add a star or a dot on the MSL (e.g. a location that is 60km away from the radar station) with some text?

```python
ax = wradlib.vis.plot_scan_strategy(ranges,
                                    elevs,
                                    sitecoords,
                                    maxalt=15000.0,
                                    cg=True,
                                    az=10,                                    
                                    cmap="viridis",
                                    units='km',
                                    terrain=False)
# get polar parasite axis
paax = ax.parasites[1]
# use this as earth radius
er = 6371000
# the distance in m
rng = 60000
# calculate bin distance
ade = wradlib.georef.bin_distance(rng, 0, sitecoords[2], ke=1.0)
# get angle
thetap = -np.degrees(ade / er) + 90.0
# plot the stuff at the wanted location
paax.plot(thetap, er, "r*", linewidth=3, label="RAD", zorder=3)
paax.text(thetap, er, "Radar", zorder=3)

```

---

<div class="post-metadata">

**Author:** ![kmuehlbauer](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/kmuehlbauer/32/439_2.png) [@kmuehlbauer](https://openradar.discourse.group/u/kmuehlbauer)\
**Post date:** [November 21, 2023, 10:11am UTC](https://openradar.discourse.group/t/wradlib-vis-plot-scan-strategy-wrong-altitude/343/13 "2023-11-21T10:11:18Z")

</div>

> [@lou](#):
>
> I downloaded some Geo-Tiff files that I need. But I could not figure out how I should now process these data in order to implement it into the scan\_strategy-function? Would you mind to help me out?

Takes a while, need to find a bit of time doing that. You might explore GDAL merge [gdal\_merge.py — GDAL documentation](https://gdal.org/programs/gdal_merge.html) on how to merge the tiles. After that just follow-up with the preprocessing steps [Beam Blockage Calculation using a DEM — wradlib](https://docs.wradlib.org/en/stable/notebooks/beamblockage/beamblockage.html#Preprocessing-the-digitial-elevation-model) how to interpolate the DEM onto the radar polar grid. Then just feed the wanted azimuth to terrain (`ax = wrl.vis.plot_scan_strategy(ranges, elevs, site, units="km", terrain=polarvalues[wanted_azi]`).

HTH,  
Kai

---

<div class="post-metadata">

**Author:** ![lou](https://avatars.discourse-cdn.com/v4/letter/l/ea666f/32.png) [@lou](https://openradar.discourse.group/u/lou)\
**Post date:** [November 21, 2023, 1:24pm UTC](https://openradar.discourse.group/t/wradlib-vis-plot-scan-strategy-wrong-altitude/343/14 "2023-11-21T13:24:37Z")

</div>

Thanks. That workes perfeclty 🙂

Maybe, you can have a look - when you have a spare minute - as well at:

```auto
ax = wradlib.vis.plot_scan_strategy(ranges,
                                    elevs,
                                    sitecoords,
                                    maxrange=120000.0,
                                    cg=True,
                                    az=180,
                                    cmap="viridis",
                                    units='km')

```

For me, maxrange does not work when I use cg=True!

---

<div class="post-metadata">

**Author:** ![kmuehlbauer](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/kmuehlbauer/32/439_2.png) [@kmuehlbauer](https://openradar.discourse.group/u/kmuehlbauer)\
**Post date:** [November 22, 2023, 7:02am UTC](https://openradar.discourse.group/t/wradlib-vis-plot-scan-strategy-wrong-altitude/343/15 "2023-11-22T07:02:11Z")

</div>

Thanks @lou, indeed, `maxrange` is not taken into account currently. Let’s put it on the list.

---

<div class="post-metadata">

**Author:** ![kmuehlbauer](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/kmuehlbauer/32/439_2.png) [@kmuehlbauer](https://openradar.discourse.group/u/kmuehlbauer)\
**Post date:** [December 11, 2023, 6:41am UTC](https://openradar.discourse.group/t/wradlib-vis-plot-scan-strategy-wrong-altitude/343/16 "2023-12-11T06:41:21Z")

</div>

A post was split to a new topic: [Unexpected output with wradlib.vis.plot\_scan\_strategy](https://openradar.discourse.group/t/unexpected-output-with-wradlib-vis-plot-scan-strategy/371)
