[GRASS-user] v.in.ogr in Python script not working
Uwe Fischer
gisfisch at t-online.de
Thu Mar 3 04:35:50 PST 2016
Hello,
I' new to this list and this is my first question. I try to develop a script
that is able to import CAD files (MicroStation DGN) into a grass mapset.
First, I tried the command v.in.ogr in the menu system and everything works
fine. The result is exactly as desired. Then, I tried to write a Python
script that is able to do exactly the same but without starting GRASS.
The command line provided by the menu input (in QGIS' Grass toolbox) reads:
v.in.ogr dsn=D:/my.dgn output=gr03 type=boundary,centroid snap=0.01
min_area=1 "where="Level" = 1" -o
Searching the internet for sample scripts, I found some of those and
modified my command string according to the samples:
import grass.script as grass
import grass.script.setup as gsetup
gsetup.init(gisbase,gisdbase,location,mapset)
input_dgn = "D:\\my.dgn"
grass.run_command("v.in.ogr",
dsn = input_dgn,
output = 'gr03',
type = 'boundary,centroid',
snap = 0.01,
min_area = 1,
where = """"Level" = 1""")
Unfortunately, this does not work. I get an error crash message telling me
that v.in.ogr does not work any more. I tried many different options,
including other use of quotes or leaving some args off. Nothing helped.
Maybe there is a keyword conflict or an issue with the order of the args?
The "where" part is very important since it helps me split the data like i
need to. I use Grass 6.4.4
Thanks a lot for help an ideas,
Regards, Uwe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20160303/a38bba02/attachment.html>
More information about the grass-user
mailing list