<div dir="ltr"><div class="gmail_quote"><div dir="ltr"><div><p style="margin:1.2em 0px!important">Dear devs,</p><p style="margin:1.2em 0px!important">I got different results if I use <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline">ctypes</code> or the module <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline">g.region</code>, I wrote:</p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline;white-space:pre-wrap;overflow:auto;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important;display:block;padding:0.5em;color:rgb(51,51,51);background-color:rgb(248,248,255);background-repeat:initial initial"><span style="color:rgb(51,51,51);font-weight:bold">import</span> ctypes
<span style="color:rgb(51,51,51);font-weight:bold">import</span> grass.lib.gis <span style="color:rgb(51,51,51);font-weight:bold">as</span> libgis
<span style="color:rgb(51,51,51);font-weight:bold">from</span> grass <span style="color:rgb(51,51,51);font-weight:bold">import</span> script
SEP = <span style="color:rgb(221,17,68)">'\n\n'</span>
c_region = ctypes.pointer(libgis.Cell_head())
<span style="color:rgb(153,153,136);font-style:italic">## read current region </span>
libgis.G_get_set_window(c_region)
print(<span style="color:rgb(221,17,68)">'original'</span>)
print(c_region.contents.ns_res)
print(c_region.contents.rows)
print(c_region.contents.ew_res)
print(c_region.contents.cols)
print(SEP)
<span style="color:rgb(153,153,136);font-style:italic">## change resolution </span>
c_region.contents.ns_res = <span style="color:rgb(0,153,153)">100.</span>
c_region.contents.ew_res = <span style="color:rgb(0,153,153)">100.</span>
<span style="color:rgb(153,153,136);font-style:italic">## adjust </span>
libgis.G_adjust_Cell_head(c_region, <span style="color:rgb(0,153,153)">0</span>, <span style="color:rgb(0,153,153)">0</span>)
print(<span style="color:rgb(221,17,68)">'changed'</span>)
print(c_region.contents.ns_res)
print(c_region.contents.rows)
print(c_region.contents.ew_res)
print(c_region.contents.cols)
print(SEP)
<span style="color:rgb(153,153,136);font-style:italic">## save current </span>
libgis.G_set_window(c_region)
print(script.read_command(<span style="color:rgb(221,17,68)">"g.region"</span>, flags=<span style="color:rgb(221,17,68)">"p"</span>))
print(SEP)
<span style="color:rgb(153,153,136);font-style:italic">## read current region </span>
libgis.G_get_set_window(c_region)
print(<span style="color:rgb(221,17,68)">'after'</span>)
print(c_region.contents.ns_res)
print(c_region.contents.rows)
print(c_region.contents.ew_res)
print(c_region.contents.cols)
print(SEP)
</code></pre>
<p style="margin:1.2em 0px!important">The output is:</p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline;white-space:pre-wrap;overflow:auto;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important;display:block;padding:0.5em;color:rgb(51,51,51);background-color:rgb(248,248,255);background-repeat:initial initial">original
<span style="color:rgb(0,153,153)">10.0</span>
<span style="color:rgb(0,153,153)">1350</span>
<span style="color:rgb(0,153,153)">10.0</span>
<span style="color:rgb(0,153,153)">1500</span>
changed
<span style="color:rgb(0,153,153)">100.0</span>
<span style="color:rgb(0,153,153)">135</span>
<span style="color:rgb(0,153,153)">100.0</span>
<span style="color:rgb(0,153,153)">150</span>
projection: <span style="color:rgb(0,153,153)">99</span> (Lambert Conformal Conic)
zone: <span style="color:rgb(0,153,153)">0</span>
datum: nad83
ellipsoid: a=<span style="color:rgb(0,153,153)">6378137</span> es=<span style="color:rgb(0,153,153)">0.006694380022900787</span>
north: <span style="color:rgb(0,153,153)">228500</span>
south: <span style="color:rgb(0,153,153)">215000</span>
west: <span style="color:rgb(0,153,153)">630000</span>
east: <span style="color:rgb(0,153,153)">645000</span>
nsres: <span style="color:rgb(0,153,153)">10</span>
ewres: <span style="color:rgb(0,153,153)">10</span>
rows: <span style="color:rgb(0,153,153)">1350</span>
cols: <span style="color:rgb(0,153,153)">1500</span>
cells: <span style="color:rgb(0,153,153)">2025000</span>
after
<span style="color:rgb(0,153,153)">100.0</span>
<span style="color:rgb(0,153,153)">135</span>
<span style="color:rgb(0,153,153)">100.0</span>
<span style="color:rgb(0,153,153)">150</span>
</code></pre>
<p style="margin:1.2em 0px!important">Any Ideas?</p><span class="HOEnZb"><font color="#888888"><p style="margin:1.2em 0px!important">Pietro</p></font></span></div></div></div></div>