Spaces:
Sleeping
Sleeping
Download test_vsat.py from Assefore/forest-suitability: direct link, hf CLI and curl.
- Browser
- Download file 1.2 kB
-
https://huggingface.co/spaces/Assefore/forest-suitability/resolve/main/test_vsat.py
- Command line
-
hf download hf://spaces/Assefore/forest-suitability/test_vsat.py
-
curl -L -o test_vsat.py https://huggingface.co/spaces/Assefore/forest-suitability/resolve/main/test_vsat.py
1.2 kB
| import os | |
| import requests | |
| KEY = os.environ.get("VWORLD_KEY", "") # 환경변수로만 — repo에 키 노출 금지 | |
| # VWorld 위성 타일: /req/wmts/1.0.0/{KEY}/Satellite/{z}/{y}/{x}.jpeg | |
| # 여주 인근 한 지점이 들어가는 타일 (z=18 예시) | |
| z, x, y = 18, 224020, 101860 # 일단 임의값 — 아래서 좌표로 계산 | |
| import math | |
| def deg2tile(lat, lng, z): | |
| n = 2 ** z | |
| xt = int((lng + 180.0) / 360.0 * n) | |
| yt = int((1 - math.log(math.tan(math.radians(lat)) + 1/math.cos(math.radians(lat))) / math.pi) / 2 * n) | |
| return xt, yt | |
| lat, lng = 37.30, 127.63 | |
| z = 18 | |
| x, y = deg2tile(lat, lng, z) | |
| url = f"https://api.vworld.kr/req/wmts/1.0.0/{KEY}/Satellite/{z}/{y}/{x}.jpeg" | |
| r = requests.get(url, timeout=10) | |
| print("URL:", url) | |
| print("HTTP status:", r.status_code) | |
| print("Content-Type:", r.headers.get("Content-Type")) | |
| print("바이트 길이:", len(r.content)) | |
| # 이미지면 저장해서 눈으로 확인 | |
| if r.status_code == 200 and "image" in (r.headers.get("Content-Type") or ""): | |
| open("vsat_tile.jpeg", "wb").write(r.content) | |
| print("✅ 타일 저장: vsat_tile.jpeg (열어서 위성사진 맞는지 확인)") | |
| else: | |
| print("응답 일부:", r.text[:300]) |