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

BadZipFile: File is not a zip file #83

Closed
sugizo opened this issue May 14, 2024 · 2 comments · Fixed by #94
Closed

BadZipFile: File is not a zip file #83

sugizo opened this issue May 14, 2024 · 2 comments · Fixed by #94
Labels
bug Something isn't working

Comments

@sugizo
Copy link

sugizo commented May 14, 2024

The bug

/usr/local/lib/python3.10/dist-packages/dem_stitcher/stitcher.py:138: UserWarning: We need to localize the tiles as a Geotiff. Saving to tmp_f08d402f-9a1f-4ccc-907c-c35741d781ab
  warn(f"We need to localize the tiles as a Geotiff. Saving to {str(tile_dir)}", category=UserWarning)
Downloading srtm_v3 tiles:   0%|          | 0/2 [00:00<?, ?it/s]
---------------------------------------------------------------------------
BadZipFile                                Traceback (most recent call last)
[<ipython-input-22-1ebc4ae49366>](https://localhost:8080/#) in <cell line: 26>()
     24 area_or_point = 'Point'
     25 
---> 26 X, p = stitch_dem(bounds_tif, 
     27                   dem_name = 'srtm_v3',  # srtm_v3, nasadem
     28                   dst_ellipsoidal_height = ellipsoidal_height,

14 frames
[/usr/lib/python3.10/zipfile.py](https://localhost:8080/#) in _RealGetContents(self)
   1334             raise BadZipFile("File is not a zip file")
   1335         if not endrec:
-> 1336             raise BadZipFile("File is not a zip file")
   1337         if self.debug > 1:
   1338             print(endrec)

BadZipFile: File is not a zip file

To Reproduce

from dem_stitcher import stitch_dem
from dem_stitcher.datasets import DATASETS
from geopy.geocoders import Nominatim

geolocator = Nominatim(user_agent = "Chrome")

location = geolocator.geocode('rome, italy')

latitude = location.latitude
longitude = location.longitude

factor_lat = 0.2
factor_lon = 0.2

min_lat = float("{:.1f}".format(latitude - factor_lat) )
max_lat = float("{:.1f}".format(latitude + factor_lat) )
min_lon = float("{:.1f}".format(longitude - factor_lon) )
max_lon = float("{:.1f}".format(longitude + factor_lon) )

# as xmin, ymin, xmax, ymax in epsg:4326
bounds_tif = [min_lon, min_lat, max_lon, max_lat]
ellipsoidal_height = False
area_or_point = 'Point'

X, p = stitch_dem(bounds_tif, 
                  dem_name = 'srtm_v3',  # srtm_v3, nasadem
                  dst_ellipsoidal_height = ellipsoidal_height,
                  dst_area_or_point = area_or_point)

Additional context

error only occurs when use dem_name :
srtm_v3
and
nasadem

best regards

@sugizo sugizo added the bug Something isn't working label May 14, 2024
@cmarshak
Copy link
Collaborator

Hi @sugizo - can you make sure that you have the correct credentials stored in your ~/.netrc?

machine urs.earthdata.nasa.gov
    login <username>
    password <password>

I have to make a PR that makes the error more human readable as this error is totally indecipherable - I am sorry about that.

@cmarshak
Copy link
Collaborator

There is a blurb in the readme but really needs better error handling.

https://github.com/ACCESS-Cloud-Based-InSAR/dem-stitcher?tab=readme-ov-file#credentials

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants