Coder Social home page Coder Social logo

llgeek / satellite-aerial-image-retrieval Goto Github PK

View Code? Open in Web Editor NEW
52.0 4.0 21.0 7 KB

Satellite/Aerial Image Retrieval: using Bing maps tile system to automatically download aerial imagery (maximum resolution available) given a latitude, longitude bounding box.

Python 100.00%
retrieving-images satellite tilemap bing-map-tile

satellite-aerial-image-retrieval's Introduction

Satellite Aerial Image Retrieval


How to run the code:

Please make sure the following environment is configured:

  1. Python 3.5+
  2. urllib
  3. PIL

To run the script, simply input the following commands in Terminal:

python3 ProbeMapMatching.py lat1, lon1, lat2, lon2,

where (lat1, lon1) is the latitude and longitude of the upper-left coordinate, and (lat2, lon2) is the latitude and longitude of the lower-right coordinate.

In my code, my program tolerates arbitrary coordinates input, as long as the two coordinates are diagonal. My program will figure out to transform the input coordinates to the standardized one before processing.

The retrieved image will be stored in .\output folder. The name of the image will follow the 'aerialImage_{}.jpeg' ending with the retrieval level.

Some sample retrievals could be:

  1. Chicago Navy Pier:
python3 aerialImageRetrieval.py 41.893812 -87.615195 41.885108 -87.597778

  1. Chicago Cloud Gate:
python3 aerialImageRetrieval.py 41.882981 -87.623496 41.882397 -87.623076

  1. Greater Chicago Area:
python3 aerialImageRetrieval.py 41.968574 -87.752519 41.774917 -87.566837

  1. Eiffel Tower in Paris:
python3 aerialImageRetrieval.py 48.859261 2.293362 48.856953 2.296194

  1. The Palace Museum in China:
python3 aerialImageRetrieval.py 39.922856 116.391459 39.913278 116.402509


Source Files:

  1. tilesystem.py: This module implements a set of static methods used for Bing maps tile system. All the methods in sample C# code in https://msdn.microsoft.com/en-us/library/bb259689.aspx, have been implemented by my own understanding.
  2. aerialImageRetrieval.py: This module is used to retrieve satellite/aerial image. Given a bounding box, which is composed of left up corner coordinate (latitude, longitude) and right down corner coordinate (latitude, longitude). Return an aerial imagery (with maximum resolution available) downloaded from Bing map tile system. The aerial image will be strictly cropped based on the size of bounding box. Also, if the given bounding box is too large and with the maximum resolution available, the retrieval image could be too large. So I set a maximum image size (8192 * 8192 pixels), approximately 256MB, to filter too large images.

satellite-aerial-image-retrieval's People

Contributors

federicob avatar llgeek avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

satellite-aerial-image-retrieval's Issues

timeout

Hi!

i tried to use the script and got timeout:

raceback (most recent call last):
File "C:\Python\lib\urllib\request.py", line 1350, in do_open
h.request(req.get_method(), req.selector, req.data, headers,
File "C:\Python\lib\http\client.py", line 1255, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:\Python\lib\http\client.py", line 1301, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\Python\lib\http\client.py", line 1250, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Python\lib\http\client.py", line 1010, in _send_output
self.send(msg)
File "C:\Python\lib\http\client.py", line 950, in send
self.connect()
File "C:\Python\lib\http\client.py", line 921, in connect
self.sock = self._create_connection(
File "C:\Python\lib\socket.py", line 808, in create_connection
raise err
File "C:\Python\lib\socket.py", line 796, in create_connection
sock.connect(sa)
TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time,
or established connection failed because connected host has failed to respond

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "aerialImageRetrieval.py", line 223, in
main()
File "aerialImageRetrieval.py", line 216, in main
if imgretrieval.max_resolution_imagery_retrieval():
File "aerialImageRetrieval.py", line 129, in max_resolution_imagery_retrieval
retrieve_sucess, horizontal_image = self.horizontal_retrieval_and_stitch_image(tileX1, tileX2, tileY, levl)
File "aerialImageRetrieval.py", line 181, in horizontal_retrieval_and_stitch_image
image = self.download_image(quadkey)
File "aerialImageRetrieval.py", line 60, in download_image
with request.urlopen(BASEURL.format(quadkey)) as file:
File "C:\Python\lib\urllib\request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "C:\Python\lib\urllib\request.py", line 525, in open
response = self._open(req, data)
File "C:\Python\lib\urllib\request.py", line 542, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
File "C:\Python\lib\urllib\request.py", line 502, in _call_chain
result = func(*args)
File "C:\Python\lib\urllib\request.py", line 1379, in http_open
return self.do_open(http.client.HTTPConnection, req)
File "C:\Python\lib\urllib\request.py", line 1353, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [WinError 10060] A connection attempt failed because the connected party did not properly respond
after a period of time, or established connection failed because connected host has failed to respond>

Small issue

There's an extra multiplication with 360 in the calculation of y. If you compare to the original, this value is not there. It causes issues when reverting back: https://docs.microsoft.com/en-us/bingmaps/articles/bing-maps-tile-system

PS: Thanks for the code. It's great!
PPS: What kind of license is this code? Can I freely use it in my projects (i.e. MIT license or so?) Thanks...

y = 0.5 - 360 * TileSystem.clip(pixelY, 0, mapsize - 1) / mapsize

should be

y = 0.5 - TileSystem.clip(pixelY, 0, mapsize - 1) / mapsize

Are these errors wanted?

Current level 23 results an image exceeding the maximum image size (8192 * 8192), will SKIP
Current level 22 results an image exceeding the maximum image size (8192 * 8192), will SKIP
Cannot find tile image at level 21 for tile coordinate (538180, 779330)

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.