Many thanks also for the link, it works!!
Sonja
Christian Kaiser a écrit :
Sonja,
I think you can use something like this:
grass.run_command("v.in.ogr", flags='o',
dsn=r'E:\pythoninput\Mercier_ditch.shp', output='ditch2', overwrite=True)
See the make_command function for the options:
<http://download.osgeo.org/grass/grass6_progman/namespacepython_1_1core.html#a6745e7335b5bfcc30d89443fc912c63b>
For the flags not starting with -- but only with - (short flags), I think you
can just concatenate them (flags='oc' for example). For the long flags
(overwrite, verbose, quiet), they are a separate argument in the run_command
function.
Hope this helps,
Christian
On 28 janv. 2010, at 10:38, Sonja Jankowfsky wrote:
Many thanks.
So, the forward slash does not work in windows. (and I know I should not use
literal pathnames, but it's just for testing). So either two forward or
backward slashs, or one backward.
One other question concerning the flags: How can I put two flags at the same
time, as for example -o --o for overwriting the projection check and an already
existing file?
I tried everything: flags='o', flags='-o'
flags='o -o' or flags='-o o'
flags='o' '-o'
but the interpreter isn't happy with this solutions.
Is there any way to put several flags?
Sonja
Glynn Clements a écrit :
Sonja Jankowfsky wrote:
I'm running a python script under windows/eclipse, where I try to import a
shape and a raster file with v.in.ogr and r.in.gdal.
grass.run_command("r.in.gdal",'-o', input='E:\pythoninput\mnyzeron5m.asc',
output='dem5m', '-o')
Python uses backslash as an escape character; if you need to use a
backslash in a string literal, either use two backslashes, i.e.:
input='E:\\pythoninput\\mnyzeron5m.asc'
or use a raw literal, i.e.:
input=r'E:\pythoninput\mnyzeron5m.asc'
Alternatively, a forward slash will work. But scripts should rarely
need to have literal pathnames embedded within them.
grass.run_command("v.in.ogr", '-o', dsn='E:\pythoninput\Mercier_ditch.shp',
output='ditch2', '-o')
run_command() etc use the "flags" argument to specify flags (without
the leading '-'), e.g.:
grass.run_command("v.in.ogr", flags='o',
dsn=r'E:\pythoninput\Mercier_ditch.shp', output='ditch2')
--
Sonja Jankowfsky
UR Hydrologie-Hydraulique
Cemagref de Lyon
3 bis quai Chauveau CP 220
69336 Lyon Cedex 09
FRANCE
Tel : (+33)4 72 20 86 11 Fax : (+33)4 78 47 78 75
_______________________________________________
grass-user mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-user
--
Sonja Jankowfsky
UR Hydrologie-Hydraulique
Cemagref de Lyon
3 bis quai Chauveau CP 220
69336 Lyon Cedex 09
FRANCE
Tel : (+33)4 72 20 86 11
Fax : (+33)4 78 47 78 75
_______________________________________________
grass-user mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-user