Git Product home page Git Product logo

srtm4's Introduction

SRTM4 (Shuttle Radar Topography Mission)

Download and parsing of SRTM4 elevation data.

PyPI version

Carlo de Franchis, Enric Meinhardt, Gabriele Facciolo, CMLA 2018

Installation and dependencies

The main source code repository for this project is https://github.com/centreborelli/srtm4. It is written in Python. It is tested with Python 3.7, 3.8, 3.9 and 3.10.

srtm4 requires libtiff development files. They can be installed with apt-get install libtiff-dev (Ubuntu, Debian) or brew install libtiff (macOS).

Once libtiff is installed, srtm4 can be installed with pip:

pip install srtm4

Usage

In a Python interpreter:

>>> import srtm4
>>> longitude, latitude = 2, 48
>>> altitude = srtm4.srtm4(longitude, latitude)
>>> print(altitude)  # should be 174.613 (altitude in meters above the WGS84 ellipsoid)

In a shell:

GEOID_PATH=data ./bin/srtm4 2 48

For the crop function, if pyproj complains about the download of file, you can fix it manually with the command:

pyproj sync -v --file us_nga_egm96_15

srtm4's People

Contributors

carlodef avatar gfacciol avatar glostis avatar kidanger avatar mnhrdt avatar rolandakiki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

srtm4's Issues

'tiffio.h' file not found on Mac

src/srtm4.c:9:10: fatal error: 'tiffio.h' file not found
#include <tiffio.h>
^~~~~~~~~~

I installed libtiff via homebrew: brew install libtiff, but I am getting this erroe when running pip install srtm4
Any suggestions?

pip install doesn't work on Ubuntu 18

Installing this package doesn't seem to work on Ubuntu 18, I think it has something to do with the libtiff package (I tried installing different versions of this package but it still did not work unfortunately).

Any idea if there is an easy fix for this?

 -ltiff -o bin/srtm4
    src/srtm4.c:9:10: fatal error: tiffio.h: No such file or directory
     #include <tiffio.h>
              ^~~~~~~~~~
    compilation terminated.
    Makefile:15: recipe for target 'bin/srtm4' failed

SSL Certificate issue

Trying to download a SRTM tile through this library gives the following error currently:

requests.exceptions.SSLError: HTTPSConnectionPool(host='srtm.csi.cgiar.org', port=443): Max retries exceeded with url: /wp-content/uploads/files/srtm_5x5/TIFF/srtm_21_05.zip (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1131)')))

When visiting https://srtm.csi.cgiar.org/ it looks like there is a problem with the SSL certificate that causes this. I tried setting verify=False here but that didn't solve the issue:

    r = session.get(from_url, stream=True, verify=False)

giving the following error:

ConnectionError: Response code 403 received for url https://srtm.csi.cgiar.org/wp-content/uploads/files/srtm_5x5/TIFF/srtm_37_03.zip

Which makes sense since the link to the SRTM tile seems to be broken: https://srtm.csi.cgiar.org/wp-content/uploads/files/srtm_5x5/TIFF/srtm_37_03.zip

Installation error on MacOS

PLEASE ADVISE

Collecting srtm4
Using cached srtm4-1.1.5.tar.gz (2.0 MB)
Preparing metadata (setup.py) ... done
Requirement already satisfied: filelock in ./opt/anaconda3/lib/python3.8/site-packages (from srtm4) (3.4.0)
Requirement already satisfied: numpy in ./opt/anaconda3/lib/python3.8/site-packages (from srtm4) (1.21.4)
Requirement already satisfied: requests in ./opt/anaconda3/lib/python3.8/site-packages (from srtm4) (2.26.0)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in ./opt/anaconda3/lib/python3.8/site-packages (from requests->srtm4) (1.26.7)
Requirement already satisfied: certifi>=2017.4.17 in ./opt/anaconda3/lib/python3.8/site-packages (from requests->srtm4) (2021.10.8)
Requirement already satisfied: idna<4,>=2.5 in ./opt/anaconda3/lib/python3.8/site-packages (from requests->srtm4) (3.1)
Requirement already satisfied: charset-normalizer~=2.0.0 in ./opt/anaconda3/lib/python3.8/site-packages (from requests->srtm4) (2.0.8)
Building wheels for collected packages: srtm4
Building wheel for srtm4 (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /Users/ghasem.abdi/opt/anaconda3/bin/python3.8 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/tg/3j7jy4jd3gs_69pk4m00c7sw0000gn/T/pip-install-h6i6i78q/srtm4_ba80b7fe0e044931b2a36f7990c443b5/setup.py'"'"'; file='"'"'/private/var/folders/tg/3j7jy4jd3gs_69pk4m00c7sw0000gn/T/pip-install-h6i6i78q/srtm4_ba80b7fe0e044931b2a36f7990c443b5/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/tg/3j7jy4jd3gs_69pk4m00c7sw0000gn/T/pip-wheel-7ht8x0fm
cwd: /private/var/folders/tg/3j7jy4jd3gs_69pk4m00c7sw0000gn/T/pip-install-h6i6i78q/srtm4_ba80b7fe0e044931b2a36f7990c443b5/
Complete output (54 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib
copying srtm4.py -> build/lib
running egg_info
writing srtm4.egg-info/PKG-INFO
writing dependency_links to srtm4.egg-info/dependency_links.txt
writing requirements to srtm4.egg-info/requires.txt
writing top-level names to srtm4.egg-info/top_level.txt
listing git files failed - pretending there aren't any
reading manifest file 'srtm4.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'requirements.txt'
writing manifest file 'srtm4.egg-info/SOURCES.txt'
mkdir -p bin
c++ -g -O3 -fpermissive -DNDEBUG -DDONT_USE_TEST_MAIN -c src/Geoid.cpp -o src/Geoid.o
c++ -g -O3 -fpermissive -DNDEBUG -DDONT_USE_TEST_MAIN -c src/geoid_height_wrapper.cpp -o src/geoid_height_wrapper.o
cc -std=c99 -g -O3 -DNDEBUG -DDONT_USE_TEST_MAIN -DMAIN_SRTM4 src/srtm4.c src/Geoid.o src/geoid_height_wrapper.o -lstdc++ -lz -lm -ltiff -o bin/srtm4
src/srtm4.c:9:10: fatal error: 'tiffio.h' file not found
#include <tiffio.h>
^~~~~~~~~~
1 error generated.
make: *** [bin/srtm4] Error 1
Traceback (most recent call last):
File "", line 1, in
File "/private/var/folders/tg/3j7jy4jd3gs_69pk4m00c7sw0000gn/T/pip-install-h6i6i78q/srtm4_ba80b7fe0e044931b2a36f7990c443b5/setup.py", line 39, in
setup(name="srtm4",
File "/Users/ghasem.abdi/opt/anaconda3/lib/python3.8/site-packages/setuptools/init.py", line 153, in setup
return distutils.core.setup(**attrs)
File "/Users/ghasem.abdi/opt/anaconda3/lib/python3.8/distutils/core.py", line 148, in setup
dist.run_commands()
File "/Users/ghasem.abdi/opt/anaconda3/lib/python3.8/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "/Users/ghasem.abdi/opt/anaconda3/lib/python3.8/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/Users/ghasem.abdi/opt/anaconda3/lib/python3.8/site-packages/wheel/bdist_wheel.py", line 299, in run
self.run_command('build')
File "/Users/ghasem.abdi/opt/anaconda3/lib/python3.8/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/Users/ghasem.abdi/opt/anaconda3/lib/python3.8/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/Users/ghasem.abdi/opt/anaconda3/lib/python3.8/distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/Users/ghasem.abdi/opt/anaconda3/lib/python3.8/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/Users/ghasem.abdi/opt/anaconda3/lib/python3.8/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/private/var/folders/tg/3j7jy4jd3gs_69pk4m00c7sw0000gn/T/pip-install-h6i6i78q/srtm4_ba80b7fe0e044931b2a36f7990c443b5/setup.py", line 28, in run
subprocess.check_call("make", shell=True)
File "/Users/ghasem.abdi/opt/anaconda3/lib/python3.8/subprocess.py", line 364, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command 'make' returned non-zero exit status 2.

ERROR: Failed building wheel for srtm4
Running setup.py clean for srtm4
Failed to build srtm4
Installing collected packages: srtm4
Running setup.py install for srtm4 ... error
ERROR: Command errored out with exit status 1:
command: /Users/ghasem.abdi/opt/anaconda3/bin/python3.8 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/tg/3j7jy4jd3gs_69pk4m00c7sw0000gn/T/pip-install-h6i6i78q/srtm4_ba80b7fe0e044931b2a36f7990c443b5/setup.py'"'"'; file='"'"'/private/var/folders/tg/3j7jy4jd3gs_69pk4m00c7sw0000gn/T/pip-install-h6i6i78q/srtm4_ba80b7fe0e044931b2a36f7990c443b5/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /private/var/folders/tg/3j7jy4jd3gs_69pk4m00c7sw0000gn/T/pip-record-0nvxixnl/install-record.txt --single-version-externally-managed --compile --install-headers /Users/ghasem.abdi/opt/anaconda3/include/python3.8/srtm4
cwd: /private/var/folders/tg/3j7jy4jd3gs_69pk4m00c7sw0000gn/T/pip-install-h6i6i78q/srtm4_ba80b7fe0e044931b2a36f7990c443b5/
Complete output (55 lines):
running install
/Users/ghasem.abdi/opt/anaconda3/lib/python3.8/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
running build
running build_py
creating build
creating build/lib
copying srtm4.py -> build/lib
running egg_info
writing srtm4.egg-info/PKG-INFO
writing dependency_links to srtm4.egg-info/dependency_links.txt
writing requirements to srtm4.egg-info/requires.txt
writing top-level names to srtm4.egg-info/top_level.txt
listing git files failed - pretending there aren't any
reading manifest file 'srtm4.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'requirements.txt'
writing manifest file 'srtm4.egg-info/SOURCES.txt'
cc -std=c99 -g -O3 -DNDEBUG -DDONT_USE_TEST_MAIN -DMAIN_SRTM4 src/srtm4.c src/Geoid.o src/geoid_height_wrapper.o -lstdc++ -lz -lm -ltiff -o bin/srtm4
src/srtm4.c:9:10: fatal error: 'tiffio.h' file not found
#include <tiffio.h>
^~~~~~~~~~
1 error generated.
make: *** [bin/srtm4] Error 1
Traceback (most recent call last):
File "", line 1, in
File "/private/var/folders/tg/3j7jy4jd3gs_69pk4m00c7sw0000gn/T/pip-install-h6i6i78q/srtm4_ba80b7fe0e044931b2a36f7990c443b5/setup.py", line 39, in
setup(name="srtm4",
File "/Users/ghasem.abdi/opt/anaconda3/lib/python3.8/site-packages/setuptools/init.py", line 153, in setup
return distutils.core.setup(**attrs)
File "/Users/ghasem.abdi/opt/anaconda3/lib/python3.8/distutils/core.py", line 148, in setup
dist.run_commands()
File "/Users/ghasem.abdi/opt/anaconda3/lib/python3.8/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "/Users/ghasem.abdi/opt/anaconda3/lib/python3.8/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/Users/ghasem.abdi/opt/anaconda3/lib/python3.8/site-packages/setuptools/command/install.py", line 68, in run
return orig.install.run(self)
File "/Users/ghasem.abdi/opt/anaconda3/lib/python3.8/distutils/command/install.py", line 545, in run
self.run_command('build')
File "/Users/ghasem.abdi/opt/anaconda3/lib/python3.8/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/Users/ghasem.abdi/opt/anaconda3/lib/python3.8/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/Users/ghasem.abdi/opt/anaconda3/lib/python3.8/distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/Users/ghasem.abdi/opt/anaconda3/lib/python3.8/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/Users/ghasem.abdi/opt/anaconda3/lib/python3.8/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/private/var/folders/tg/3j7jy4jd3gs_69pk4m00c7sw0000gn/T/pip-install-h6i6i78q/srtm4_ba80b7fe0e044931b2a36f7990c443b5/setup.py", line 28, in run
subprocess.check_call("make", shell=True)
File "/Users/ghasem.abdi/opt/anaconda3/lib/python3.8/subprocess.py", line 364, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command 'make' returned non-zero exit status 2.
----------------------------------------
ERROR: Command errored out with exit status 1: /Users/ghasem.abdi/opt/anaconda3/bin/python3.8 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/tg/3j7jy4jd3gs_69pk4m00c7sw0000gn/T/pip-install-h6i6i78q/srtm4_ba80b7fe0e044931b2a36f7990c443b5/setup.py'"'"'; file='"'"'/private/var/folders/tg/3j7jy4jd3gs_69pk4m00c7sw0000gn/T/pip-install-h6i6i78q/srtm4_ba80b7fe0e044931b2a36f7990c443b5/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /private/var/folders/tg/3j7jy4jd3gs_69pk4m00c7sw0000gn/T/pip-record-0nvxixnl/install-record.txt --single-version-externally-managed --compile --install-headers /Users/ghasem.abdi/opt/anaconda3/include/python3.8/srtm4 Check the logs for full command output.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.