1

I have to read a large number of MrSID images and process them in Python. I usually access GIS file formats using the gdal application and the gdal Python library. However, the gdal package for Python does not come with MrSID support (I use the portable WinPython and the precompiled gdal package from here). Then I also use QGIS that comes with gdal support: here, gdal does support MrSID out of the box (command: gdalinfo.exe --formats).

I was wondering if there is a gdal package for Python that does support MrSID out of the box, or do I have to compile it from the source (using Windows 8.1 64-bit).

I tried to just copy the QGIS dll "...\gdalplugins\gdal_MrSID.dll" to the same folder in my Python gdal library, but this makes the command "gdalinfo.exe --formats" to stop with an error.

This is the code that I use in Python to see if gdal supports MrSID:

import gdal
gdal.AllRegister()
for i in range(1, gdal.GetDriverCount()):
 drv = gdal.GetDriver(i)
 print drv.GetDescription(),

Using this after implementing Kersten's solution, the list does not include the entry "MrSID". Calling the command "gdalinfo --formats" however, does list the entry "MrSID (rov): Multi-resolution Seamless Image Database (MrSID)".

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Sep 25, 2015 at 8:04
5
  • You should be able to copy the complete osgeo/gdal from your QGIS Python installation to your WinPython installation. Commented Sep 25, 2015 at 8:26
  • Thanks but I wish it was that simple. Are you familiar with a typical QGIS installation on Windows (company policy: I have to use the standalone installer, not the OSGeo4W network installer). I looked and osgeo/gdal related files seem to be spread out everywhere. But is this plain copy and paste approach the right thing to do anyway? How about versions and stuff (both Pythons are 2.7 though)? Commented Sep 25, 2015 at 8:51
  • In that case it is more complicated. I have a Osgeo4W QGIS installation and successfully ported gdal from the osgeo-python to my stand alone python. I'm sure that is not the best approach but it works. Commented Sep 25, 2015 at 10:49
  • Ok, thanks for sharing. I'll try it at home, where I have Osgeo4W as well. If it works there, your contribution will be marked the solution. Commented Sep 25, 2015 at 10:52
  • I think the better solution is to use the GDAL binaries from GISinternals (see my answer), unless you want to compile it from source. Commented Sep 25, 2015 at 11:01

2 Answers 2

1

Can't you call it with subprocess?

https://docs.python.org/2/library/subprocess.html

answered Sep 25, 2015 at 8:19
3
  • I have never used subprocess but just reading about it: don't you think this is a bit far-fetched? You want me to call the gdal-related commands from QGIS (with MrSID support) from within Python, right? Commented Sep 25, 2015 at 8:56
  • I think I've misread your question in the first place and what you mention was not what I meant. How you say it is definitely far-fetched but it could actually work. Commented Sep 25, 2015 at 9:03
  • Yeah, rereading my question, I understand your answer now. However, it is not what I am looking for, even though it should work. Just for clarity: I want to read + process the MrSID images from within Python using the Python gdal package in the most pythonic way possible. Commented Sep 25, 2015 at 9:15
1

Instead of using the binaries provided by Christopher Gohlke you can use the GDAL binaries from GISInternals:

For your case you would need:

answered Sep 25, 2015 at 10:51
4
  • Unfortunately, I have to unmark this the solution (for now). I installed these binaries, and gdal is available for my version of Python, however, MrSID is not a raster format available in Python. MrSID is listed in the output of "gdalinfo --formats", but not when executing the code that I have added to my original question. And I am using the same gdal installation in both cases. Any idea why gdal itself supports MrSID but gdal via the Python binding is not? Commented Sep 28, 2015 at 8:43
  • My issue with the binaries from GISInternals was never resolved, but I found a workaround to solve my problem. I create my images using MapServer and access them from Python using WMS. My installation of MapServer does support reading MrSID images. I leave this issue open to be resolved in the future. Commented Nov 11, 2015 at 22:19
  • Have you tried opening MrSID files from within Python? When I compare my driver lists there are also some inconsistencies - e.g. VRT is missing from the Python list. It is however no problem to open VRT from within the Python bindings. Commented Nov 12, 2015 at 10:33
  • Yes, I tried opening the MrSID files from within Python. I got the error that a 'sid' file is an unsupported format. I made my own comparison list. Here it is: formats supported by GDAL and not by Python binding: FITS, MrSID and VRT. And formats supported by Python binding but not by GDAL directly: OGDI. Commented Nov 12, 2015 at 20:38

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.