[GRASS-dev] [GRASS-SVN] r70632 - grass/trunk/scripts/v.report
Martin Landa
landa.martin at gmail.com
Mon Feb 20 00:44:49 PST 2017
2017-02-20 9:19 GMT+01:00 Huidae Cho <grass4u at gmail.com>:
> sure. usually, I don't backport, but I'll check the wiki. Thanks.
thanks for your effort. Would be nice if all devs would take care
about backports. Ma
>> >> > - f = grass.vector_db(map=mapname)[int(layer)]
>> >> > grass.fatal(_("There is a table connected to input
>> >> > vector map '%s', but "
>> >> > "there are no categories present in
>> >> > the
>> >> > key column '%s'. Consider using "
>> >> > "v.to.db to correct this.") %
>> >> > (mapname,
>> >> > f['key']))
>> >> > @@ -142,6 +142,7 @@
>> >> > for r2 in records2:
>> >> > records3.append(filter(lambda r1: r1[catcol] == r2[0],
>> >> > records1)[0] + r2[1:])
>> >> > else:
>> >> > + catcol = 0
>> >> > records1 = []
>> >> > p = grass.pipe_command('v.category', inp=mapname,
>> >> > layer=layer,
>> >> > option='print')
>> >> > for line in p.stdout:
>> >> > @@ -172,15 +173,18 @@
>> >> > numcols = len(colnames) + len(extracolnames)
>> >> >
>> >> > # calculate percents if requested
>> >> > - if units != '' and units in ['p', 'percent']:
>> >> > - # calculate total area value
>> >> > - areatot = 0
>> >> > + if units == 'percent' and option != 'coor':
>> >> > + # calculate total value
>> >> > + total = 0
>> >> > for r in records3:
>> >> > - areatot += float(r[-1])
>> >> > + total += float(r[-1])
>> >> >
>> >> > - # calculate area percentages
>> >> > - records4 = [float(r[-1]) * 100 / areatot for r in records3]
>> >> > - records3 = [r1 + [r4] for r1, r4 in zip(records1, records4)]
>> >> > + # calculate percentages
>> >> > + records4 = [float(r[-1]) * 100 / total for r in records3]
>> >> > + if type(records1[0]) == int:
>> >> > + records3 = [[r1] + [r4] for r1, r4 in zip(records1,
>> >> > records4)]
>> >> > + else:
>> >> > + records3 = [r1 + [r4] for r1, r4 in zip(records1,
>> >> > records4)]
>> >> >
>> >> > # sort results
>> >> > if options['sort']:
>> >> >
>> >> > _______________________________________________
>> >> > grass-commit mailing list
>> >> > grass-commit at lists.osgeo.org
>> >> > https://lists.osgeo.org/mailman/listinfo/grass-commit
>> >>
>> >>
>> >>
>> >> --
>> >> Martin Landa
>> >> http://geo.fsv.cvut.cz/gwiki/Landa
>> >> http://gismentors.cz/mentors/landa
>> >
>> >
>>
>>
>>
>> --
>> Martin Landa
>> http://geo.fsv.cvut.cz/gwiki/Landa
>> http://gismentors.cz/mentors/landa
>
>
--
Martin Landa
http://geo.fsv.cvut.cz/gwiki/Landa
http://gismentors.cz/mentors/landa
More information about the grass-dev
mailing list