[GRASS-user] g.region usage in python for overriding N, S, E, W values
Gökçen Güner
gokcenguner at gmail.com
Mon Jan 14 16:53:12 PST 2013
Hi,
I want to change North, East, South and West extent values of a raster map
using python. In GUI I've used g.region function like this:
g.region -g -a rast=band1_2005_etm at PERMANENT n=4256115 s=4045185 e=831315
w=601785
n=4256115
s=4045185
w=601785
e=831315
As you see what I got is what I set. But I couldn't do the same in python:
def loadMap(inputMapPath, outBandName):
mapLoaded = grass.run_command('r.in.gdal', input=inputMapPath,
output=outBandName, flags='o', overwrite=True)
if(mapLoaded == 0):
print "Map Loaded From " + inputMapPath + " to " + outBandName
else:
print "ERROR: Map Loaded From " + inputMapPath + " to " +
outBandName
regionizeMap(outBandName)
print ""
def regionizeMap(bandName):
mapRegionized = grass.run_command('g.region', rast=bandName, n=4256115,
s=4045185, e=831315, w=601785, flags='a', overwrite=True)
if(mapRegionized == 0):
print "Map Regionized: " + bandName
else:
print "ERROR: Map Regionized: " + bandName
print ""
def showRegionInfo(bandName):
r = grass.read_command('g.region', rast=bandName, flags='g',
verbose=True)
print bandName
print r
print ""
The output is:
Map Loaded From D:\gis\data\l71175034_03420050627_b10histeqmatched.tif to
band1_2005_etm
Map Regionized: band1_2005_etm
band1_2005_etm
n=4257015
s=4043385
w=601785
e=844215
You can see the differnce here, I set east to 831315 but what i got is
844215. What can I do the achieve same result with GUI?
Thanks in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20130115/49700cbd/attachment.html>
More information about the grass-user
mailing list