Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Opening .tiff geoimages consumes enormous memory

Opening .tiff geoimages consumes enormous memory

Scheduled Pinned Locked Moved Solved General and Desktop
40 Posts 5 Posters 4.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Christian Ehrlicher
    29 Dec 2020, 11:07

    QtImagrReader is for sure not the correct way to handle geotiff. Either use openCV or better gdal for such tasks.

    J Offline
    J Offline
    john_hobbyist
    wrote on 30 Dec 2020, 15:35 last edited by
    #16

    @Christian-Ehrlicher

    I am trying GDAL in order to print the image:

    from osgeo import gdal
    import sys
    
    ds = gdal.Open('UAV_image.tif')
    print(ds)
    

    and I get this error:

    <osgeo.gdal.Dataset; proxy of <Swig Object of type 'GDALDatasetShadow *' at 0x7fb89062b840> >
    

    Any idea what I am missing here?

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 30 Dec 2020, 16:25 last edited by
      #17

      @john_hobbyist said in Opening .tiff geoimages consumes enormous memory:

      Any idea what I am missing here?

      Nothing. All is fine.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      2
      • J Offline
        J Offline
        john_hobbyist
        wrote on 30 Dec 2020, 16:27 last edited by
        #18

        Why I cannot see the image?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 30 Dec 2020, 16:29 last edited by
          #19

          The Python print function only print strings or a string representation of the object.

          Check if GDAL provides a widget or equivalent for that.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          2
          • J Offline
            J Offline
            john_hobbyist
            wrote on 30 Dec 2020, 16:46 last edited by john_hobbyist
            #20

            Ok, until now OpenCV requires ~24GB RAM, gdal does not work. Is there any QImageReader sample code to open the .tif? I am searching the google for this...nothing found.

            M C 2 Replies Last reply 30 Dec 2020, 17:03
            0
            • J john_hobbyist
              30 Dec 2020, 16:46

              Ok, until now OpenCV requires ~24GB RAM, gdal does not work. Is there any QImageReader sample code to open the .tif? I am searching the google for this...nothing found.

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 30 Dec 2020, 17:03 last edited by
              #21

              @john_hobbyist
              Hi
              in what way did GDAL not work ?

              Also, Mr @Christian-Ehrlicher made me realize that geotiff is a special tiff so
              even QImageReader can read an image in sections. it might not really do what you want.

              What do you need to do to this image ?

              1 Reply Last reply
              1
              • J john_hobbyist
                30 Dec 2020, 16:46

                Ok, until now OpenCV requires ~24GB RAM, gdal does not work. Is there any QImageReader sample code to open the .tif? I am searching the google for this...nothing found.

                C Offline
                C Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on 30 Dec 2020, 17:05 last edited by
                #22

                @john_hobbyist I wonder what you want to do with this image when you even don't know the basics of this format... it's a georeferenced image with multiple images and bands inside. It's not a simple picture at all.

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                1 Reply Last reply
                4
                • J Offline
                  J Offline
                  john_hobbyist
                  wrote on 30 Dec 2020, 17:15 last edited by john_hobbyist
                  #23

                  @mrjj and @Christian-Ehrlicher:

                  I want to open it and do some zooming with code I use. Also I want to read the coordinates from the image (I do not how, but I am searching it)

                  M 1 Reply Last reply 30 Dec 2020, 17:29
                  0
                  • J john_hobbyist
                    30 Dec 2020, 17:15

                    @mrjj and @Christian-Ehrlicher:

                    I want to open it and do some zooming with code I use. Also I want to read the coordinates from the image (I do not how, but I am searching it)

                    M Offline
                    M Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on 30 Dec 2020, 17:29 last edited by JKSH
                    #24

                    @john_hobbyist
                    Ok then QImageReader is not the way as it can't access any coordinates.

                    I think you gave up on GDAL too fast. It's whats people seem to use.

                    1 Reply Last reply
                    1
                    • J Offline
                      J Offline
                      john_hobbyist
                      wrote on 30 Dec 2020, 17:34 last edited by
                      #25

                      @mrjj: yes with

                      gdalinfo
                      

                      command on the terminal I get the information I want...
                      Is there any way to get these information from the terminal and feed it to my python code for further processing? In other words how do I read information posted in terminal and use it inside my python code?

                      Ok, I will try again gdal to open the .tif

                      M 1 Reply Last reply 30 Dec 2020, 17:45
                      0
                      • J john_hobbyist
                        30 Dec 2020, 17:34

                        @mrjj: yes with

                        gdalinfo
                        

                        command on the terminal I get the information I want...
                        Is there any way to get these information from the terminal and feed it to my python code for further processing? In other words how do I read information posted in terminal and use it inside my python code?

                        Ok, I will try again gdal to open the .tif

                        M Offline
                        M Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on 30 Dec 2020, 17:45 last edited by
                        #26

                        @john_hobbyist
                        Hi
                        well yes, you could call gdalinfo with QProcess
                        https://www.learnpyqt.com/tutorials/qprocess-external-programs/
                        read the section with "Getting data from the QProcess"

                        1 Reply Last reply
                        1
                        • J Offline
                          J Offline
                          john_hobbyist
                          wrote on 1 Jan 2021, 22:46 last edited by
                          #27

                          Hello,
                          Ok I read it.

                          What is wrong in this code, and I cannot run the command via python command:

                          import sys
                          import time
                          
                          def flush_then_wait():
                              sys.stdout.flush()
                              sys.stderr.flush()
                              time.sleep(0.5)
                          
                          sys.stdout.write('gdalinfo UAV_image.tif')
                          flush_then_wait()
                          

                          on the terminal I run gdalinfo UAV_image.tif and prints me the metadata of the .tif, but I cannot run it through the python script

                          M 1 Reply Last reply 2 Jan 2021, 00:06
                          0
                          • J john_hobbyist
                            1 Jan 2021, 22:46

                            Hello,
                            Ok I read it.

                            What is wrong in this code, and I cannot run the command via python command:

                            import sys
                            import time
                            
                            def flush_then_wait():
                                sys.stdout.flush()
                                sys.stderr.flush()
                                time.sleep(0.5)
                            
                            sys.stdout.write('gdalinfo UAV_image.tif')
                            flush_then_wait()
                            

                            on the terminal I run gdalinfo UAV_image.tif and prints me the metadata of the .tif, but I cannot run it through the python script

                            M Offline
                            M Offline
                            mrjj
                            Lifetime Qt Champion
                            wrote on 2 Jan 2021, 00:06 last edited by
                            #28

                            @john_hobbyist
                            hi
                            That code only prints the text to the console.
                            It does not try to run gdalinfo
                            The first part is just a test script to run that shows some output.

                            You want the part with
                            p = QProcess()
                            p.start("ffprobe", ['-show_format', '-show_streams', 'a.mp4.py'])

                            (replace the program and parameters)

                            also to read the result, you should also read the
                            "Getting data from the QProcess" part

                            You want to use the full Python program shown near teh end. it sets up reading from the process.

                            1 Reply Last reply
                            2
                            • J Offline
                              J Offline
                              john_hobbyist
                              wrote on 2 Jan 2021, 13:14 last edited by
                              #29

                              Ok, I understand the:

                              p = QProcess()
                              p.start("python", ["dummy_script.py"])
                              

                              but not

                              p.start("ffprobe", ['-show_format', '-show_streams', 'a.mp4.py'])
                              

                              I assume that I put "python" on "ffprobe" but what I put on '-show_format', '-show_streams' ??

                              Thanx

                              M 1 Reply Last reply 2 Jan 2021, 13:23
                              0
                              • J john_hobbyist
                                2 Jan 2021, 13:14

                                Ok, I understand the:

                                p = QProcess()
                                p.start("python", ["dummy_script.py"])
                                

                                but not

                                p.start("ffprobe", ['-show_format', '-show_streams', 'a.mp4.py'])
                                

                                I assume that I put "python" on "ffprobe" but what I put on '-show_format', '-show_streams' ??

                                Thanx

                                M Offline
                                M Offline
                                mrjj
                                Lifetime Qt Champion
                                wrote on 2 Jan 2021, 13:23 last edited by mrjj 1 Feb 2021, 13:23
                                #30

                                @john_hobbyist
                                Hi
                                The first one, starts the python app with the parameter of a script name

                                This one
                                p.start("ffprobe", ['-show_format', '-show_streams', 'a.mp4.py'])

                                calls the app ffprobe with 4 parameters.

                                So you would do

                                p.start("gdalinfo ", ['UAV_image.tif'])

                                you might need a full path to the UAV_image.tif instead of just the name.

                                1 Reply Last reply
                                2
                                • J Offline
                                  J Offline
                                  john_hobbyist
                                  wrote on 2 Jan 2021, 16:46 last edited by john_hobbyist 1 Feb 2021, 16:52
                                  #31

                                  I have been stuck around two weeks on this. Maybe I should ask what I am trying to do, in order to help me, if somebody can, on this specific question.

                                  So is there any sample code in QT so that I can open .tif files, show me the corner coordinates (I am trying to make it work with gdal)
                                  and when zoom (by establishing 4 points on the .tif) in to show me the updated new corner coordinates?

                                  I am trying this github code:
                                  https://github.com/kklmn/OrthoView/blob/master/OrthoView.py
                                  but I do not know how feasible it is

                                  M 1 Reply Last reply 2 Jan 2021, 18:00
                                  0
                                  • J john_hobbyist
                                    2 Jan 2021, 16:46

                                    I have been stuck around two weeks on this. Maybe I should ask what I am trying to do, in order to help me, if somebody can, on this specific question.

                                    So is there any sample code in QT so that I can open .tif files, show me the corner coordinates (I am trying to make it work with gdal)
                                    and when zoom (by establishing 4 points on the .tif) in to show me the updated new corner coordinates?

                                    I am trying this github code:
                                    https://github.com/kklmn/OrthoView/blob/master/OrthoView.py
                                    but I do not know how feasible it is

                                    M Offline
                                    M Offline
                                    mrjj
                                    Lifetime Qt Champion
                                    wrote on 2 Jan 2021, 18:00 last edited by mrjj 1 Feb 2021, 18:09
                                    #32

                                    @john_hobbyist
                                    Hi
                                    Well its not a trivial thing you want to do.
                                    If you mean some meta data from the geotiff with "corner coordinates" then no.
                                    Qt does not know the geotiff format and cannot read any META data from the file. (beside the actual tiff image)

                                    if you can get that info from gdalinfo commandline, its not a bad idea.

                                    Im not sure OrthoView.py will work for you as it seems to want to load all of the image and that seems to use
                                    an excessive amount of ram.

                                    Did you try something like
                                    http://tuiview.org/
                                    and see if that can even load the image ?

                                    J 1 Reply Last reply 2 Jan 2021, 18:05
                                    1
                                    • M mrjj
                                      2 Jan 2021, 18:00

                                      @john_hobbyist
                                      Hi
                                      Well its not a trivial thing you want to do.
                                      If you mean some meta data from the geotiff with "corner coordinates" then no.
                                      Qt does not know the geotiff format and cannot read any META data from the file. (beside the actual tiff image)

                                      if you can get that info from gdalinfo commandline, its not a bad idea.

                                      Im not sure OrthoView.py will work for you as it seems to want to load all of the image and that seems to use
                                      an excessive amount of ram.

                                      Did you try something like
                                      http://tuiview.org/
                                      and see if that can even load the image ?

                                      J Offline
                                      J Offline
                                      john_hobbyist
                                      wrote on 2 Jan 2021, 18:05 last edited by
                                      #33

                                      @mrjj said in Opening .tiff geoimages consumes enormous memory:

                                      @john_hobbyist
                                      Hi
                                      Well its not a trivial thing you want to do.
                                      If you mean some meta data from the geotiff with "corner coordinates" then no.
                                      Qt does not know the geotiff format and cannot read any data from the file.

                                      if you can get that info from gdalinfo commandline, its not a bad idea.

                                      Im not sure OrthoView.py will work for you as it seems to want to load all of the image and that seems to use
                                      an excessive amount of ram.

                                      Did you try something like
                                      http://tuiview.org/
                                      and see if that can even load the image ?

                                      Ok, I will take a look thank you! Can I add python code to the http://tuiview.org/ ?

                                      M 1 Reply Last reply 2 Jan 2021, 18:11
                                      0
                                      • C Offline
                                        C Offline
                                        Christian Ehrlicher
                                        Lifetime Qt Champion
                                        wrote on 2 Jan 2021, 18:06 last edited by
                                        #34

                                        @mrjj said in Opening .tiff geoimages consumes enormous memory:

                                        cannot read any data from the file.

                                        It can read the image, but only completely which is obvious no meaningful way for big images. Therefore you have to use special libraries like e.g. gdal. So either you want to use geotiffs and have to learn what a georeferenced image is and how a geotiff is internally structured or don't use them.

                                        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                                        Visit the Qt Academy at https://academy.qt.io/catalog

                                        1 Reply Last reply
                                        2
                                        • J john_hobbyist
                                          2 Jan 2021, 18:05

                                          @mrjj said in Opening .tiff geoimages consumes enormous memory:

                                          @john_hobbyist
                                          Hi
                                          Well its not a trivial thing you want to do.
                                          If you mean some meta data from the geotiff with "corner coordinates" then no.
                                          Qt does not know the geotiff format and cannot read any data from the file.

                                          if you can get that info from gdalinfo commandline, its not a bad idea.

                                          Im not sure OrthoView.py will work for you as it seems to want to load all of the image and that seems to use
                                          an excessive amount of ram.

                                          Did you try something like
                                          http://tuiview.org/
                                          and see if that can even load the image ?

                                          Ok, I will take a look thank you! Can I add python code to the http://tuiview.org/ ?

                                          M Offline
                                          M Offline
                                          mrjj
                                          Lifetime Qt Champion
                                          wrote on 2 Jan 2021, 18:11 last edited by
                                          #35

                                          Ok, I will take a look thank you! Can I add python code to the http://tuiview.org/ ?

                                          well its written in python witha bit of c code for the raster.
                                          But it was more to see if that could load such a huge image.

                                          1 Reply Last reply
                                          1

                                          25/40

                                          30 Dec 2020, 17:34

                                          • Login

                                          • Login or register to search.
                                          25 out of 40
                                          • First post
                                            25/40
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved