[GRASS-dev] creating temporary mapsets in a parallelized python script

Helmut Kudrnovsky hellik at web.de
Mon Apr 11 14:19:17 PDT 2016


Anna Petrášová wrote
> On Mon, Apr 11, 2016 at 4:46 PM, Helmut Kudrnovsky <

> hellik@

> > wrote:
>> Anna Petrášová wrote
>>> On Mon, Apr 11, 2016 at 4:04 PM, Helmut Kudrnovsky <
>>
>>> hellik@
>>
>>> > wrote:
>>>> Hi,
>>>>
>>>> in a parallelized python script it is needed to do the parallelized
>>>> jobs
>>>> in
>>>> different mapsets as region settings are changed during calculations.
>>>
>>> are you sure you need separate mapsets? You can also just use this:
>>>
>>> env = os.environ.copy()
>>> env['GRASS_REGION'] = grass.region_env(raster='elevation')
>>>
>>> gscript.run_command('r.viewshed', ..., env=env)
>>>
>>> Anna
>>>
>>>>
>>>> Any hints how to create temporary mapsets? Already existing pygrass /
>>>> pyscript functions?
>>>>
>>
>> the idea of the script is to run (1) by python's multiprocessing for more
>> than 600 points.
>>
>> IIRC (1) changes region during calculations, so several calculations may
>> interfere in regions settings.
>>
>>
> 
> I see, then it's easier to fix the script and use grass.use_temp_region

>From the manual:

script.core.use_temp_region()[source]¶
Copies the current region to a temporary region with “g.region save=”, then
sets WIND_OVERRIDE to refer to that region. Installs an atexit handler to
delete the temporary region upon termination.

Does this function mean that: while concurrent r.basin runs on different
CPUs in the same mapset, there is no interefering by region settings change
interefering?



-----
best regards
Helmut
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/creating-temporary-mapsets-in-a-parallelized-python-script-tp5260753p5260765.html
Sent from the Grass - Dev mailing list archive at Nabble.com.


More information about the grass-dev mailing list