1

How can I set the Grass Region in Python without already having a map in the Mapset? Basically I am looking for the equivalent to this window

enter image description here

Currently I am only able to extent an existing region, which leads in my case to very big regions.

5

How about this:

import grass.script as grass

grass.run_command('g.region', n=10, s=9, e=35, w=33, ewres=0.1, nsres=0.2, verbose=True, flags='p')
    projection: 3 (Latitude-Longitude)
    zone:       0
    datum:      wgs84
    ellipsoid:  wgs84
    north:      10N
    south:      9N
    west:       33E
    east:       35E
    nsres:      0:12
    ewres:      0:06
    rows:       5
    cols:       20
    cells:      100
  • g.region requires in my Grass (6.4.3) a parameter <map> (Raster map to change). What version are you on? What am I doing wrong? In the documentation I don't see this parameter either. – ustroetz Nov 14 '13 at 18:13
  • No, g.region works on the overall "computational region", and is not specific to one map. That's the same for all version. THere is a different command, r.region which changes the extent and resolution of a single raster. Is that what you meant? – Micha Nov 16 '13 at 11:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.