<div dir="ltr">Alex,<div><br></div><div>see rasterio: <a href="https://github.com/mapbox/rasterio" target="_blank">https://github.com/mapbox/rasterio</a></div><div><br></div><div>It uses Cython (<a href="https://cython.readthedocs.io/en/latest/index.html" target="_blank">https://cython.readthedocs.io/en/latest/index.html</a>) to wrap GDAL rasters and related functions for use in Python.  You can use Cython to wrap C / C++ libraries for use in Python; how much you wrap depends on the interface you want between the two.</div><div><br></div><div>Hope that helps,</div><div><br></div><div>Brendan</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Dec 8, 2020 at 10:17 AM Alex HighViz <<a href="mailto:alexhighviz@hotmail.com" target="_blank">alexhighviz@hotmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">



<div>
<div dir="auto" style="direction:ltr;margin:0px;padding:0px;font-family:sans-serif;font-size:11pt;color:black">
Hi Paul,<br>
<br>
</div>
<div dir="auto" style="direction:ltr;margin:0px;padding:0px;font-family:sans-serif;font-size:11pt;color:black">
Yes there is a generic, "how do I expose a  C++ library to Python users" question. But there is a GDAL specific issue that the main inputs and outputs in my library are raster layers, and I am not sure how to pass those. Especially if my library is using GDAL
 and the user is using GDAL through Python. I can make my interface completely based on filenames, but that seems inefficient. Is this not a more commonly encountered problem?<br>
<br>
</div>
<div dir="auto" style="direction:ltr;margin:0px;padding:0px;font-family:sans-serif;font-size:11pt;color:black">
Thanks, Alex<span id="gmail-m_8055903877239950684gmail-m_-3280903892681362296ms-outlook-android-cursor"></span><br>
<br>
</div>
<div dir="auto" style="direction:ltr;margin:0px;padding:0px;font-family:sans-serif;font-size:11pt;color:black">
<span id="gmail-m_8055903877239950684gmail-m_-3280903892681362296OutlookSignature">
<div dir="auto" style="direction:ltr;margin:0px;padding:0px;font-family:sans-serif;font-size:11pt;color:black">
Get <a href="https://aka.ms/ghei36" target="_blank">Outlook for Android</a></div>
</span><br>
</div>
<hr style="display:inline-block;width:98%">
<div id="gmail-m_8055903877239950684gmail-m_-3280903892681362296divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Paul Harwood <<a href="mailto:runette@gmail.com" target="_blank">runette@gmail.com</a>><br>
<b>Sent:</b> Tuesday, December 8, 2020 4:46:07 PM<br>
<b>To:</b> Alex HighViz <<a href="mailto:alexhighviz@hotmail.com" target="_blank">alexhighviz@hotmail.com</a>><br>
<b>Cc:</b> <a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a> <<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a>><br>
<b>Subject:</b> Re: [gdal-dev] How to wrap a C++ library using GDAL in a Python library?</font>
<div> </div>
</div>
<div>
<div dir="ltr">I may have misunderstood but I think you are asking the wrong community.<br>
<br>
You can take your own C++ library and make it available to a Python library - see <a href="https://docs.python.org/3/extending/extending.html" target="_blank">https://docs.python.org/3/extending/extending.html</a> etc - but this is not the community to ask for advice about
 that. You can, of course, access GDAL in that c++ library using the c++ API but I don't think that doing so would change how you expose the API from your library in Python ...<br>
<br>
Perhaps you need to make your question more specific?</div>
<br>
<div>
<div dir="ltr">On Tue, 8 Dec 2020 at 12:37, Alex HighViz <<a href="mailto:alexhighviz@hotmail.com" target="_blank">alexhighviz@hotmail.com</a>> wrote:<br>
</div>
<blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Hello,</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<span style="color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif;font-size:12pt">Could somebody </span><span style="color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif;font-size:12pt">please put me on the right track with the following problem?</span><br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I have a C++ library that makes use of GDAL for processing raster maps and I would like to wrap some of its features into a Python library to make it accessible to a wider community.</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I would like my library to present functions that take rasters as input and produce rasters as outputs.  I can modify the C++ side to have the functions work on GDALRasterBands, GDALDatasets, or just on filenames. From my perspective I'd prefer to write any
 wrapping / boiler plate in C++ and have the Python parts as small as possible.</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I know this question has been asked before here, but I don't recall the answer and could not find it again. A simple example of "best practice" would be ideal.</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
With many thanks, Alex</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
</div>
_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">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/mailman/listinfo/gdal-dev</a><br>
</blockquote>
</div>
</div>
</div>

_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">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/mailman/listinfo/gdal-dev</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><font size="4">Brendan C. Ward</font><div><font color="#666666">Owner | Lead Software Engineer</font><br><div>Astute Spruce, LLC</div></div><div><a href="https://astutespruce.com/" target="_blank">astutespruce.com</a><br></div><div>541-250-9544</div></div></div></div></div></div></div>