Hi, I'm glad you opened that topic. If you change region in C or using ctypes in Python, it is affecting only the current process. While g.region reads/writes the file with region but obviously will not change your process region in Python (when using ctypes). And then there are the temporary regions. To design an API for it is a challenge. I think I even wrote something about it to documentation but it needs to be completely rewritten to be actually readable.
Vaclav On Thu, Feb 27, 2014 at 5:02 PM, Pietro <[email protected]> wrote: > Dear devs, > > I got different results if I use ctypes or the module g.region, I wrote: > > import ctypes import grass.lib.gis as libgis from grass import script > > SEP = '\n\n' > > c_region = ctypes.pointer(libgis.Cell_head()) > ## read current region > libgis.G_get_set_window(c_region) > > print('original') > print(c_region.contents.ns_res) > print(c_region.contents.rows) > print(c_region.contents.ew_res) > print(c_region.contents.cols) > print(SEP) > ## change resolution > c_region.contents.ns_res = 100. > c_region.contents.ew_res = 100. > ## adjust > libgis.G_adjust_Cell_head(c_region, 0, 0) > > print('changed') > print(c_region.contents.ns_res) > print(c_region.contents.rows) > print(c_region.contents.ew_res) > print(c_region.contents.cols) > print(SEP) > ## save current > libgis.G_set_window(c_region) > > print(script.read_command("g.region", flags="p")) > print(SEP) > ## read current region > libgis.G_get_set_window(c_region) > print('after') > print(c_region.contents.ns_res) > print(c_region.contents.rows) > print(c_region.contents.ew_res) > print(c_region.contents.cols) > print(SEP) > > The output is: > > original10.0135010.01500 > > changed100.0135100.0150 > > projection: 99 (Lambert Conformal Conic) > zone: 0 > datum: nad83 > ellipsoid: a=6378137 es=0.006694380022900787 > north: 228500 > south: 215000 > west: 630000 > east: 645000 > nsres: 10 > ewres: 10 > rows: 1350 > cols: 1500 > cells: 2025000 > > after100.0135100.0150 > > Any Ideas? > > Pietro > > _______________________________________________ > grass-dev mailing list > [email protected] > http://lists.osgeo.org/mailman/listinfo/grass-dev >
_______________________________________________ grass-dev mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/grass-dev
