[GRASS-SVN] r73968 - in grass-addons/grass7/raster: r.basin r.colors.cubehelix r.colors.out_sld r.cpt2grass r.euro.ecosystem r.flexure r.futures/r.futures.calib r.futures/r.futures.potential r.hazard.flood r.hypso r.in.usgs r.in.wcs r.mcda.input r.mcda.output r.mcda.roughset r.mwprecip r.northerness.easterness r.object.activelearning r.object.spatialautocor r.out.legend r.rock.stability r.roughness.vector r.series.diversity r.shalstab r.to.vect.lines r.vif r.width.funct

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jan 17 13:34:28 PST 2019


Author: neteler
Date: 2019-01-17 13:34:28 -0800 (Thu, 17 Jan 2019)
New Revision: 73968

Modified:
   grass-addons/grass7/raster/r.basin/r.basin.py
   grass-addons/grass7/raster/r.colors.cubehelix/r.colors.cubehelix.py
   grass-addons/grass7/raster/r.colors.out_sld/r.colors.out_sld.py
   grass-addons/grass7/raster/r.cpt2grass/r.cpt2grass.py
   grass-addons/grass7/raster/r.euro.ecosystem/r.euro.ecosystem.py
   grass-addons/grass7/raster/r.flexure/r.flexure.py
   grass-addons/grass7/raster/r.futures/r.futures.calib/r.futures.calib.py
   grass-addons/grass7/raster/r.futures/r.futures.potential/r.futures.potential.py
   grass-addons/grass7/raster/r.hazard.flood/r.hazard.flood.py
   grass-addons/grass7/raster/r.hypso/r.hypso.py
   grass-addons/grass7/raster/r.in.usgs/r.in.usgs.py
   grass-addons/grass7/raster/r.in.wcs/r.in.wcs.py
   grass-addons/grass7/raster/r.mcda.input/r.mcda.input.py
   grass-addons/grass7/raster/r.mcda.output/r.mcda.output.py
   grass-addons/grass7/raster/r.mcda.roughset/r.mcda.roughset.py
   grass-addons/grass7/raster/r.mwprecip/pgwrapper.py
   grass-addons/grass7/raster/r.northerness.easterness/r.northerness.easterness.py
   grass-addons/grass7/raster/r.object.activelearning/r.object.activelearning.py
   grass-addons/grass7/raster/r.object.spatialautocor/r.object.spatialautocor.py
   grass-addons/grass7/raster/r.out.legend/r.out.legend.py
   grass-addons/grass7/raster/r.rock.stability/r.rock.stability.py
   grass-addons/grass7/raster/r.roughness.vector/r.roughness.vector.html
   grass-addons/grass7/raster/r.roughness.vector/r.roughness.vector.py
   grass-addons/grass7/raster/r.series.diversity/r.series.diversity.py
   grass-addons/grass7/raster/r.shalstab/r.shalstab.html
   grass-addons/grass7/raster/r.shalstab/r.shalstab.py
   grass-addons/grass7/raster/r.to.vect.lines/r.to.vect.lines.py
   grass-addons/grass7/raster/r.vif/r.vif.py
   grass-addons/grass7/raster/r.width.funct/r.width.funct.py
Log:
raster addons: Python3 compatibility changes, using 2to3 from python-tools

Modified: grass-addons/grass7/raster/r.basin/r.basin.py
===================================================================
--- grass-addons/grass7/raster/r.basin/r.basin.py	2019-01-17 20:53:33 UTC (rev 73967)
+++ grass-addons/grass7/raster/r.basin/r.basin.py	2019-01-17 21:34:28 UTC (rev 73968)
@@ -75,9 +75,9 @@
 from numpy import zeros
 import csv
 
-if not os.environ.has_key("GISBASE"):
-    grass.message( "You must be in GRASS GIS to run this program." )
-    sys.exit(1)
+# i18N
+import gettext
+gettext.install('grassmods', os.path.join(os.getenv("GISBASE"), 'locale'))
 
 # check requirements
 def check_progs():
@@ -575,9 +575,9 @@
                                                         elevation = 'r_elevation_crop' )
 
 
-        print " ------------------------------ "
-        print "Output of r.stream.stats: "
-        print  stream_stats
+        print(" ------------------------------ ")
+        print("Output of r.stream.stats: ")
+        print(stream_stats)
 
         stream_stats_summary = stream_stats.split('\n')[4].split('|')
         stream_stats_mom = stream_stats.split('\n')[8].split('|')

Modified: grass-addons/grass7/raster/r.colors.cubehelix/r.colors.cubehelix.py
===================================================================
--- grass-addons/grass7/raster/r.colors.cubehelix/r.colors.cubehelix.py	2019-01-17 20:53:33 UTC (rev 73967)
+++ grass-addons/grass7/raster/r.colors.cubehelix/r.colors.cubehelix.py	2019-01-17 21:34:28 UTC (rev 73968)
@@ -246,7 +246,7 @@
             f.write(rules)
             f.write('\n')
     elif not options['map']:
-        print rules
+        print(rules)
 
 
 if __name__ == '__main__':

Modified: grass-addons/grass7/raster/r.colors.out_sld/r.colors.out_sld.py
===================================================================
--- grass-addons/grass7/raster/r.colors.out_sld/r.colors.out_sld.py	2019-01-17 20:53:33 UTC (rev 73967)
+++ grass-addons/grass7/raster/r.colors.out_sld/r.colors.out_sld.py	2019-01-17 21:34:28 UTC (rev 73968)
@@ -61,10 +61,6 @@
 import sys
 import grass.script as grass
 
-if not os.environ.has_key("GISBASE"):
-    grass.message( "You must be in GRASS GIS to run this program." )
-    sys.exit(1)
-
 def set_output_encoding(encoding='utf-8'):
     import codecs
     current = sys.stdout.encoding
@@ -109,7 +105,7 @@
         use_categories = False
 
     # Initialize SLD with header
-    sld = u"""<?xml version="1.0" encoding="UTF-8"?>
+    sld = """<?xml version="1.0" encoding="UTF-8"?>
 <StyledLayerDescriptor version="1.0.0" 
     xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd" 
     xmlns="http://www.opengis.net/sld" 
@@ -118,7 +114,7 @@
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <NamedLayer>
     <Name>{}</Name>""".format(style_name)
-    sld+=u"""    <UserStyle>
+    sld+="""    <UserStyle>
       <Title>{}</Title>\n
       <FeatureTypeStyle>
         <Rule>
@@ -126,12 +122,12 @@
 
     # Define type of ColorMap depending on data type of input map
     if use_categories:
-        sld+=u'            <ColorMap type={}>\n'.format('"values"')
-        ColorMapEntry = u'              <ColorMapEntry color="#{0:02x}{1:02x}{2:02x}" quantity="{3}" label="{4}" opacity="{5}" />\n'
+        sld+='            <ColorMap type={}>\n'.format('"values"')
+        ColorMapEntry = '              <ColorMapEntry color="#{0:02x}{1:02x}{2:02x}" quantity="{3}" label="{4}" opacity="{5}" />\n'
     else:
-        sld+=u'            <ColorMap>\n'
+        sld+='            <ColorMap>\n'
         # sld+='            <ColorMap type={}>\n'.format('"ramp"')
-        ColorMapEntry = u'              <ColorMapEntry color="#{0:02x}{1:02x}{2:02x}" quantity="{3}" opacity="{4}" />\n'
+        ColorMapEntry = '              <ColorMapEntry color="#{0:02x}{1:02x}{2:02x}" quantity="{3}" opacity="{4}" />\n'
 
     # 
     for c in color_rules:
@@ -138,7 +134,7 @@
         if len(c.split(' ')) == 2 and not c.split(' ')[0] == 'default':
             q = c.split(' ')[0]
             if q == 'nv':
-                q = u'NaN'
+                q = 'NaN'
                 r = 255
                 g = 255
                 b = 255
@@ -149,10 +145,10 @@
                 b = int(c.split(' ')[1].split(':')[2])
                 o = 1
             if use_categories:
-                if str(q) in categories.keys():
+                if str(q) in list(categories.keys()):
                     l = categories[str(q)]
-                elif q == u'NaN':
-                    l = u'NoData'
+                elif q == 'NaN':
+                    l = 'NoData'
                 else:
                     continue
                 sld+=ColorMapEntry.format(r,g,b,q,l,o)
@@ -160,7 +156,7 @@
                 sld+=ColorMapEntry.format(r,g,b,q,o)
 
     # write file footer
-    sld+=u"""            </ColorMap>
+    sld+="""            </ColorMap>
           </RasterSymbolizer>
         </Rule>
       </FeatureTypeStyle>
@@ -170,7 +166,7 @@
 
     if output == '-':
         # Write SLD to stdout if no output is requested
-        print sld
+        print(sld)
     else:
         # Write SLD to file if requested
         with open(output, 'w+') as o:

Modified: grass-addons/grass7/raster/r.cpt2grass/r.cpt2grass.py
===================================================================
--- grass-addons/grass7/raster/r.cpt2grass/r.cpt2grass.py	2019-01-17 20:53:33 UTC (rev 73967)
+++ grass-addons/grass7/raster/r.cpt2grass/r.cpt2grass.py	2019-01-17 21:34:28 UTC (rev 73968)
@@ -132,7 +132,7 @@
         try:
             from urllib.request import urlopen
         except ImportError:
-            from urllib import urlopen
+            from urllib.request import urlopen
 
         txt = urlopen(input_url).readlines()
     else:
@@ -185,7 +185,7 @@
             f.write('\n'.join(rules))
             f.write('\n')
     elif not options['map']:
-        print '\n'.join(rules) + '\n'
+        print('\n'.join(rules) + '\n')
 
 
 if __name__ == '__main__':

Modified: grass-addons/grass7/raster/r.euro.ecosystem/r.euro.ecosystem.py
===================================================================
--- grass-addons/grass7/raster/r.euro.ecosystem/r.euro.ecosystem.py	2019-01-17 20:53:33 UTC (rev 73967)
+++ grass-addons/grass7/raster/r.euro.ecosystem/r.euro.ecosystem.py	2019-01-17 21:34:28 UTC (rev 73968)
@@ -48,10 +48,6 @@
 import tempfile
 import grass.script as grass
 
-if not os.environ.has_key("GISBASE"):
-    grass.message( "You must be in GRASS GIS to run this program." )
-    sys.exit(1)
-
 def main():
 
     iraster = options['input']		

Modified: grass-addons/grass7/raster/r.flexure/r.flexure.py
===================================================================
--- grass-addons/grass7/raster/r.flexure/r.flexure.py	2019-01-17 20:53:33 UTC (rev 73967)
+++ grass-addons/grass7/raster/r.flexure/r.flexure.py	2019-01-17 21:34:28 UTC (rev 73968)
@@ -197,12 +197,12 @@
     try:
         import gflex
     except:
-        print ""
-        print "MODULE IMPORT ERROR."
-        print "In order to run r.flexure or g.flexure, you must download and install"
-        print "gFlex. The most recent development version is available from"
-        print "https://github.com/awickert/gFlex."
-        print "Installation instructions are available on the page."
+        print("")
+        print("MODULE IMPORT ERROR.")
+        print("In order to run r.flexure or g.flexure, you must download and install")
+        print("gFlex. The most recent development version is available from")
+        print("https://github.com/awickert/gFlex.")
+        print("Installation instructions are available on the page.")
         grass.fatal("Software dependency must be installed.")
 
     # This code is for 2D flexural isostasy
@@ -272,14 +272,14 @@
     if grass.region_env()[6] == '3':
         if latlon_override:
             if flex.Verbose:
-                print "Latitude/longitude grid."
-                print "Based on r_Earth = 6371 km"
-                print "Setting y-resolution [m] to 111,195 * [degrees]"
+                print("Latitude/longitude grid.")
+                print("Based on r_Earth = 6371 km")
+                print("Setting y-resolution [m] to 111,195 * [degrees]")
             flex.dy = grass.region()['nsres']*111195.
             NSmid = (grass.region()['n'] + grass.region()['s'])/2.
             dx_at_mid_latitude = (3.14159/180.) * 6371000. * np.cos(np.deg2rad(NSmid))
             if flex.Verbose:
-                print "Setting x-resolution [m] to "+"%.2f" %dx_at_mid_latitude+" * [degrees]"
+                print("Setting x-resolution [m] to "+"%.2f" %dx_at_mid_latitude+" * [degrees]")
             flex.dx = grass.region()['ewres']*dx_at_mid_latitude
         else:
             grass.fatal("Need the '-l' flag to enable lat/lon solution approximation.")
@@ -308,7 +308,7 @@
     #grass.run_command('r.colors', map=output + '_interp', color='rainbow', quiet=True)#, flags='e')
 
 def install_dependencies():
-    print "PLACEHOLDER"
+    print("PLACEHOLDER")
 
 if __name__ == "__main__":
     import sys

Modified: grass-addons/grass7/raster/r.futures/r.futures.calib/r.futures.calib.py
===================================================================
--- grass-addons/grass7/raster/r.futures/r.futures.calib/r.futures.calib.py	2019-01-17 20:53:33 UTC (rev 73967)
+++ grass-addons/grass7/raster/r.futures/r.futures.calib/r.futures.calib.py	2019-01-17 21:34:28 UTC (rev 73968)
@@ -296,7 +296,7 @@
             run_simulation(development_start=development_start, development_end=simulation_dev_end,
                            compactness_mean=compactness_mean, compactness_range=compactness_range,
                            discount_factor=discount_factor, patches_file=patches_file, fut_options=fut_options)
-        except CalledModuleError, e:
+        except CalledModuleError as e:
             queue.put(None)
             cleanup(tmp=TMP_PROCESS)
             gcore.error(_("Running r.futures.pga failed. Details: {e}").format(e=e))

Modified: grass-addons/grass7/raster/r.futures/r.futures.potential/r.futures.potential.py
===================================================================
--- grass-addons/grass7/raster/r.futures/r.futures.potential/r.futures.potential.py	2019-01-17 20:53:33 UTC (rev 73967)
+++ grass-addons/grass7/raster/r.futures/r.futures.potential/r.futures.potential.py	2019-01-17 21:34:28 UTC (rev 73968)
@@ -186,14 +186,14 @@
         cmd += [ '-l', level]
     p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     stdout, stderr = p.communicate()
-    print stderr
+    print(stderr)
     if p.returncode != 0:
-        print stderr
+        print(stderr)
         gscript.fatal(_("Running R script failed, check messages above"))
 
     gscript.info(_("Best model summary:"))
     gscript.info("-------------------------")
-    print stdout
+    print(stdout)
 
     with open(TMP_POT, 'r') as fin, open(options['output'], 'w') as fout:
         i = 0

Modified: grass-addons/grass7/raster/r.hazard.flood/r.hazard.flood.py
===================================================================
--- grass-addons/grass7/raster/r.hazard.flood/r.hazard.flood.py	2019-01-17 20:53:33 UTC (rev 73967)
+++ grass-addons/grass7/raster/r.hazard.flood/r.hazard.flood.py	2019-01-17 21:34:28 UTC (rev 73968)
@@ -57,10 +57,6 @@
     except:
         sys.exit("grass.script can't be imported.")
 
-if not os.environ.has_key("GISBASE"):
-    print("You must be in GRASS GIS to run this program.")
-    sys.exit(1)
-
 def main():
 
     #### check if we have the r.area addon

Modified: grass-addons/grass7/raster/r.hypso/r.hypso.py
===================================================================
--- grass-addons/grass7/raster/r.hypso/r.hypso.py	2019-01-17 20:53:33 UTC (rev 73967)
+++ grass-addons/grass7/raster/r.hypso/r.hypso.py	2019-01-17 21:34:28 UTC (rev 73968)
@@ -64,14 +64,14 @@
 
     for i in range(len(stats)):
         if i == 0:
-            zn[i,0], zn[i, 1] = map(float, stats[i].split(' '))
+            zn[i,0], zn[i, 1] = list(map(float, stats[i].split(' ')))
             zn[i,2] = zn[i,1]
         else:
-            zn[i,0], zn[i, 1] = map(float, stats[i].split(' '))
+            zn[i,0], zn[i, 1] = list(map(float, stats[i].split(' ')))
             zn[i,2] = zn[i,1] + zn[i-1,2]
 
     totcell = sum(zn[:,1])
-    print "Tot. cells", totcell
+    print("Tot. cells", totcell)
 
     for i in range(len(stats)):
         zn[i,3] = 1 - (zn[i,2] / sum(zn[:,1]))
@@ -97,19 +97,19 @@
     if flags['b']:
         plotImage(zn[:,4], zn[:,0],options['image']+'_Hypsographic.png','-','A [km^2]','Z [m.slm]','Hypsographic Curve')
 
-    print "==========================="
-    print "Hypsometric | quantiles"
-    print "==========================="
-    print '%.0f' %findint(kl,0.025) , "|", 0.025
-    print '%.0f' %findint(kl,0.05) , "|", 0.05
-    print '%.0f' %findint(kl,0.1) , "|", 0.1
-    print '%.0f' %findint(kl,0.25) , "|", 0.25
-    print '%.0f' %findint(kl,0.5) , "|", 0.5
-    print '%.0f' %findint(kl,0.75) , "|", 0.75
-    print '%.0f' %findint(kl,0.9) , "|", 0.9
-    print '%.0f' %findint(kl,0.975) , "|", 0.975
-    print '\n'
-    print 'Done!'
+    print("===========================")
+    print("Hypsometric | quantiles")
+    print("===========================")
+    print('%.0f' %findint(kl,0.025) , "|", 0.025)
+    print('%.0f' %findint(kl,0.05) , "|", 0.05)
+    print('%.0f' %findint(kl,0.1) , "|", 0.1)
+    print('%.0f' %findint(kl,0.25) , "|", 0.25)
+    print('%.0f' %findint(kl,0.5) , "|", 0.5)
+    print('%.0f' %findint(kl,0.75) , "|", 0.75)
+    print('%.0f' %findint(kl,0.9) , "|", 0.9)
+    print('%.0f' %findint(kl,0.975) , "|", 0.975)
+    print('\n')
+    print('Done!')
     #print prc
 
 

Modified: grass-addons/grass7/raster/r.in.usgs/r.in.usgs.py
===================================================================
--- grass-addons/grass7/raster/r.in.usgs/r.in.usgs.py	2019-01-17 20:53:33 UTC (rev 73967)
+++ grass-addons/grass7/raster/r.in.usgs/r.in.usgs.py	2019-01-17 21:34:28 UTC (rev 73968)
@@ -463,7 +463,7 @@
                                                 count=file_download_count,
                                                 srs=product_srs,
                                                 tile=TNM_file_titles_info)
-    print data_info
+    print(data_info)
 
     if gui_i_flag:
         gscript.info(_("To download USGS data, remove <i> flag, and rerun r.in.usgs."))

Modified: grass-addons/grass7/raster/r.in.wcs/r.in.wcs.py
===================================================================
--- grass-addons/grass7/raster/r.in.wcs/r.in.wcs.py	2019-01-17 20:53:33 UTC (rev 73967)
+++ grass-addons/grass7/raster/r.in.wcs/r.in.wcs.py	2019-01-17 21:34:28 UTC (rev 73968)
@@ -252,8 +252,8 @@
 
         try:
             cap = self._fetchDataFromServer(cap_url, options['username'], options['password'])
-            print dir(cap)
-        except (IOError, HTTPException), e:
+            print(dir(cap))
+        except (IOError, HTTPException) as e:
             if urllib2.HTTPError == type(e) and e.code == 401:
                 grass.fatal(_("Authorization failed to <%s> when fetching capabilities") % options['url'])
             else:

Modified: grass-addons/grass7/raster/r.mcda.input/r.mcda.input.py
===================================================================
--- grass-addons/grass7/raster/r.mcda.input/r.mcda.input.py	2019-01-17 20:53:33 UTC (rev 73967)
+++ grass-addons/grass7/raster/r.mcda.input/r.mcda.input.py	2019-01-17 21:34:28 UTC (rev 73968)
@@ -114,7 +114,7 @@
 	labels=["_".join(m.split('_')[1:]) for m in maps] 
 	labels=list(set(labels))
 	for l in labels:
-		print "mapping %s rule" % str(l)
+		print("mapping %s rule" % str(l))
 		map_synth=[]
 		for m in maps:
 			if l == "_".join(m.split('_')[1:]):
@@ -160,7 +160,7 @@
 		maps.append(mappa)
 		
 	maplist=",".join(maps)	
-	print maplist
+	print(maplist)
 	patch_georules(maps,outputMap)
 			
 	if not flags['l']:

Modified: grass-addons/grass7/raster/r.mcda.output/r.mcda.output.py
===================================================================
--- grass-addons/grass7/raster/r.mcda.output/r.mcda.output.py	2019-01-17 20:53:33 UTC (rev 73967)
+++ grass-addons/grass7/raster/r.mcda.output/r.mcda.output.py	2019-01-17 21:34:28 UTC (rev 73968)
@@ -69,7 +69,7 @@
     ncols = gregion['cols']
     ewres=int(gregion['ewres'])
     nsres=int(gregion['nsres'])
-    print nrows, ncols, ewres,nsres
+    print(nrows, ncols, ewres,nsres)
 
     outf = file(output,"w")
     outf.write("**ATTRIBUTES\n")
@@ -108,12 +108,12 @@
     example=tmp.split()
 
     examples.append(example)
-    MATRIX=map(list,zip(*examples))
+    MATRIX=list(map(list,list(zip(*examples))))
 
     MATRIX=[r for r in MATRIX if not '?' in r] #remove all rows with almost one "?"
     MATRIX=[list(i) for i in set(tuple(j) for j in MATRIX)] #remove duplicate example 
                 
-    print "rows:%d - col:%d" %(len(MATRIX),len(MATRIX[0]))
+    print("rows:%d - col:%d" %(len(MATRIX),len(MATRIX[0])))
     for r in range(len(MATRIX)):
         for c in range(len(MATRIX[0])):
             outf.write("%s " %  str(MATRIX[r][c]))

Modified: grass-addons/grass7/raster/r.mcda.roughset/r.mcda.roughset.py
===================================================================
--- grass-addons/grass7/raster/r.mcda.roughset/r.mcda.roughset.py	2019-01-17 20:53:33 UTC (rev 73967)
+++ grass-addons/grass7/raster/r.mcda.roughset/r.mcda.roughset.py	2019-01-17 21:34:28 UTC (rev 73968)
@@ -73,6 +73,7 @@
 from time import time, ctime  
 import grass.script as grass
 import grass.script.array as garray
+from functools import reduce
 
 
 def BuildFileISF(attributes, preferences, decision, outputMap, outputTxt):
@@ -100,7 +101,7 @@
 	
 	if flags['n']:
 		for i in range(len(attributes)):
-			print "%s - convert null to 0" % str(attributes[i])
+			print("%s - convert null to 0" % str(attributes[i]))
 			grass.run_command("r.null", map=attributes[i], null=0)
 			
 	outf.write("\n**EXAMPLES\n")
@@ -119,7 +120,7 @@
 	example=tmp.split()
 	examples.append(example)
 
-	MATRIX=map(list,zip(*examples))
+	MATRIX=list(map(list,list(zip(*examples))))
 	MATRIX=[r for r in MATRIX if not '?' in r] #remove all rows with almost one "?"
 	MATRIX=[list(i) for i in set(tuple(j) for j in MATRIX)] #remove duplicate example 
 	
@@ -164,7 +165,7 @@
 	start=(data.index(['**EXAMPLES'])+1)
 	end=data.index(['**END'])
 	for i in range(start, end):
-		data[i]=(map(float, data[i]))
+		data[i]=(list(map(float, data[i])))
 		matrix.append(data[i])
 	i=1
 	for r in matrix:
@@ -187,7 +188,7 @@
 		infile.close()	   
 		infosystem={'attributes':collect_attributes(data),'examples':collect_examples(data)}
 	except TypeError:
-		print "\n\n Computing error or input file %s is not readeable. Exiting gracefully" % isf
+		print("\n\n Computing error or input file %s is not readeable. Exiting gracefully" % isf)
 		sys.exit(0)
 		
 	return infosystem
@@ -351,7 +352,7 @@
 		examples.append(rule['objectsCovered']) 
 
 	if len(examples)>0:
-		examples = reduce(set.intersection,map(set,examples))  #functional approach: intersect all lists if example is not empty
+		examples = reduce(set.intersection,list(map(set,examples)))  #functional approach: intersect all lists if example is not empty
 		examples = list(set(examples) & set([r[0] for r in selected]))
 	return examples #all examples covered from a single rule
 	
@@ -436,7 +437,7 @@
 
 			for r in rules:
 				obj_cov_by_rules.append(r['objectsCovered'])
-			obj_cov_by_rules=list((reduce(set.intersection,map(set,obj_cov_by_rules)))) #reduce():Apply function of two arguments cumulatively to the items of iterable, from left to right, so as to reduce the iterable to a single value.
+			obj_cov_by_rules=list((reduce(set.intersection,list(map(set,obj_cov_by_rules))))) #reduce():Apply function of two arguments cumulatively to the items of iterable, from left to right, so as to reduce the iterable to a single value.
 
 			S=list(set(S) & set(best['objectsCovered'] ))
 			control+=1
@@ -536,7 +537,7 @@
 	labels=["_".join(m.split('_')[1:]) for m in maps] 
 	labels=list(set(labels))
 	for l in labels:
-		print "mapping %s rule" % str(l)
+		print("mapping %s rule" % str(l))
 		map_synth=[]
 		for m in maps:
 			if l == "_".join(m.split('_')[1:]):
@@ -545,7 +546,7 @@
 			grass.run_command("r.patch", overwrite='True', input=(",".join(map_synth)), output=l )
 		else:
 			grass.run_command("g.copy", raster=(str(map_synth),l))
-		print "__",str(map_synth),l
+		print("__",str(map_synth),l)
 		grass.run_command("r.to.vect", overwrite='True', flags='s', input=l, output=l, feature='area')
 		grass.run_command("v.db.addcol", map=l, columns='rule varchar(25)')
 		grass.run_command("v.db.update", map=l, column='rule', value=l)
@@ -582,22 +583,22 @@
 	Dominating=DominatingSet(infosystem)
 	Dominated=DominatedSet(infosystem)
 ##	upward union class
-	print "elaborate upward union"
+	print("elaborate upward union")
 	Lu=LowerApproximation(UpwardUnionClass, Dominating) #lower approximation of upward union for type 1 rules
 	Uu=UpperApproximation(UpwardUnionClass,Dominated ) #upper approximation of upward union
 	UpwardBoundary=Boundaries(Uu, Lu)
 ##	downward union class
-	print "elaborate downward union"
+	print("elaborate downward union")
 	Ld=LowerApproximation(DownwardUnionClass, Dominated) # lower approximation of  downward union for type 3 rules
 	Ud=UpperApproximation(DownwardUnionClass,Dominating ) # upper approximation of  downward union 
 	DownwardBoundary=Boundaries(Ud, Ld)
 	QualityOfQpproximation(DownwardBoundary,  infosystem)
-	print "RULES extraction (*)" 
+	print("RULES extraction (*)") 
 	RULES=Domlem(Lu,Ld, infosystem)
 	Parser_mapcalc(RULES, outputMap)		   
 	Print_rules(RULES, outputTxt)
 	end=time()
-	print "Time computing-> %.4f s" % (end-start)
+	print("Time computing-> %.4f s" % (end-start))
 	return 0
 	#except:
 		#print "ERROR! Rules does not generated!"

Modified: grass-addons/grass7/raster/r.mwprecip/pgwrapper.py
===================================================================
--- grass-addons/grass7/raster/r.mwprecip/pgwrapper.py	2019-01-17 20:53:33 UTC (rev 73967)
+++ grass-addons/grass7/raster/r.mwprecip/pgwrapper.py	2019-01-17 21:34:28 UTC (rev 73968)
@@ -43,7 +43,7 @@
                         self.cursor.copy_from(afile,table,sep=sep)
                         self.connection.commit()
 
-                 except Exception,err:
+                 except Exception as err:
                         self.connection.rollback()
                         self.print_message( " Catched error (as expected):\n")
                         self.print_message(err)
@@ -63,9 +63,9 @@
                 #self.print_message (sql)
                 try:
                         self.cursor.execute(sql)
-                except Exception, e:
+                except Exception as e:
                         self.connection.rollback()
-                        print e.pgerror
+                        print(e.pgerror)
                         pass
                 
                 if commit:        
@@ -103,13 +103,13 @@
                         sql_update_col = 'UPDATE "' + table + '" SET ' + parse
                 else:
                         sql_update_col = 'UPDATE "' + table + '" SET ' + parse + ' WHERE ' + where
-                print "upcol %s"%sql_update_col      
+                print("upcol %s"%sql_update_col)      
                 # Excute the SQL statement.
                 self.cursor.execute(sql_update_col)
                 
         def print_message(self,msg):
-                print '-' * 80
-                print msg
-                print '-' * 80
-                print 
+                print('-' * 80)
+                print(msg)
+                print('-' * 80)
+                print() 
                 sys.stdout.flush()

Modified: grass-addons/grass7/raster/r.northerness.easterness/r.northerness.easterness.py
===================================================================
--- grass-addons/grass7/raster/r.northerness.easterness/r.northerness.easterness.py	2019-01-17 20:53:33 UTC (rev 73967)
+++ grass-addons/grass7/raster/r.northerness.easterness/r.northerness.easterness.py	2019-01-17 21:34:28 UTC (rev 73968)
@@ -34,10 +34,6 @@
 import grass.script as grass
 import math
 
-if not os.environ.has_key("GISBASE"):
-    grass.message( "You must be in GRASS GIS to run this program." )
-    sys.exit(1)
-
 def main():
     r_elevation = options['elevation'].split('@')[0] 
     r_aspect = r_elevation+'_aspect'

Modified: grass-addons/grass7/raster/r.object.activelearning/r.object.activelearning.py
===================================================================
--- grass-addons/grass7/raster/r.object.activelearning/r.object.activelearning.py	2019-01-17 20:53:33 UTC (rev 73967)
+++ grass-addons/grass7/raster/r.object.activelearning/r.object.activelearning.py	2019-01-17 21:34:28 UTC (rev 73968)
@@ -162,8 +162,8 @@
         :filename: Name of the csv file
     """
     data = np.copy(X_unlabeled)
-    data = np.insert(data, 0, map(str, ID), axis=1)
-    data = np.insert(data, 1, map(str, predictions), axis=1)
+    data = np.insert(data, 0, list(map(str, ID)), axis=1)
+    data = np.insert(data, 1, list(map(str, predictions)), axis=1)
 
     if header.size != 0 :
         header = np.insert(header, 1, ['Class'])
@@ -519,7 +519,7 @@
         gamma = clf.best_params_['gamma']
     return float(c), float(gamma)
 
-def main() :
+def main():
     global learning_steps
     global diversity_lambda
     global nbr_uncertainty
@@ -572,7 +572,7 @@
     gcore.message('Score : {}'.format(score))
 
     for ID in samples_to_label_IDs :
-        print(int(ID))
+        print((int(ID)))
 
 
 if __name__ == '__main__' :

Modified: grass-addons/grass7/raster/r.object.spatialautocor/r.object.spatialautocor.py
===================================================================
--- grass-addons/grass7/raster/r.object.spatialautocor/r.object.spatialautocor.py	2019-01-17 20:53:33 UTC (rev 73967)
+++ grass-addons/grass7/raster/r.object.spatialautocor/r.object.spatialautocor.py	2019-01-17 21:34:28 UTC (rev 73968)
@@ -2,15 +2,15 @@
 #
 ############################################################################
 #
-# MODULE:	r.object.spatialautocor
-# AUTHOR(S):	Moritz Lennert
+# MODULE:       r.object.spatialautocor
+# AUTHOR(S):    Moritz Lennert
 #
-# PURPOSE:	Calculates global spatial autocorrelation on raster objects
-# COPYRIGHT:	(C) 1997-2017 by the GRASS Development Team
+# PURPOSE:      Calculates global spatial autocorrelation on raster objects
+# COPYRIGHT:    (C) 1997-2017 by the GRASS Development Team
 #
-#		This program is free software under the GNU General Public
-#		License (>=v2). Read the file COPYING that comes with GRASS
-#		for details.
+#       This program is free software under the GNU General Public
+#       License (>=v2). Read the file COPYING that comes with GRASS
+#       for details.
 #
 #############################################################################
 # References:
@@ -62,7 +62,6 @@
    found_missing = False
    for prog in ['r.neighborhoodmatrix']:
        if not gscript.find_program(prog, '--help'):
-
            found_missing = True
            gscript.warning(_("'%s' required. Please install '%s' first using 'g.extension %s'") % (prog, prog, prog))
    if found_missing:
@@ -143,7 +142,7 @@
         for neighbor in neighbors:
             neighbor_value = means[neighbor] - global_mean
             sum_products += region_value * neighbor_value
-                sum_squared_differences = ( means[region] - means[neighbor] ) ** 2
+            sum_squared_differences = ( means[region] - means[neighbor] ) ** 2
 
     if method == 'moran':
         autocor = ( ( float(N) / total_nb_neighbors ) * (float(sum_products)  /  sum_sq_mean_diffs ) )
@@ -168,4 +167,4 @@
 
 if __name__ == "__main__":
     options, flags = gscript.parser()
-    main()
+    sys.exit(main())

Modified: grass-addons/grass7/raster/r.out.legend/r.out.legend.py
===================================================================
--- grass-addons/grass7/raster/r.out.legend/r.out.legend.py	2019-01-17 20:53:33 UTC (rev 73967)
+++ grass-addons/grass7/raster/r.out.legend/r.out.legend.py	2019-01-17 21:34:28 UTC (rev 73968)
@@ -345,10 +345,10 @@
     d_legend = Module("d.legend", flags=flag, raster=inmap, font=font,
                       at=at, fontsize=fz, labelnum=labelnum, run_=False)
     if vr:
-        val_range = map(float, vr.split(','))
+        val_range = list(map(float, vr.split(',')))
         d_legend.inputs.range = val_range
     if labval:
-        label_values = map(float, labval.split(','))
+        label_values = list(map(float, labval.split(',')))
         d_legend.inputs.label_values = label_values
     if labstep:
         label_step = float(labstep)

Modified: grass-addons/grass7/raster/r.rock.stability/r.rock.stability.py
===================================================================
--- grass-addons/grass7/raster/r.rock.stability/r.rock.stability.py	2019-01-17 20:53:33 UTC (rev 73967)
+++ grass-addons/grass7/raster/r.rock.stability/r.rock.stability.py	2019-01-17 21:34:28 UTC (rev 73968)
@@ -99,10 +99,6 @@
     except:
         sys.exit("grass.script can't be imported.")
 
-if not os.environ.has_key("GISBASE"):
-    print("You must be in GRASS GIS to run this program.")
-    sys.exit(1)
-
 def main():
 ############################################### leggo variabili###################################
     r_elevation = options['dem'].split('@')[0]

Modified: grass-addons/grass7/raster/r.roughness.vector/r.roughness.vector.html
===================================================================
--- grass-addons/grass7/raster/r.roughness.vector/r.roughness.vector.html	2019-01-17 20:53:33 UTC (rev 73967)
+++ grass-addons/grass7/raster/r.roughness.vector/r.roughness.vector.html	2019-01-17 21:34:28 UTC (rev 73968)
@@ -34,30 +34,24 @@
 If the user does not specify the output maps names, they will be set to
 </p>
 
-<div class="code">
- <pre>
-  <em>INPUT_MAP_vector_strength_NxN</em>
- </pre>
-</div>
+<div class="code"><pre>
+INPUT_MAP_vector_strength_NxN
+</pre></div>
 
 and
 
-<div class="code">
- <pre>
-  <em>INPUT_MAP_fisher_K_NxN</em>
- </pre>
-</div>
+<div class="code"><pre>
+  INPUT_MAP_fisher_K_NxN
+</pre></div>
 
 where N is the window size.
 
 <h2>EXAMPLE</h2>
 
-<div class="code">
- <pre>
+<div class="code"><pre>
   # calculate roughness factor by search window = 5
   r.roughness.vector elevation=DEM slope=slope aspect=aspect window=5
- </pre>
-</div>
+</pre></div>
 
 <h2>SEE ALSO</h2>
 
@@ -80,7 +74,7 @@
 <a href="http://dx.doi.org/10.1016/S0169-555X(03)00164-8" target="_blank">http://dx.doi.org/10.1016/S0169-555X(03)00164-8</a>. 
 <br>
 <br>
-Grohmann, C.H., Smith, M.J. & Riccomini, C., 2011. Multiscale Analysis 
+Grohmann, C.H., Smith, M.J. & Riccomini, C., 2011. Multiscale Analysis 
 of Topographic Surface Roughness in the Midland Valley, Scotland. 
 <em>Geoscience and Remote Sensing, IEEE Transactions on</em>, 49:1200-1213. 
 <a href="http://dx.doi.org/10.1109/TGRS.2010.2053546" target="_blank">http://dx.doi.org/10.1109/TGRS.2010.2053546</a>
@@ -95,4 +89,4 @@
 Helmut Kudrnovsky
 <p>
 
-<i>Last changed: $Date$</i>
\ No newline at end of file
+<i>Last changed: $Date$</i>

Modified: grass-addons/grass7/raster/r.roughness.vector/r.roughness.vector.py
===================================================================
--- grass-addons/grass7/raster/r.roughness.vector/r.roughness.vector.py	2019-01-17 20:53:33 UTC (rev 73967)
+++ grass-addons/grass7/raster/r.roughness.vector/r.roughness.vector.py	2019-01-17 21:34:28 UTC (rev 73968)
@@ -151,17 +151,17 @@
 
     find_elev = grass.find_file(elevmap, element = 'cell')
     if find_elev['name'] == "":
-        print "Map %s not found! Aborting." % elevmap
+        print("Map %s not found! Aborting." % elevmap)
         sys.exit()
 
     find_slope = grass.find_file(slope, element = 'cell')
     if find_slope['name'] == "":
-        print "Map %s not found! Aborting." % slope
+        print("Map %s not found! Aborting." % slope)
         sys.exit()
 
     find_aspect = grass.find_file(aspect, element = 'cell')
     if find_aspect['name'] == "":
-        print "Map %s not found! Aborting." % aspect
+        print("Map %s not found! Aborting." % aspect)
         sys.exit()
 
 #########################################################################################################

Modified: grass-addons/grass7/raster/r.series.diversity/r.series.diversity.py
===================================================================
--- grass-addons/grass7/raster/r.series.diversity/r.series.diversity.py	2019-01-17 20:53:33 UTC (rev 73967)
+++ grass-addons/grass7/raster/r.series.diversity/r.series.diversity.py	2019-01-17 21:34:28 UTC (rev 73968)
@@ -127,9 +127,6 @@
 import atexit
 import string
 import grass.script as grass
-if not os.environ.has_key("GISBASE"):
-    grass.message( "You must be in GRASS GIS to run this program." )
-    sys.exit(1)
 
 #----------------------------------------------------------------------------
 # Functions

Modified: grass-addons/grass7/raster/r.shalstab/r.shalstab.html
===================================================================
--- grass-addons/grass7/raster/r.shalstab/r.shalstab.html	2019-01-17 20:53:33 UTC (rev 73967)
+++ grass-addons/grass7/raster/r.shalstab/r.shalstab.html	2019-01-17 21:34:28 UTC (rev 73968)
@@ -1,11 +1,19 @@
-<h1>DESCRIPTION</h1>
-<div>R.shalstab</div>
-<div>This command allows to apply the algorithm developed by Montgomery and Dietrich (1994) in GRASS GIS. According to these authors, the models associate the theories of infinite slope, where the strength of soil share at the discretion of rupture of Mohr Coulomb, with the hydrological model O'Loughlin (1986), resulting in equation.
-Requested input and output.
+<h2>DESCRIPTION</h2>
+
+<b>r.shalstab</b> allows to apply the algorithm developed by Montgomery
+and Dietrich (1994) in GRASS GIS. According to these authors, the
+models associate the theories of infinite slope, where the strength of
+soil share at the discretion of rupture of Mohr Coulomb, with the
+hydrological model O'Loughlin (1986), resulting in equation. Requested
+input and output.
+
+<p>
 The command requires some input:
-<ul><li>DEM a digital terrain model of the study area;</li>
+
+<ul>
+<li>DEM a digital terrain model of the study area;</li>
 <li>Raster map or single value for soil cohesion (N/m^2);</li>
-<li>Raster map or single value for soil friction angle (°);</li>
+<li>Raster map or single value for soil friction angle (°);</li>
 <li>Raster map or single value for soil density (kg/m^3);</li>
 <li>Raster map or single value for vertical thickness of soil (m);</li>
 <li>Raster map or single value for hydraulic conductivity k (m/h);</li>
@@ -12,8 +20,11 @@
 <li>Raster map or single value for root cohesion (N/m^2); (default = 0)</li>
 <li>Raster map or single value for wet soil density (kg/m^3). (default = 2100)</li>
 </ul>
-The output are:
-<ul>A landslide susceptibility map (value range from 1 to 7):</ul>
+
+The outputs are:
+
+A landslide susceptibility map (value range from 1 to 7):
+
 <ul>
 <li>1 Unconditionally Unstable</li>
 <li>2 0-30 mm/day</li>
@@ -23,14 +34,17 @@
 <li>6 201-999 mm/day</li>
 <li>7 Stable</li>
 </ul>
-<ul>A map for of critical rainfall map (mm/day)
-</ul>
-</div>
-<h1>AUTHORS</h1>
-<div>
-Andrea Filipello, University of Turin, Italy mail</div>
-<div>Daniele Strigaro, University of Milan, Italy mail
-</div>
-<h1>REFERENCES</h1>
-<div>Montgomery, D. R. and Dietrich, W. E.: A physically based model for the topographic control of shallow landsliding,Water Resour. Res., 30, 1153–1171, 1994.</div>
 
+A map for of critical rainfall map (mm/day).
+
+<h2>AUTHORS</h2>
+
+<p>Andrea Filipello, University of Turin, Italy mail</p>
+<p>Daniele Strigaro, University of Milan, Italy mail</p>
+
+<h2>REFERENCES</h2>
+
+<p>Montgomery, D. R. and Dietrich, W. E.: A physically based model for the
+topographic control of shallow landsliding,Water Resour. Res., 30, 1153-1171, 1994.</p>
+
+<p><i>Last changed: $Date$</i>

Modified: grass-addons/grass7/raster/r.shalstab/r.shalstab.py
===================================================================
--- grass-addons/grass7/raster/r.shalstab/r.shalstab.py	2019-01-17 20:53:33 UTC (rev 73967)
+++ grass-addons/grass7/raster/r.shalstab/r.shalstab.py	2019-01-17 21:34:28 UTC (rev 73968)
@@ -108,11 +108,6 @@
     except:
         sys.exit("grass.script can't be imported.")
 
-if not os.environ.has_key("GISBASE"):
-    print("You must be in GRASS GIS to run this program.")
-    sys.exit(1)
-
-
 def main():
     r_elevation = options['dem'].split('@')[0]
     mapname = options['dem'].replace("@", " ")

Modified: grass-addons/grass7/raster/r.to.vect.lines/r.to.vect.lines.py
===================================================================
--- grass-addons/grass7/raster/r.to.vect.lines/r.to.vect.lines.py	2019-01-17 20:53:33 UTC (rev 73967)
+++ grass-addons/grass7/raster/r.to.vect.lines/r.to.vect.lines.py	2019-01-17 21:34:28 UTC (rev 73968)
@@ -125,7 +125,7 @@
 
     # open new 3D vector map
     Vect_open_new(map_info, outmap, True)
-    print 'ddd'
+    print('ddd')
     Vect_hist_command(map_info)
 
     # Create and initialize structs to store points/lines and category numbers
@@ -139,7 +139,7 @@
     zL = LineArrayType()
 
     #### iterate through map rows
-    for row in xrange(rows):
+    for row in range(rows):
         if row % skip != 0:
             continue
 
@@ -157,11 +157,11 @@
 
         # reset
         n = 0
-        for col in xrange(cols):
+        for col in range(cols):
             xL[col] = yL[col] = zL[col] = 0
 
         # TODO check for NULL
-        for col in xrange(cols):
+        for col in range(cols):
 #            if not G_is_null_value(byref(in_rast[col]), data_type):
             if in_rast[col] > -2e9:
                 xL[n] = Rast_col_to_easting((col + 0.5), byref(region))

Modified: grass-addons/grass7/raster/r.vif/r.vif.py
===================================================================
--- grass-addons/grass7/raster/r.vif/r.vif.py	2019-01-17 20:53:33 UTC (rev 73967)
+++ grass-addons/grass7/raster/r.vif/r.vif.py	2019-01-17 21:34:28 UTC (rev 73968)
@@ -91,7 +91,7 @@
 import sys
 import math
 import numpy as np
-from cStringIO import StringIO
+from io import StringIO
 import uuid
 import tempfile
 import atexit
@@ -123,7 +123,7 @@
 
 def CheckLayer(envlay):
     """Check if the input layers exist. If not, exit with warning"""
-    for chl in xrange(len(envlay)):
+    for chl in range(len(envlay)):
         ffile = gs.find_file(envlay[chl], element='cell')
         if ffile['fullname'] == '':
             gs.fatal("The layer " + envlay[chl] + " does not exist.")
@@ -198,7 +198,7 @@
     IPR = options['retain'].split(',')
     if IPR != ['']:
         CheckLayer(IPR)
-        for k in xrange(len(IPR)):
+        for k in range(len(IPR)):
             if IPR[k] not in IPF:
                 IPF.extend([IPR[k]])
     IPFn = [i.split('@')[0] for i in IPF]
@@ -229,8 +229,8 @@
     # VIF is computed once only
     if MXVIF == '':
         # Print header of table to std output
-        print('{0[0]:{1}s} {0[1]:8s} {0[2]:8s}'.format(
-                ['variable', 'vif', 'sqrtvif'], nlength))
+        print(('{0[0]:{1}s} {0[1]:8s} {0[2]:8s}'.format(
+                ['variable', 'vif', 'sqrtvif'], nlength)))
 
         # Compute the VIF
         for i, e in enumerate(IPFn):
@@ -249,11 +249,11 @@
             out_vif.append(vifstat[0])
             out_sqrt.append(vifstat[1])
             out_variable.append(e)
-            print('{0[0]:{1}s} {0[1]:8.2f} {0[2]:8.2f}'.format([IPFn[i],
-                  vifstat[0], vifstat[1]], nlength))
-        print
+            print(('{0[0]:{1}s} {0[1]:8.2f} {0[2]:8.2f}'.format([IPFn[i],
+                  vifstat[0], vifstat[1]], nlength)))
+        print()
         if len(OPF) > 0:
-            print("Statistics are written to {}\n".format(OPF))
+            print(("Statistics are written to {}\n".format(OPF)))
 
     # The VIF stepwise variable selection procedure
     else:
@@ -277,10 +277,10 @@
             # print the header of the output table to the console
             if not flag_s:
                 print("\n")
-                print("VIF round " + str(m))
+                print(("VIF round " + str(m)))
                 print("--------------------------------------")
-                print('{0[0]:{1}s} {0[1]:>8s} {0[2]:>8s}'.format(
-                    ['variable', 'vif', 'sqrtvif'], nlength))
+                print(('{0[0]:{1}s} {0[1]:>8s} {0[2]:>8s}'.format(
+                    ['variable', 'vif', 'sqrtvif'], nlength)))
 
             # Compute the VIF and sqrt(vif) for all variables in this round
             for k, e in enumerate(IPFn):
@@ -305,8 +305,8 @@
 
                 # print result to console
                 if not flag_s:
-                    print('{0[0]:{1}s} {0[1]:8.2f} {0[2]:8.2f}'.
-                          format([IPFn[k], vifstat[0], vifstat[1]], nlength))
+                    print(('{0[0]:{1}s} {0[1]:8.2f} {0[2]:8.2f}'.
+                          format([IPFn[k], vifstat[0], vifstat[1]], nlength)))
 
                 # If variable is set to be retained by the user, the VIF
                 # is set to -9999 to ensure it will not have highest VIF
@@ -331,9 +331,9 @@
             print("/n")
             print("selected variables are: ")
             print("--------------------------------------")
-            print(', '.join(IPFn))
+            print((', '.join(IPFn)))
         else:
-            print(','.join(IPFn))
+            print((','.join(IPFn)))
 
     if len(OPF) > 0:
         try:
@@ -340,12 +340,12 @@
             text_file = open(OPF, "w")
             if MXVIF == '':
                 text_file.write("variable,vif,sqrtvif\n")
-                for i in xrange(len(out_vif)):
+                for i in range(len(out_vif)):
                     text_file.write('{0:s},{1:.6f},{2:.6f}\n'.format(
                         out_variable[i], out_vif[i], out_sqrt[i]))
             else:
                 text_file.write("round,removed,variable,vif,sqrtvif\n")
-                for i in xrange(len(out_vif)):
+                for i in range(len(out_vif)):
                     text_file.write('{0:d},{1:s},{2:s},{3:.6f},{4:.6f}\n'.
                                     format(out_round[i], out_removed[i],
                                            out_variable[i], out_vif[i],

Modified: grass-addons/grass7/raster/r.width.funct/r.width.funct.py
===================================================================
--- grass-addons/grass7/raster/r.width.funct/r.width.funct.py	2019-01-17 20:53:33 UTC (rev 73967)
+++ grass-addons/grass7/raster/r.width.funct/r.width.funct.py	2019-01-17 21:34:28 UTC (rev 73968)
@@ -61,20 +61,20 @@
 
     for i in range(len(stats)):
         if i == 0:
-            zn[i,0],  zn[i,1] = map(float, stats[i].split(' '))
+            zn[i,0],  zn[i,1] = list(map(float, stats[i].split(' ')))
             zn[i,1] = zn[i,1]
             zn[i,2] = zn[i,1] * res
         if i != 0:
-            zn[i,0],  zn[i,1] = map(float, stats[i].split(' '))
+            zn[i,0],  zn[i,1] = list(map(float, stats[i].split(' ')))
             zn[i,2] = zn[i,1] + zn[i-1,2]
             zn[i,3] = zn[i,1] * (res**2)
 
     totcell = sum(zn[:,1])
-    print "Tot. cells", totcell
+    print("Tot. cells", totcell)
     totarea = totcell * (res**2)
-    print "Tot. area", totarea
+    print("Tot. area", totarea)
     maxdist = max(zn[:,0])
-    print "Max distance", maxdist
+    print("Max distance", maxdist)
 
     for i in range(len(stats)):
         kl[i,0] = zn[i,0]
@@ -94,20 +94,20 @@
     # plot
     plotImage(zn[:,0], zn[:,3], options['image']+'_width_function.png','-','x','W(x)','Width Function')
 
-    print "==========================="
-    print "Width Function | quantiles"
-    print "==========================="
-    print '%.0f' %findint(kl,0.05) , "|", 0.05
-    print '%.0f' %findint(kl,0.15) , "|", 0.15
-    print '%.0f' %findint(kl,0.3) , "|", 0.3
-    print '%.0f' %findint(kl,0.4) , "|", 0.4
-    print '%.0f' %findint(kl,0.5) , "|", 0.5
-    print '%.0f' %findint(kl,0.6) , "|", 0.6
-    print '%.0f' %findint(kl,0.7) , "|", 0.7
-    print '%.0f' %findint(kl,0.85) , "|", 0.85
-    print '%.0f' %findint(kl,0.95) , "|", 0.95
-    print '\n'
-    print 'Done!'
+    print("===========================")
+    print("Width Function | quantiles")
+    print("===========================")
+    print('%.0f' %findint(kl,0.05) , "|", 0.05)
+    print('%.0f' %findint(kl,0.15) , "|", 0.15)
+    print('%.0f' %findint(kl,0.3) , "|", 0.3)
+    print('%.0f' %findint(kl,0.4) , "|", 0.4)
+    print('%.0f' %findint(kl,0.5) , "|", 0.5)
+    print('%.0f' %findint(kl,0.6) , "|", 0.6)
+    print('%.0f' %findint(kl,0.7) , "|", 0.7)
+    print('%.0f' %findint(kl,0.85) , "|", 0.85)
+    print('%.0f' %findint(kl,0.95) , "|", 0.95)
+    print('\n')
+    print('Done!')
 
 def plotImage(x,y,image,type,xlabel,ylabel,title):
     plt.plot(x, y, type)



More information about the grass-commit mailing list