|
| 1 | +#!/usr/bin/env python |
| 2 | + |
| 3 | +############################################################################ |
| 4 | +# |
| 5 | +# MODULE: qgis.v.kernel.rast.py |
| 6 | +# AUTHOR(S): Radim Blazek |
| 7 | +# |
| 8 | +# PURPOSE: Export a vectore to PostGIS (PostgreSQL) database table |
| 9 | +# COPYRIGHT: (C) 2009 by Radim Blazek |
| 10 | +# |
| 11 | +# This program is free software under the GNU General Public |
| 12 | +# License (>=v2). Read the file COPYING that comes with GRASS |
| 13 | +# for details. |
| 14 | +# |
| 15 | +############################################################################# |
| 16 | + |
| 17 | +#%Module |
| 18 | +#% description: Generates a raster density map from vector points data using a moving 2D isotropic Gaussian kernel. |
| 19 | +#% keywords: vector, export, database |
| 20 | +#%End |
| 21 | + |
| 22 | +#%option |
| 23 | +#% key: input |
| 24 | +#% type: string |
| 25 | +#% gisprompt: old,vector,vector |
| 26 | +#% key_desc : name |
| 27 | +#% description: Input vector with training points |
| 28 | +#% required : yes |
| 29 | +#%end |
| 30 | + |
| 31 | +#%option |
| 32 | +#% key: stddeviation |
| 33 | +#% type: double |
| 34 | +#% description: Standard deviation in map units |
| 35 | +#% required : yes |
| 36 | +#%end |
| 37 | + |
| 38 | +#%option |
| 39 | +#% key: output |
| 40 | +#% type: string |
| 41 | +#% gisprompt: new,cell,raster |
| 42 | +#% key_desc : name |
| 43 | +#% description: Output raster map |
| 44 | +#% required : yes |
| 45 | +#%end |
| 46 | + |
| 47 | +import sys |
| 48 | +import os |
| 49 | +import string |
| 50 | +try: |
| 51 | + from grass.script import core as grass |
| 52 | +except ImportError: |
| 53 | + import grass |
| 54 | +except: |
| 55 | + raise Exception ("Cannot find 'grass' Python module. Python is supported by GRASS from version >= 6.4" ) |
| 56 | + |
| 57 | +def main(): |
| 58 | + input = options['input'] |
| 59 | + output = options['output'] |
| 60 | + stddeviation = options['stddeviation'] |
| 61 | + |
| 62 | + if grass.run_command('v.kernel', input=input, stddeviation=stddeviation, output=output ) != 0: |
| 63 | + grass.fatal("Cannot run v.kernel.") |
| 64 | + |
| 65 | +if __name__ == "__main__": |
| 66 | + options, flags = grass.parser() |
| 67 | + main() |
0 commit comments