Hello all,
I am trying to use the pygrass API to create a contextmanager that set’s a temporary Region, but I am not sure which method I should be using. The following methods seem to be relevant:
Region.set_current()
Region.set_raster_region()
Region.write()
Could someone further clarify when each one should be used?
all the best,
Panos
Hi Panos,
On Sat, Apr 27, 2019 at 5:30 PM Panagiotis Mavrogiorgos
<pmav99@gmail.com> wrote:
Hello all,
I am trying to use the pygrass API to create a contextmanager that set's a temporary Region, but I am not sure which method I should be using. The following methods seem to be relevant:
Region.set_current()
Region.set_raster_region()
Region.write()
Could someone further clarify when each one should be used?
Here is some sample code:
https://grasswiki.osgeo.org/wiki/GRASS_Python_Scripting_Library#Using_temporary_region_for_computations
which makes use of script.core.use_temp_region()
https://grass.osgeo.org/grass77/manuals/libpython/script.html#script.core.use_temp_region
Others here may be able to suggest what's recommended.
Best,
Markus
On Sat, Apr 27, 2019 at 7:13 PM Markus Neteler <neteler@osgeo.org> wrote:
Here is some sample code:
https://grasswiki.osgeo.org/wiki/GRASS_Python_Scripting_Library#Using_temporary_region_for_computations
which makes use of script.core.use_temp_region()
https://grass.osgeo.org/grass77/manuals/libpython/script.html#script.core.use_temp_region
Thank you Markus,
The “problem” is that “use_temp_region()” is calling “g.region” and I would like to avoid that if possible, since it entails some overhead vs using the API.
The following methods seem to be relevant:
Region.set_current()
Region.set_raster_region()
Region.write()
As far as I can understand this, the only method that will actually change the computational region is “write()” am I correct?
Could also someone clarify what is the difference between “working region” mentioned in “set_current()” and the computational region?
all the best,
Panos