[GRASS-user] Problem with r.in.gdal in Python

mdomnita mdomnita at gmail.com
Mon Apr 18 07:34:59 EDT 2011


Hello fellow GRASS users,

I have some problems using the commands that modify the rasters in my
dataset in a python script. I will post the code example for the r.in.gdal
but it is the same for g.remove.
I am quite new to Python GRASS programming so I do not really know a lot of
stuff about the libraries and functions.

The python script is as follows:
First, details about the environment, to see that some things work:
----
>>>import grass.script as grass
>>>env = grass.gisenv()
>>>print env
{'MAPSET': 'PERMANENT', 'GISDBASE': 'C:/Users/matei/Documents/GISDataBase',
'LOCATION_NAME': 'North-Carolina', 'GRASS_GUI': 'wxpython'}
>>>v = grass.read_command("g.version" )
>>>print v
GRASS 6.4.1 (2011)
>>>mapsets = grass.mapsets(False)
>>>print mapsets
['PERMANENT', 'landsat', 'sqlite', 'user1']
>>>r = grass.read_command("g.list", type='rast')
>>>print r
----------------------------------------------
raster files available in mapset <PERMANENT>:
Elev_100                  elev_srtm_30m             lsat7_2002_62 ....
----

And the problem:
---
>>>r =
grass.run_command("r.in.gdal",flags="o",input=r'D:\BazineWGS84\flowdir\w001001.adf',
output="FldirTmp",overwrite=True)
>>>print r
-1073741511
>>>r = grass.raster.raster_info("FldirTmp")
ERROR: Raster map <FldirTmp> not found
---

Other commands that create rasters like
grass.mapcalc("Elev_200=elevation+200") work well

I tried other possibilities like using forward slash or double backslashes
in the path, not using the o flag but it does the same.

I get that number ”-1073741511” as an answer and the result is not created.
It does not raise any error or anything else.

In the grass console the same thing works like a charm:
-----
r.in.gdal -o --overwrite input=D:\BazineWGS84\flowdir\w001001.adf
output=FldirTmp
Over-riding projection check
r.in.gdal complete. Raster map <FldirTmp> created.
r.info FldirTmp                                                                 

+----------------------------------------------------------------------------+
 | Layer:    FldirTmp                       Date: Mon Apr 18 12:35:46 2011   
|.....
-----
 


--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Problem-with-r-in-gdal-in-Python-tp6283306p6283306.html
Sent from the Grass - Users mailing list archive at Nabble.com.


More information about the grass-user mailing list