[GRASS-dev] Re: [GRASS GIS] #1424: Profile tool always casts to integers (incl. csv output)

GRASS GIS trac at osgeo.org
Sat Aug 20 05:42:03 EDT 2011


#1424: Profile tool always casts to integers (incl. csv output)
-------------------------------------+--------------------------------------
 Reporter:  hamish                   |       Owner:  grass-dev@…              
     Type:  defect                   |      Status:  new                      
 Priority:  major                    |   Milestone:  6.4.2                    
Component:  wxGUI                    |     Version:  svn-releasebranch64      
 Keywords:  profile tool, precision  |    Platform:  All                      
      Cpu:  All                      |  
-------------------------------------+--------------------------------------

Comment(by glynn):

 Replying to [comment:1 hamish]:
 > Also I notice an occurrence of `sqrt(a^2 + b^2)` in profile.py, which is
 to be avoided as it gives the wrong answer from lat/long locations.

 That will give the wrong answer for all locations; Python follows C and
 uses `^` for the bitwise exclusive-or operator. Exponentiation uses `**`
 (which should be preferred over math.pow()), i.e. sqrt(a**2 + b**2).

 However, Python's math module also has a hypot() function, which is
 probably the optimal approach here.

-- 
Ticket URL: <https://trac.osgeo.org/grass/ticket/1424#comment:3>
GRASS GIS <http://grass.osgeo.org>



More information about the grass-dev mailing list