<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-GB" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;mso-fareast-language:EN-US">In 3.1 and earlier, GDAL had short helper scripts to allow the deprecated imports, named “gdal.py”, “osr.py”, and “ogr.py”, with contents like:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;mso-fareast-language:EN-US">```<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;mso-fareast-language:EN-US"># import osgeo.gdal as a convenience<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;mso-fareast-language:EN-US">from osgeo.gdal import deprecation_warn<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;mso-fareast-language:EN-US">deprecation_warn('gdal')<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;mso-fareast-language:EN-US">from osgeo.gdal import *<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;mso-fareast-language:EN-US">```<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;mso-fareast-language:EN-US">You could create such very short modules on your local machine (presumably not bothering to include the deprecation warning!). Using PYTHONPATH to point to a directory
with them in is probably the simplest way. <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;mso-fareast-language:EN-US">The source for the Python wrappers in GDAL 3.1 can be found at:
<a href="https://github.com/OSGeo/gdal/tree/release/3.1/gdal/swig/python">https://github.com/OSGeo/gdal/tree/release/3.1/gdal/swig/python</a><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;mso-fareast-language:EN-US">(Alternatively, I’d argue it wouldn’t be too hard to do some global search and replace for “import gdal”->”from osgeo import gdal”, using your IDE or some command line
tools, but I presume you’re not tempted by that idea!)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span style="font-family:"Arial",sans-serif;color:black">Dr Daniel Evans<o:p></o:p></span></b></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:#F6A124">Software Developer<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div dir="ltr" style="mso-line-height-rule:exactly;-webkit-text-size-adjust:100%;direction:ltr;"><table cellpadding="0" cellspacing="0" border="0" style="width:100%;"><tr style="font-size:0;"><td align="left" style="vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="font-size:0;"><tr style="font-size:0;"><td align="left" style="padding:10px 0 0;vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="font-size:0;color:#4A4A49;font-style:normal;font-weight:700;white-space:nowrap;"><tr style="font-size:14.67px;"><td align="left" style="padding:0;vertical-align:top;font-family:Arial;">e: <span style="font-family:remialcxesans;font-size:1px;color:#FFFFFF;line-height:1px;"></span></td><td align="left" style="padding:0 0 0 4px;vertical-align:top;color:#F6A124;font-family:Arial;font-weight:400;"><a href="mailto:Daniel.Evans@jbarisk.com" target="_blank" id="LPlnk689713" style="text-decoration:none;color:#F6A124;"><strong style="font-weight:400;">Daniel.Evans@jbarisk.com</strong></a></td></tr><tr style="font-size:14.67px;"><td align="left" style="padding:0;vertical-align:top;font-family:Arial;">t: </td><td align="left" style="padding:0 0 0 4px;vertical-align:top;color:#F6A124;font-family:Arial;font-weight:400;"><a href="tel:+44%20(0)1756%20799919" target="_blank" id="LPlnk689713" style="text-decoration:none;color:#F6A124;"><strong style="font-weight:400;">+44 (0)1756 799919</strong></a></td></tr><tr style="font-size:0;"><td align="left" style="padding:0;vertical-align:top;"></td><td align="left" style="padding:0 0 0 4px;vertical-align:top;"></td></tr></table></td></tr></table></td></tr><tr style="color:#000001;font-size:14.67px;font-style:normal;font-weight:400;white-space:nowrap;"><td align="left" style="vertical-align:top;font-family:Arial;"><a href="http://www.jbarisk.com/" target="_blank" id="LPlnk689713" title="Click to visit our website" style="text-decoration:none;color:#F6A124;"><strong style="font-weight:400;">www.jbarisk.com</strong></a></td></tr><tr style="font-size:0;"><td align="left" style="vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="font-size:0;"><tr style="font-size:0;"><td align="left" style="padding:10px 0 0;vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="font-size:0;"><tr style="font-size:0;"><td rowspan="3" align="left" style="padding:0 0 5px;vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="width:100%;font-size:0;"><tr style="font-size:0;"><td align="left" style="vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="font-size:0;line-height:normal;"><tr style="font-size:0;"><td align="left" style="padding:10px 0 15px;vertical-align:top;"><img src="cid:image609265.png@488B08BD.81877BA2" height="52" border="0" alt="" style="height:52px;min-height:52px;max-height:52px;font-size:0;" /></td></tr></table></td></tr><tr style="font-size:0;"><td align="left" style="vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="font-size:0;"><tr style="font-size:0;"><td align="left" style="padding:0 0 12px;vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="height:30px;font-size:0;"><tr style="font-size:0;"><td align="left" style="vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="font-size:0;line-height:normal;"><tr style="font-size:0;"><td align="left" style="padding:0 4px 5px 0;vertical-align:top;"><a href="https://www.facebook.com/TheFloodPeople" target="_blank" id="LPlnk689713" style="text-decoration:none;"><img src="cid:image464149.png@A95A3999.1229E029" width="34" border="0" title="Facebook" alt="Facebook" style="width:34px;min-width:34px;max-width:34px;font-size:12px;" /></a></td></tr></table></td><td align="left" style="vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="font-size:0;line-height:normal;"><tr style="font-size:0;"><td align="left" style="padding:0 4px 5px 0;vertical-align:top;"><a href="https://www.linkedin.com/company/jba-risk-management/" target="_blank" id="LPlnk689713" style="text-decoration:none;"><img src="cid:image605237.png@B54A1885.0A4CC181" width="34" border="0" title="LinkedIn" alt="LinkedIn" style="width:34px;min-width:34px;max-width:34px;font-size:12px;" /></a></td></tr></table></td><td align="left" style="vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="font-size:0;line-height:normal;"><tr style="font-size:0;"><td align="left" style="padding:0 4px 5px 0;vertical-align:top;"><a href="https://twitter.com/JBARisk" target="_blank" id="LPlnk689713" style="text-decoration:none;"><img src="cid:image663108.png@A2CBEA56.68823639" width="34" border="0" title="Twitter" alt="Twitter" style="width:34px;min-width:34px;max-width:34px;font-size:12px;" /></a></td></tr></table></td><td align="left" style="vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="font-size:0;line-height:normal;"><tr style="font-size:0;"><td align="left" style="padding:0 4px 5px 0;vertical-align:top;"><a href="https://www.youtube.com/channel/UC0iatom2jYbW96voW0rlpCw" target="_blank" id="LPlnk689713" style="text-decoration:none;"><img src="cid:image903814.png@65CDA168.A9BB9726" width="34" border="0" title="YouTube" alt="YouTube" style="width:34px;min-width:34px;max-width:34px;font-size:12px;" /></a></td></tr></table></td></tr></table></td></tr></table></td></tr></table></td><td style="padding:0;"> </td></tr><tr style="font-size:0;"><td style="padding:0;"> </td></tr><tr style="font-size:0;"><td style="padding:0;"> </td></tr></table></td></tr></table></td></tr><tr style="font-size:0;"><td align="left" style="vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="font-size:0;"><tr style="font-size:0;"><td align="left" style="padding:7px 0 5px;border-top:solid 1px #4A4A49;border-right:none;border-bottom:none;border-left:none;vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="white-space:normal;color:#444444;font-size:14.67px;font-family:Calibri,Arial,sans-serif;font-weight:400;font-style:normal;text-align:left;line-height:12px;"><tr style="font-size:9px;"><td style="font-family:Arial;"><span style="background-color:#FFFFFF;">All JBA Risk Management's email messages contain confidential information and are intended only for the individual(s) named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail.</span><br /><span style="background-color:#FFFFFF;">Please notify the sender immediately by email if you have received this email by mistake and delete this email from your system.</span> <br /><span style="background-color:#FFFFFF;">JBA Risk Management Limited is registered in England, company number 07732946, 1 Broughton Park, Old Lane North, Broughton, Skipton, North Yorkshire, BD23 3FD, England</span><span style="color:#000001;">.</span><br /></td></tr></table></td></tr></table></td></tr></table></div><div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US">From:</span></b><span lang="EN-US"> gdal-dev <gdal-dev-bounces@lists.osgeo.org>
<b>On Behalf Of </b>Jose Gomez-Dans<br>
<b>Sent:</b> 07 April 2021 12:11<br>
<b>To:</b> gdal-dev <gdal-dev@lists.osgeo.org><br>
<b>Subject:</b> [gdal-dev] "New" style import<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">Hi,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">I've recently updated GDAL to 3.2.1. I mostly use it from Python, and have oodles of scripts from the past that use "import gdal" somewhere. With the newer versions of GDAL, this is deprecated and is now "from osgeo import gdal".
<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Is there some hacky workaround/sacrifice to the technical debt gods to carry on using "import gdal" for legacy codes?
<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Thanks!<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Jose<o:p></o:p></p>
</div>
</div>
</div>
</body>
</html>