[gdal-dev] Using gdal_calc without python
Idan Miara
idan at miara.com
Sat Jan 7 23:31:36 PST 2023
Hi Carsten,
> You mean that I should zip the whole Python installation folder and copy
it to the customer environment?, Or just the Scripts folder?
Zipping just the scripts folder won't be helpful, as they are only thin
wrappers that are fully dependent on Python and the respective script.
It would be better to zip the whole Python folder and unzip it on the other
computer to the exact same path.
Otherwise - the exe files in the scripts folder might not work (IIRC they
are created when you install Python or the respective package and hardcode
the Python path so you can run them from any folder if they are in the
Windows Path).
You can avoid using the files in the Scripts folder, by calling the script
explicitly (so you are not dependent on any specific folder location or
folder in the path):
For example, for gdal_calc:
`c:\path_to_your_python\python -m osgeo_utils.gdal_calc <input>`
or for pip:
`c:\path_to_your_python\python -m pip install <input>`
Otherwise, if you still want to call the scripts without the full explicit
command then you should note that there were some changes in the wrappers
in gdal 3.5.
In gdal < 3.5 the scripts were thin python wrapper fils, which you could
create batch files for easier access for them:
https://github.com/OSGeo/gdal/blob/master/swig/python/gdal-utils/osgeo_utils/auxiliary/batch_creator.py
I gdal >= 3.5 those wrappers were replaced by thin exe wrappers (which I
think won't work if you change your python folder after installing them):
https://github.com/OSGeo/gdal/pull/5296
> I had also thought of the third option with the "stand alone app". I was
just not sure if all dependencies (e.g. numpy) are included.
I think that dependencies are handled, but again, I don't think that would
be helpful for your use case.
> I had already tried to install GDAL via „pip install GDAL“, but it
requires c++ build tools. Can't this be simplified?
Yes, it's complicated, you can see discussion here:
https://github.com/OSGeo/gdal/issues/4352
> Why are scripts like gdal_calc not included to the „standard“ package so
that they can be run similarly to gdalinfo?
gdal_calc was implemented only in Python (utilizing the power of
Python...).
gdalinfo was implemented in c++ (and with a Python clone for educational
purposes)
Kind regards,
Idan
On Sat, 7 Jan 2023 at 02:18, Carsten Lockenkötter <
carsten.lockenkoetter at web.de> wrote:
> Hi Idan,
>
>
>
> Yes, the operating system is Windows.
>
> You mean that I should zip the whole Python installation folder and copy
> it to the customer environment?
>
> Or just the Scripts folder?
>
> Sorry, I am a beginner in Python.
>
>
>
> I had also thought of the third option with the "stand alone app".
>
> I was just not sure if all dependencies (e.g. numpy) are included.
>
>
>
> I will try out the options soon, thank you.
>
> I had just hoped that there was an easier way.
>
> It's a pity that the path with Python is so difficult for beginners and
> that you may have to install it from an unofficial source.
>
> I had already tried to install GDAL via „pip install GDAL“, but it
> requires c++ build tools.
>
> Can't this be simplified?
>
>
>
> Why are scripts like gdal_calc not included to the „standard“ package so
> that they can be run similarly to gdalinfo?
>
> This would probably make everything a little easier.
>
>
>
> Regards,
>
> Carsten
>
>
>
> *Von:* Idan Miara <idan at miara.com>
> *Gesendet:* Freitag, 6. Januar 2023 21:15
> *An:* Carsten Lockenkötter <carsten.lockenkoetter at web.de>
> *Cc:* gdal-dev at lists.osgeo.org
> *Betreff:* Re: [gdal-dev] Using gdal_calc without python
>
>
>
> Hi!
>
>
>
> gdal_calc is implemented fully in python, so you would need python to run
> it.
>
>
>
> Assuming your client uses Windows and you don't have admin privileges to
> install software, you could install official Python and gdal (from
> https://www.lfd.uci.edu/~gohlke/pythonlibs/, which unfortunately is not
> maintained anymore) on another Windows machine and then just zip it and
> unzip on your clients' pc.
>
>
>
> Another option is using OSGeo4W (or QGIS).
>
> In the same way, you could also be able to install it, zip and unzip (I
> haven't tried this method recently)
>
>
>
> You might still need to install on your clients' pc Visual Studio
> Redistributables (which I think both Python and QGIS installers install for
> you automatically).
>
> I was successful with both methods, but I think that the first method is
> easier.
>
>
>
> Maybe also https://pyinstaller.org/en/stable/ could help if you needed to
> pack gdal_calc more like a "stand alone app", but I think that wasn't your
> issue.
>
>
>
> Kind regards,
>
> Idan
>
>
>
> On Fri, 6 Jan 2023 at 21:34, Carsten Lockenkötter <
> carsten.lockenkoetter at web.de> wrote:
>
> Hi,
>
>
>
> I'm currently building a workflow to crop possible white or black borders
> from my Geotiff files and create raster tiles with an alpha band.
>
> I'm using some Python functions provided by you, such as gdal_calc.py.
>
>
>
> My workflow works so far, but my problem is that I have to run everything
> on my customer's server.
>
> Unfortunately, I don't have the ability to install software there, so I
> can't install Python and gdal_calc.py can't be run.
>
>
>
> So far, I've always downloaded the compiled binaries from gisinternals.com
> and copied them to the server (the zip archive) to use gdalwarp, for
> example.
>
> But with that, I can't run gdal_calc, right? Python is still needed for
> that, or am I mistaken?
>
>
>
> Is there a way to use gdal_calc/gdal_retile without having to install
> software components?
>
> If there are approaches to control the functions through a wrapper, that
> would also help me.
>
> I have knowledge in C# and could use MaxRev.Gdal.Core, for example.
> However, I haven't found an approach yet to use gdal_calc.
>
> I probably have to rewrite the Python script in C#?
>
>
>
> Regards,
>
> Carsten
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20230108/650e8263/attachment.htm>
More information about the gdal-dev
mailing list