Opened 7 years ago

Last modified 5 years ago

#3225 new defect

r.plane: ValueError: invalid literal for float(): 0:04:14.5E

Reported by: neteler Owned by: grass-dev@…
Priority: normal Milestone: 7.6.2
Component: Python Version: svn-trunk
Keywords: r.plane Cc:
CPU: Unspecified Platform: Unspecified

Description (last modified by neteler)

At time (besides the weird fact that the angle convention of azimuth does not match the standard GRASS convention) the easting and northing input does not accept sexagesimal input in lat-long location:

GRASS 7.2.0svn (latlong):~ >
r.plane output=plane dip=45 azimuth=9 \
  easting=0:04:14.5E northing=48:52:14.5N elev=1000 type=CELL
Traceback (most recent call last):
  File "/home/neteler/software/grass72/dist.x86_64-pc-linux-gnu/scripts/r.plane", line 128, in <module>
    main()
  File "/home/neteler/software/grass72/dist.x86_64-pc-linux-gnu/scripts/r.plane", line 78, in main
    ea = float(options['easting'])
ValueError: invalid literal for float(): 0:04:14.5E

AFAIK G_OPT_M_COORDS would support that but here the values have to be specified separately.

Change History (7)

comment:1 by neteler, 6 years ago

Milestone: 7.0.67.0.7

comment:2 by martinl, 5 years ago

Milestone: 7.0.77.6.2

comment:3 by neteler, 5 years ago

I guess a Python equivalent of G_scan_easting() and G_scan_northing() is needed here.

in reply to:  3 comment:4 by mmetz, 5 years ago

Replying to neteler:

I guess a Python equivalent of G_scan_easting() and G_scan_northing() is needed here.

It's here: https://trac.osgeo.org/grass/browser/grass/trunk/lib/python/script/utils.py#L33

comment:5 by lucadelu, 5 years ago

Please look and try r74438

in reply to:  5 comment:6 by neteler, 5 years ago

Description: modified (diff)
Version: unspecifiedsvn-trunk

Replying to lucadelu:

Please look and try r74438

Thanks, but now I get

r.plane output=plane dip=45 azimuth=9 easting=0:04:14.5E northing=48:52:14.5N elev=1000 type=CELL
ERROR: Input coordinates seems to be invalid

With debug output added locally, I see that "E" and "N" are the problem (which are accepted in g.region, see https://grass.osgeo.org/grass76/manuals/g.region.html#changing-extent-and-raster-resolution-using-values):

r.plane output=plane dip=45 azimuth=9 easting="00:04:14.5E" northing="48:52:14.5N" elev=1000 type=CELL
Traceback (most recent call last):
  File "/home/mneteler/software/grass77/dist.x86_64-pc-linux-gnu/scripts/r.plane", line 134, in <module>
    main()
  File "/home/mneteler/software/grass77/dist.x86_64-pc-linux-gnu/scripts/r.plane", line 84, in main
    print(gscript.utils.float_or_dms(options['easting']))
  File "/home/mneteler/software/grass77/dist.x86_64-pc-linux-gnu/etc/python/grass/script/utils.py", line 45, in float_or_dms
    return sum(float(x) / 60 ** n for (n, x) in enumerate(s.split(':')))
  File "/home/mneteler/software/grass77/dist.x86_64-pc-linux-gnu/etc/python/grass/script/utils.py", line 45, in <genexpr>
    return sum(float(x) / 60 ** n for (n, x) in enumerate(s.split(':')))
ValueError: invalid literal for float(): 14.5E

# trying without "E":
r.plane output=plane dip=45 azimuth=9 easting="00:04:14.5" northing="48:52:14.5N" elev=1000 type=CELL
0.0706944444444
ERROR: Input coordinates seems to be invalid

# trying without E and N:
r.plane output=plane dip=45 azimuth=9 easting=00:04:14.5 northing=48:52:14.5 elev=1000 type=CELL
  36%
...

IMHO float_or_dms() needs an update to accept E and N.

comment:7 by lucadelu, 5 years ago

In 74485:

libpython: float_or_dms accept E,W,N,S. see #3225

Note: See TracTickets for help on using tickets.