Comments (4)
I like this idea. Can't you change the dim
parameter though?
from api-docs.
@The-Penultimate-Defenestrator
Hey there, it's been quite awhile since I've used the API. From what I recall, the image files themselves are a set size (delivered straight from the satellite), so any stitching or compiled tiles would have to be an additional feature.
from api-docs.
There is a dim
argument, described as:
width and height of the image in degrees
And the default is 0.025
from api-docs.
My Python stitching code:
import urllib2
import json
import time
from io import BytesIO
from PIL import Image
URL="https://api.nasa.gov/planetary/earth/imagery?lon={}&lat={}&date={}&api_key={}"
API_KEY="ymjXp9qz2jJDR5tNEb0qa5YekynvAcVLJvKVcxYH"
def get_satellite_image(location=None,date=None):
if location is None:
location=(41.7475067,-74.0968971) #Coordinates of New Paltz
if date is None:
date=time.strftime("%Y-%m-%d")
lat,lon=location
req_url=URL.format(str(lon),str(lat),date,API_KEY)
req=json.loads(urllib2.urlopen(req_url).read())
image_url=req["url"]
print "Image at "+image_url
image = urllib2.urlopen(image_url)
b=BytesIO(image.read())
return b
def get_stitched_satellite_image(l=(41.7475067,-74.0968971),date=None):
d=0.025
coords = [l,#Original
(l[0]+d,l[1]),(l[0],l[1]+d),(l[0]-d,l[1]),(l[0],l[1]-d),#Horizontally adjacent
(l[0]+d,l[1]+d),(l[0]+d,l[1]-d),(l[0]-d,l[1]-d),(l[0]-d,l[1]+d)]#Diagonally adjacent
coords.sort()
image_files=[get_satellite_image(c,date) for c in coords]
images=[Image.open(i) for i in image_files]
imsize=512
canvas=Image.new('RGB',(imsize*3,imsize*3))
index=0
for y in range(2,-1,-1):
for x in range(3):
coords=(x*imsize,y*imsize)
canvas.paste(images[index],coords)
index+=1
return canvas
def save_satellite_image(location=None,date=None,filename='out.png'):
Image.open(get_satellite_image(location,date)).save(filename)
def save_stitched_satellite_image(location=(41.7475067,-74.0968971),date=None,filename='out.png'):
get_stitched_satellite_image(location,date).save(filename)
if __name__ == "__main__":
save_stitched_satellite_image((40.7,-74.0))
from api-docs.
Related Issues (20)
- 500 error, manifest quering
- https://images-api.nasa.gov chronological order
- Earth API: error 503 HOT 3
- APIs for Mars orbiting satellites HOT 1
- API Key in the open?
- Broken Link: Satellite Situation Center HOT 3
- APOD API 503 error HOT 6
- APOD 502 Bad Gateway HOT 1
- Making an API call even with the DEMO_KEY is returing 502 Bad Gateway HOT 1
- APOD endpoint returning 502 HOT 3
- APOD endpoint returns 504 HOT 5
- EONET API v3 get response is not valid json HOT 1
- HORIZONS api response in JSON format looks weird HOT 2
- Unable to create an API Key HOT 1
- Satellite Situation Center Links broken?
- Planetary Earth API Not Working HOT 4
- Typographical error on "earth"
- OVER_RATE_LIMIT across APIs and Keys HOT 2
- HTTP FAILED: java.net.UnknownHostException: Unable to resolve host "api.nasa.gov": No address associated with hostname HOT 1
- API for GCN circulars
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from api-docs.