[GRASS-dev] [GRASS-user] pygrass: Region.set_current() doesn't work

Vaclav Petras wenzeslaus at gmail.com
Fri Jul 25 06:21:25 PDT 2014


On Fri, Jul 25, 2014 at 5:05 AM, Pietro <peter.zamb at gmail.com> wrote:

> On Fri, Jul 25, 2014 at 10:39 AM, Martin Zbinden
> <martin.zbinden at gmail.com> wrote:
> > If I understand correctly, Region.set_current() can be used
> > to effectively change the region currently used by GRASS. But changing
> > extent of Raster()-object and executing set_current() does not have
> > any effect.
>
> I found the same thing some months ago:
>
> https://lists.osgeo.org/pipermail/grass-dev/2014-February/067543.html
>
> as explained by Vaclav:
>
> "If you change region in C or using ctypes in Python, it is affecting
> only the current process."


And on the hand, if you change region using g.region, only region for
subprocesses is changed but library functions are not affected. So,
g.region will affect pygrass.modules.Module but not pygrass.raster,
pygrass.vector and others.

I was actually the one saying that pygrass Region should use library
functions, not g.region, to be part of C library wrapper together with
other pygrass functions. However, pygrass.modules needs their own
mechanism, perhaps simple Module('g.region', ...) is the most appropriate.

One could suggest to have Region calling both g.region and library
functions but this could significantly decrease speed due to invocation of
subprocesses especially when Region API is in style region.set_north(),
region.set_south(). Maybe as a opt-in feature (set in constructor) but I'm
not 100% sure about that.

Vaclav
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20140725/41a9569b/attachment.html>


More information about the grass-dev mailing list