[GRASS-dev] Fwd: different region if looking using ctypes or g.region

Pietro peter.zamb at gmail.com
Thu Feb 27 14:02:03 PST 2014


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20140227/0fcdd617/attachment.html>


More information about the grass-dev mailing list