SpatioTemporal / STARE-Cookbooks

Examples of STARE usage
0 stars 0 forks source link

problems installing GDAL and also isues with some examples #4

Open mbauer288 opened 2 years ago

mbauer288 commented 2 years ago

I found a couple of probably out-of-date API examples/tests (search for ## NEEDS FIX?), but otherwise everything seems to work. I also was unable to install GDAL, but this is an issue with my version of Ubuntu.


OS : Ubuntu 22.04 LTS Codename : jammy Kernel : 5.15.0-41-generic Architecture: x86_64

CPU : Intel i7-9700K @ 3.60GHz x 8 cores GPU : NVIDIA GeForce RTX 2080 SUPER RAM : 32 GB DDR4-2666 MHz (2 x 16 GB) HD: : 2.5 TB Step 5: Install STARE-Cookbooks (https://github.com/SpatioTemporal/STARE-Cookbooks)

    # Problem can't install GDAL

    $ sudo add-apt-repository ppa:ubuntugis/ubuntugis-stable && sudo apt-get update

        PPA publishes dbgsym, you may need to include 'main/debug' component
        Repository: 'deb https://ppa.launchpadcontent.net/ubuntugis/ppa/ubuntu/ jammy main'
        Description:
        Official stable UbuntuGIS packages.

        More info: https://launchpad.net/~ubuntugis/+archive/ubuntu/ppa
        Adding repository.
        Press [ENTER] to continue or Ctrl-c to cancel.
        Adding deb entry to /etc/apt/sources.list.d/ubuntugis-ubuntu-ppa-jammy.list
        Adding disabled deb-src entry to /etc/apt/sources.list.d/ubuntugis-ubuntu-ppa-jammy.list
        Adding key to /etc/apt/trusted.gpg.d/ubuntugis-ubuntu-ppa.gpg with fingerprint 6B827C12C2D425E227EDCA75089EBE08314DF160
        Hit:1 http://us.archive.ubuntu.com/ubuntu jammy InRelease
        Get:2 http://us.archive.ubuntu.com/ubuntu jammy-updates InRelease [114 kB]
        Get:3 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB]
        Get:4 http://us.archive.ubuntu.com/ubuntu jammy-backports InRelease [99.8 kB]
        Get:5 http://us.archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages [477 kB]
        Get:6 http://security.ubuntu.com/ubuntu jammy-security/main i386 Packages [89.4 kB]        
        Get:7 http://security.ubuntu.com/ubuntu jammy-security/main amd64 Packages [240 kB]                                    
        Get:8 http://us.archive.ubuntu.com/ubuntu jammy-updates/main i386 Packages [262 kB]                                    
        Get:9 http://security.ubuntu.com/ubuntu jammy-security/main Translation-en [59.7 kB]                                   
        Get:10 http://security.ubuntu.com/ubuntu jammy-security/main amd64 DEP-11 Metadata [11.4 kB]                           
        Get:11 http://security.ubuntu.com/ubuntu jammy-security/main amd64 c-n-f Metadata [3,924 B]                            
        Get:12 http://security.ubuntu.com/ubuntu jammy-security/restricted amd64 Packages [210 kB]                             
        Get:13 http://us.archive.ubuntu.com/ubuntu jammy-updates/main Translation-en [115 kB]                                  
        Get:14 http://us.archive.ubuntu.com/ubuntu jammy-updates/main amd64 DEP-11 Metadata [91.5 kB]                          
        Get:15 http://security.ubuntu.com/ubuntu jammy-security/restricted Translation-en [31.6 kB]                            
        Get:16 http://security.ubuntu.com/ubuntu jammy-security/universe i386 Packages [46.5 kB]                               
        Get:17 http://us.archive.ubuntu.com/ubuntu jammy-updates/main DEP-11 48x48 Icons [26.2 kB]                             
        Get:18 http://us.archive.ubuntu.com/ubuntu jammy-updates/main DEP-11 64x64 Icons [38.2 kB]                             
        Get:19 http://us.archive.ubuntu.com/ubuntu jammy-updates/main amd64 c-n-f Metadata [7,056 B]                           
        Get:20 http://us.archive.ubuntu.com/ubuntu jammy-updates/restricted amd64 Packages [248 kB]                            
        Get:21 http://security.ubuntu.com/ubuntu jammy-security/universe amd64 Packages [97.6 kB]                              
        Get:22 http://security.ubuntu.com/ubuntu jammy-security/universe Translation-en [35.1 kB]                              
        Get:23 http://security.ubuntu.com/ubuntu jammy-security/universe amd64 DEP-11 Metadata [608 B]                         
        Get:24 http://security.ubuntu.com/ubuntu jammy-security/universe amd64 c-n-f Metadata [2,408 B]                        
        Get:25 http://us.archive.ubuntu.com/ubuntu jammy-updates/restricted Translation-en [38.3 kB]                           
        Get:26 http://us.archive.ubuntu.com/ubuntu jammy-updates/universe i386 Packages [103 kB]                               
        Get:27 http://us.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 Packages [196 kB]                              
        Get:28 http://us.archive.ubuntu.com/ubuntu jammy-updates/universe Translation-en [66.2 kB]                             
        Get:29 http://us.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 DEP-11 Metadata [120 kB]
        Get:30 http://us.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 c-n-f Metadata [4,404 B]
        Get:31 http://us.archive.ubuntu.com/ubuntu jammy-updates/multiverse amd64 DEP-11 Metadata [940 B]
        Get:32 http://us.archive.ubuntu.com/ubuntu jammy-backports/universe amd64 Packages [5,416 B]
        Get:33 http://us.archive.ubuntu.com/ubuntu jammy-backports/universe i386 Packages [3,844 B]
        Get:34 http://us.archive.ubuntu.com/ubuntu jammy-backports/universe Translation-en [8,248 B]
        Get:35 http://us.archive.ubuntu.com/ubuntu jammy-backports/universe amd64 DEP-11 Metadata [12.5 kB]
        Get:36 http://us.archive.ubuntu.com/ubuntu jammy-backports/universe amd64 c-n-f Metadata [236 B]   
        Ign:37 https://ppa.launchpadcontent.net/ubuntugis/ppa/ubuntu jammy InRelease  
        Err:38 https://ppa.launchpadcontent.net/ubuntugis/ppa/ubuntu jammy Release
          404  Not Found [IP: 185.125.190.52 443]
        Reading package lists... Done
        E: The repository 'https://ppa.launchpadcontent.net/ubuntugis/ppa/ubuntu jammy Release' does not have a Release file.
        N: Updating from such a repository can't be done securely, and is therefore disabled by default.
        N: See apt-secure(8) manpage for repository creation and user configuration details.
        Hit:1 http://us.archive.ubuntu.com/ubuntu jammy InRelease
        Hit:2 http://us.archive.ubuntu.com/ubuntu jammy-updates InRelease
        Hit:3 http://us.archive.ubuntu.com/ubuntu jammy-backports InRelease
        Hit:4 http://security.ubuntu.com/ubuntu jammy-security InRelease
        Ign:5 https://ppa.launchpadcontent.net/ubuntugis/ppa/ubuntu jammy InRelease
        Err:6 https://ppa.launchpadcontent.net/ubuntugis/ppa/ubuntu jammy Release
          404  Not Found [IP: 185.125.190.52 443]
        Reading package lists... Done
        E: The repository 'https://ppa.launchpadcontent.net/ubuntugis/ppa/ubuntu jammy Release' does not have a Release file.
        N: Updating from such a repository can't be done securely, and is therefore disabled by default.
        N: See apt-secure(8) manpage for repository creation and user configuration details.

    $ sudo apt-get update
    $ sudo apt-get install gdal-bin
        Reading package lists... Done
        Building dependency tree... Done
        Reading state information... Done
        The following additional packages will be installed:
          python3-gdal python3-numpy
        Suggested packages:
          libgdal-grass gfortran python-numpy-doc python3-dev python3-pytest
        The following NEW packages will be installed:
          gdal-bin python3-gdal python3-numpy
        0 upgraded, 3 newly installed, 0 to remove and 37 not upgraded.
        Need to get 4,378 kB of archives.
        After this operation, 24.9 MB of additional disk space will be used.
        Do you want to continue? [Y/n] y
        Get:1 http://us.archive.ubuntu.com/ubuntu jammy/main amd64 python3-numpy amd64 1:1.21.5-1build2 [3,464 kB]
        Get:2 http://us.archive.ubuntu.com/ubuntu jammy/universe amd64 python3-gdal amd64 3.4.1+dfsg-1build4 [673 kB]
        Get:3 http://us.archive.ubuntu.com/ubuntu jammy/universe amd64 gdal-bin amd64 3.4.1+dfsg-1build4 [241 kB]
        Fetched 4,378 kB in 1s (4,371 kB/s)
        Selecting previously unselected package python3-numpy.
        (Reading database ... 446870 files and directories currently installed.)
        Preparing to unpack .../python3-numpy_1%3a1.21.5-1build2_amd64.deb ...
        Unpacking python3-numpy (1:1.21.5-1build2) ...
        Selecting previously unselected package python3-gdal.
        Preparing to unpack .../python3-gdal_3.4.1+dfsg-1build4_amd64.deb ...
        Unpacking python3-gdal (3.4.1+dfsg-1build4) ...
        Selecting previously unselected package gdal-bin.
        Preparing to unpack .../gdal-bin_3.4.1+dfsg-1build4_amd64.deb ...
        Unpacking gdal-bin (3.4.1+dfsg-1build4) ...
        Setting up python3-numpy (1:1.21.5-1build2) ...
        Setting up python3-gdal (3.4.1+dfsg-1build4) ...
        Setting up gdal-bin (3.4.1+dfsg-1build4) ...
        Processing triggers for man-db (2.10.2-1) ...
    $ sudo apt-get install libgdal-dev
        Reading package lists... Done
        Building dependency tree... Done
        Reading state information... Done
        Some packages could not be installed. This may mean that you have
        requested an impossible situation or if you are using the unstable
        distribution that some required packages have not yet been created
        or been moved out of Incoming.
        The following information may help to resolve the situation:

        The following packages have unmet dependencies:
         libgdal-dev : Depends: libgdal30 (= 3.4.1+dfsg-1build4) but 3.4.3+dfsg-1~jammy0 is to be installed
                       Depends: libhdf4-alt-dev but it is not going to be installed
        E: Unable to correct problems, you have held broken packages.

    $ sudo apt -y install python-gdal
        Reading package lists... Done
        Building dependency tree... Done
        Reading state information... Done
        Package python-gdal is not available, but is referred to by another package.
        This may mean that the package is missing, has been obsoleted, or
        is only available from another source
        However the following packages replace it:
          gdal-bin

        E: Package 'python-gdal' has no installation candidate

Step 5a: Clone STARE-Cookbooks repo

    $ cd 
    $ gh repo clone SpatioTemporal/STARE-Cookbooks
    $ cd /home/mbauer/STARE-Cookbooks/contrib/jupyter

    $ export PYTHONPATH="${PYTHONPATH}:/home/mbauer/pystare/:/home/mbauer/pystareplotlib/:/home/mbauer/STARE-Cookbooks/contrib/jupyter/:"

    $ cd extras
    $ jupyter notebook
        00-HelloEarth.ipynb           ## NEEDS FIX?    
            This failed due to a problem with 

                r = requests.get(url,stream=True)
                print(f"\n{r = }")
                # r = <Response [406]> "406 Not Acceptable"
                print(f"\n{r.status_code = }")
                print(f"\n{r.headers = }")            
                # r.status_code = 406
                # r.headers = {'Date': 'Mon, 01 Aug 2022 20:09:40 GMT', 'Server': 'Apache', 'Content-Length': '226', 'Keep-Alive': 'timeout=5, max=75', 'Connection': 'Keep-Alive', 'Content-Type': 'text/html; charset=iso-8859-1'}

         So I manually downloaded them and restarted jupyter and it worked
            $ cd contrib/jupyter/extras
            $ mkdir tmp
            $ cd tmp
            $ wget https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/50m/raster/HYP_50M_SR_W.zip
            $ wget https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/50m/raster/NE1_50M_SR_W.zip
            $ wget https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/raster/HYP_HR_SR_OB_DR.zip
            $ wget https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/raster/NE1_HR_LC_SR_W_DR.zip           
            background_images_dir: 
               /home/mbauer/.pyenv/versions/3.10.5/envs/mystare/lib/python3.10/site-packages/cartopy/data/raster/natural_earth
            backed up: 
               /home/mbauer/.pyenv/versions/3.10.5/envs/mystare/lib/python3.10/site-packages/cartopy/data/raster/natural_earth/images.json.sav
            zipfiles stored to ./tmp/
            HYP_50M_SR_W.tif probably already installed. Skipping copy.
            HYP_HR_SR_OB_DR.tif probably already installed. Skipping copy.
            NE1_HR_LC_SR_W_DR.tif probably already installed. Skipping copy.

            Background images loaded:
              'ne_shaded'                         [resolution='low']:  50-natural-earth-1-downsampled.png
              'hypso_50m_sr_w'                    [resolution='low']:  HYP_50M_SR_W.tif
              'ne1_50m_sr_w'                      [resolution='low']:  NE1_50M_SR_W.tif
              'hypso_10m_sr_w_ob_dr'              [resolution='low']:  HYP_HR_SR_OB_DR.tif
              'ne1_10m_sr_w_dr'                   [resolution='low']:  NE1_HR_LC_SR_W_DR.tif

            Restart Python for Cartopy to find the new images.

        This made:
            /home/mbauer/.pyenv/versions/mystare/lib/python3.10/site-packages/cartopy/data/raster/natural_earth/
                50-natural-earth-1-downsampled.png
                HYP_50M_SR_W.tif
                images.json.sav
                NE1_50M_SR_W.tif
                NE1_HR_LC_SR_W_DR.tif 

    $ cd ..
    $ jupyter notebook
        00-HelloEarth.ipynb        
            Works
        01-GeoLocation.ipynb   
            Works    
        02-SpatialIntervals.ipynb 
            Works
        03-SpatialRange.ipynb         ## NEEDS FIX?    
            ----> 5 cover_MaunaLoa = ps.circular_cover_from(spatial_index_MaunaLoa,1*deg,finest_resolution)
                AttributeError: module 'pystare' has no attribute 'circular_cover_from'
        04-Contains.ipynb   
            Works    
        05-HullsAndGrids.ipynb  
            ---> 18     covers = covers + [ps.from_polygon(shapely.geometry.Polygon(lines[k]),resolution=cover_resolution
                 19                                        ,nonconvex=False)]
                AttributeError: module 'pystare' has no attribute 'from_polygon'
        06-SanJoaquin.ipynb         ## NEEDS FIX?  
            ---------------------------------------------------------------------------
            CPLE_OpenFailedError                      Traceback (most recent call last)
            File fiona/_shim.pyx:83, in fiona._shim.gdal_open_vector()

            File fiona/_err.pyx:291, in fiona._err.exc_wrap_pointer()

            CPLE_OpenFailedError: extras/san_joaquin_simple.gpkg: No such file or directory

            During handling of the above exception, another exception occurred:

            DriverError                               Traceback (most recent call last)
            Input In [4], in <cell line: 1>()
            ----> 1 gdf = geopandas.read_file('extras/san_joaquin_simple.gpkg')
        07-MODIS+Africa.ipynb         ## NEEDS FIX?  
            ----> 1 intersected = pystare.intersect(indices, indices, multiresolution=False)
                TypeError: intersect() got an unexpected keyword argument 'multiresolution'
        08-Pystareplotlib-1.ipynb         ## NEEDS FIX?
            ----> 7     sp = stare_prism(siv=siv
                --> 436     t_triple = pystare.to_JulianTAI(triple)
                    AttributeError: module 'pystare' has no attribute 'to_JulianTAI'           
mbauer288 commented 2 years ago

Of course GDAL became available a few days later... see below.

However, I still have problems with 06-SanJoaquin.ipynb. Specifically, it can't find the file san_joaquin_simple.gpkg.


Install GDAL Ubunut 20.04 LTS jammy

libgdal-dev on Ubuntu 22.04 LTS (Jammy Jellyfish) https://linux-packages.com/ubuntu-jammy-jellyfish/package/libgdal-dev Last updated: August 06,2022

1. Install libgdal-dev package
    $ sudo apt update
    $ sudo apt install libgdal-dev
2. Uninstall / Remove libgdal-dev package
    $ sudo apt remove libgdal-dev
    $ sudo apt autoclean && sudo apt autoremove

gdal-bin on Ubuntu 22.04 LTS (Jammy Jellyfish) https://linux-packages.com/ubuntu-jammy-jellyfish/package/gdal-bin Last updated: August 06,2022

1. Install gdal-bin package
    $ sudo apt update
    $ sudo apt install gdal-bin
2. Uninstall / Remove gdal-bin package
    $ sudo apt remove gdal-bin
    $ sudo apt autoclean && sudo apt autoremove

gdal-data on Ubuntu 22.04 LTS (Jammy Jellyfish) https://linux-packages.com/ubuntu-jammy-jellyfish/package/gdal-data Last updated: August 06,2022

1. Install gdal-data package:
    $ sudo apt update
    $ sudo apt install gdal-data 
2. Uninstall / Remove gdal-data package
    $ sudo apt remove gdal-data
    $ sudo apt autoclean && sudo apt autoremove

python3-gdal on Ubuntu 22.04 LTS (Jammy Jellyfish) https://linux-packages.com/ubuntu-jammy-jellyfish/package/python3-gdal Last updated: August 06,2022

1. Install python3-gdal package
    $ sudo apt update
    $ sudo apt install python3-gdal
2. Uninstall / Remove python3-gdal package
    $ sudo apt remove python3-gdal
    $ sudo apt autoclean && sudo apt autoremove