<div dir="ltr">Shawn,<div><br></div><div>PyObject and GDALDatasetH are incompatible types and you can't pass the former to a function that expects the latter. I'm surprised your program can compile with these incompatible types.</div><div><br></div><div>Do you mean for your module to extend GDAL's Python bindings? If you look inside the C code of GDAL's Python bindings you may be able to see how to get the GDALDatasetH associated with a Python dataset object.</div><div><br></div><div>Hope this helps,</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 23, 2017 at 1:25 PM, Shawn Gong <span dir="ltr"><<a href="mailto:SGONG@mdacorporation.com" target="_blank">SGONG@mdacorporation.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




<div>
<div style="direction:ltr;font-family:Tahoma;color:#000000;font-size:10pt">
<div>
<p>Hi list,</p>
<p> </p>
<p>Has anyone done this before?</p>
<p>I try to pass a gdal dataset as an argument from Python to C.</p>
<p> </p>
<p>in my C code, I have</p>
<p>PyObject* py_my_func(PyObject *self, PyObject *args)<br>
{</p>
<p>    PyObject *poDataset;</p>
<p> </p>
<p>   if(!PyArg_ParseTuple(args, "Odd", &poDataset, &a1, &a2))<br>
  {<br>
    return NULL;<br>
  }</p>
<p> </p>
<p>  my_func(poDataset, a1, a2);<br>
}</p>
<p> </p>
<p>void my_func(GDALDatasetH hDataset, double a1, double a2)</p>
<p>{</p>
<p>}</p>
<p> </p>
<p>Python crashed and hDataset was NULL</p>
<p>Is it possible to do or I did something wrong?</p>
<p> </p>
<p>BTW, I have passed either a filename or a gdal array as an argument from Python to C, with success.</p>
<div style="FONT-SIZE:13px;FONT-FAMILY:Tahoma">
<div class="m_3308011925270217570BodyFragment"><font size="2"><font face="Tahoma">
<div class="m_3308011925270217570PlainText"></div></font> </font></div>
<div class="m_3308011925270217570PlainText"><font face="Tahoma">Thanks,<br>
Shawn<br>
</font></div>
</div>
</div>
</div>
</div>


<br>______________________________<wbr>_________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" rel="noreferrer" target="_blank">https://lists.osgeo.org/<wbr>mailman/listinfo/gdal-dev</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Sean Gillies</div></div>
</div>