Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to open 'SRTM_NE_250m.tif' ul[0]: unbound variable #50

Closed
Manodiestra opened this issue Oct 20, 2021 · 2 comments
Closed

unable to open 'SRTM_NE_250m.tif' ul[0]: unbound variable #50

Manodiestra opened this issue Oct 20, 2021 · 2 comments

Comments

@Manodiestra
Copy link

I am trying to run the docker image as specified in the documentation. The docker create-dataset.sh script works fine and downloads the tif files. It runs into issues when it tries to run the create-tiles.sh script. I get the error below.

ERROR 4: SRTM_NE_250m.tif: No such file or directory
gdalinfo failed - unable to open 'SRTM_NE_250m.tif'.
ERROR 4: SRTM_NE_250m.tif: No such file or directory
gdalinfo failed - unable to open 'SRTM_NE_250m.tif'.
../create-tiles.sh: line 13: ul[0]: unbound variable

I am almost certain this issue is because the download and use of the unar command results in three folders that contain the .tif files.
The files have a path like this. SRTM_NE_250m_TIF/SRTM_NE_250m.tif
But the script expects a path like this ./SRTM_NE_250m.tif
Which results in the unbound variable error seen above.

On Unix based systems, I believe the following code would fix the issue.

# Move tif files out of their folders
mv SRTM_NE_250m_TIF/SRTM_NE_250m.tif . && \
mv SRTM_SE_250m_TIF/SRTM_SE_250m.tif . && \
mv SRTM_W_250m_TIF/SRTM_W_250m.tif .
# Delete the folders that used to contain them
rm -r SRTM_NE_250m_TIF SRTM_SE_250m_TIF SRTM_W_250m_TIF

I'm running Ubuntu 20.04
Docker version 20.10.7, build 20.10.7-0ubuntu1~20.04.2

To reproduce this issue run the following commands (Exactly as specified in the documentation)

mkdir data # Create the target folder for the dataset
docker run -t -i -v $(pwd)/data:/code/data openelevation/open-elevation /code/create-dataset.sh
@kovar-ursa
Copy link

kovar-ursa commented Nov 1, 2021

I am running into the same problem on OSX (Unix based.)

Where would your suggested code be inserted?

I manually performed the proposed changes and then ran:

docker run -t -i -v $(pwd)/data:/code/data openelevation/open-elevation /code/create-tiles.sh SRTM_NE_250m.TIF 10 10

And it produced the same error.

I changed the file extension from .tif to .TIF and then ran:

docker run -t -i -v $(pwd)/data:/code/data openelevation/open-elevation /code/create-tiles.sh data/SRTM_NE_250m.TIF 10 10

and it worked.

So, two problems I think. 1) File is in a subdirectory and 2) file has a lowercase extension.

@Manodiestra
Copy link
Author

Thanks for the followup question. I put the code in create-dataset.sh right after download-srtm-data.sh is called.

The code I suggested might also not be targeting the correct directory for running within the docker image. It may need to be targeting ../ like so:

# Move tif files out of their folders
mv ../SRTM_NE_250m_TIF/SRTM_NE_250m.tif ../ && \
mv ../SRTM_SE_250m_TIF/SRTM_SE_250m.tif ../ && \
mv ../SRTM_W_250m_TIF/SRTM_W_250m.tif ../
# Delete the folders that used to contain them
rm -r ../SRTM_NE_250m_TIF ../SRTM_SE_250m_TIF ../SRTM_W_250m_TIF

So this would be the entire create-dataset.sh file:

#!/usr/bin/env bash

OUTDIR="/code/data"
if [ ! -e $OUTDIR ] ; then
    echo $OUTDIR does not exist!
fi

CUR_DIR=$(pwd)

set -eu

cd $OUTDIR
../download-srtm-data.sh

# Move tif files out of their folders
mv ../SRTM_NE_250m_TIF/SRTM_NE_250m.tif ../ && \
mv ../SRTM_SE_250m_TIF/SRTM_SE_250m.tif ../ && \
mv ../SRTM_W_250m_TIF/SRTM_W_250m.tif ../
# Delete the folders that used to contain them
rm -r ../SRTM_NE_250m_TIF ../SRTM_SE_250m_TIF ../SRTM_W_250m_TIF

../create-tiles.sh SRTM_NE_250m.tif 10 10
../create-tiles.sh SRTM_SE_250m.tif 10 10
../create-tiles.sh SRTM_W_250m.tif 10 20
rm -rf SRTM_NE_250m.tif SRTM_SE_250m.tif SRTM_W_250m.tif *.rar

cd $CUR_DIR

@kovar-ursa As for why you needed upper case .TIF instead of lower case .tif, I'm not sure. Is it possible that when you ran mv you specified the name of the file in the destination? The mv command will move the file, but it can also rename it. For example, SRTM_NE_250m_TIF/SRTM_NE_250m.tif ./SRMT_NE_250m.TIF would move the file out of the folder, and rename it with an upper case extension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants