|
218 | 218 | "lat = \"47.1227347\"\n",
|
219 | 219 | "lon = \"8.1855324\"\n",
|
220 | 220 | "date = \"2020-05-01\"\n",
|
221 |
| - "api_key = \"4aGLgbow4rdiRJqOF12KuHOxERGdZcVZO7NaiomC\"\n", |
| 221 | + "api_key = \"\"\n", |
222 | 222 | "dim = \"0.1\"\n",
|
223 | 223 | "\n",
|
224 | 224 | "url = f\"https://api.nasa.gov/planetary/earth/imagery?lon={lon}&lat={lat}&date={date}&dim={dim}&api_key={api_key}\"\n",
|
|
229 | 229 | "base_uri": "https://localhost:8080/"
|
230 | 230 | },
|
231 | 231 | "id": "HIFFxI1vy90M",
|
232 |
| - "outputId": "d1080e99-fa90-4978-e971-779efc9f655f" |
| 232 | + "outputId": "fed560e5-1b49-4b98-d377-77b8d3d694c0" |
233 | 233 | },
|
234 |
| - "execution_count": 11, |
| 234 | + "execution_count": 51, |
235 | 235 | "outputs": [
|
236 | 236 | {
|
237 | 237 | "output_type": "stream",
|
238 | 238 | "name": "stdout",
|
239 | 239 | "text": [
|
240 |
| - "https://api.nasa.gov/planetary/earth/imagery?lon=8.1855324&lat=47.1227347&date=2020-05-01&dim=0.1&api_key=4aGLgbow4rdiRJqOF12KuHOxERGdZcVZO7NaiomC\n" |
| 240 | + "https://api.nasa.gov/planetary/earth/imagery?lon=8.1855324&lat=47.1227347&date=2020-05-01&dim=0.1&api_key=\n" |
241 | 241 | ]
|
242 | 242 | }
|
243 | 243 | ]
|
|
372 | 372 | "source": [
|
373 | 373 | "## Get images from specific locations\n",
|
374 | 374 | "\n",
|
375 |
| - "We are preparing a `locations.csv` file with a couple of location points (lat,long) seperated with a comma. Make sure you store a locations.csv file in your sample_data directory:" |
| 375 | + "We are preparing a `locations.csv` file with a couple of location points (lat,long) seperated with a comma. Make sure you store a locations.csv file in your sample_data directory. Downloading with `wget` directly into the google drive:" |
376 | 376 | ],
|
377 | 377 | "metadata": {
|
378 | 378 | "id": "Ji8VG22889Im"
|
|
381 | 381 | {
|
382 | 382 | "cell_type": "code",
|
383 | 383 | "source": [
|
384 |
| - "with (open(\"sample_data/locations.csv\") as f):\n", |
385 |
| - " locations = f.readlines()[1:]\n", |
386 |
| - "\n", |
387 |
| - "for location in locations[:5]: # read only first five entries\n", |
388 |
| - " place = location.strip().split(\",\")\n", |
389 |
| - " lat = place[2]\n", |
390 |
| - " lon = place[1]\n", |
391 |
| - " #print(f\"lat: {place[2]} lon: {place[1]} \")\n", |
392 |
| - " url = f\"https://api.nasa.gov/planetary/earth/imagery?lon={lon}&lat={lat}&date={date}&dim={dim}&api_key={api_key}\"\n", |
393 |
| - " print(url)" |
| 384 | + "!wget https://raw.githubusercontent.com/fleshgordo/scrapinghub/main/data/locations.csv -O sample_data/locations.csv " |
394 | 385 | ],
|
395 | 386 | "metadata": {
|
396 | 387 | "colab": {
|
397 | 388 | "base_uri": "https://localhost:8080/"
|
398 | 389 | },
|
399 |
| - "id": "o3ocl-Ro9WOG", |
400 |
| - "outputId": "c54d4338-6cdd-47f9-afba-007943d74f85" |
401 |
| - }, |
402 |
| - "execution_count": 42, |
403 |
| - "outputs": [ |
404 |
| - { |
405 |
| - "output_type": "stream", |
406 |
| - "name": "stdout", |
407 |
| - "text": [ |
408 |
| - "https://api.nasa.gov/planetary/earth/imagery?lon=87.82472222222222&lat=-70.17777777777778&date=2016-05-01&dim=0.1&api_key=4aGLgbow4rdiRJqOF12KuHOxERGdZcVZO7NaiomC\n", |
409 |
| - "https://api.nasa.gov/planetary/earth/imagery?lon=114.4525&lat=16.071666666666665&date=2016-05-01&dim=0.1&api_key=4aGLgbow4rdiRJqOF12KuHOxERGdZcVZO7NaiomC\n", |
410 |
| - "https://api.nasa.gov/planetary/earth/imagery?lon=81.22333333333333&lat=31.219166666666666&date=2016-05-01&dim=0.1&api_key=4aGLgbow4rdiRJqOF12KuHOxERGdZcVZO7NaiomC\n", |
411 |
| - "https://api.nasa.gov/planetary/earth/imagery?lon=77.35&lat=39.166666666666664&date=2016-05-01&dim=0.1&api_key=4aGLgbow4rdiRJqOF12KuHOxERGdZcVZO7NaiomC\n", |
412 |
| - "https://api.nasa.gov/planetary/earth/imagery?lon=81.27111111111111&lat=30.15583333333333&date=2016-05-01&dim=0.1&api_key=4aGLgbow4rdiRJqOF12KuHOxERGdZcVZO7NaiomC\n" |
413 |
| - ] |
414 |
| - } |
415 |
| - ] |
416 |
| - }, |
417 |
| - { |
418 |
| - "cell_type": "code", |
419 |
| - "source": [ |
420 |
| - "!wget https://raw.githubusercontent.com/fleshgordo/scrapinghub/main/data/locations.csv -O sample_data/locations.csv " |
421 |
| - ], |
422 |
| - "metadata": { |
423 | 390 | "id": "iyrR7XQ5-AjA",
|
424 |
| - "outputId": "fda0c70a-1552-4bee-c615-d48ac0236c36", |
425 |
| - "colab": { |
426 |
| - "base_uri": "https://localhost:8080/" |
427 |
| - } |
| 391 | + "outputId": "fda0c70a-1552-4bee-c615-d48ac0236c36" |
428 | 392 | },
|
429 | 393 | "execution_count": 25,
|
430 | 394 | "outputs": [
|
|
446 | 410 | ]
|
447 | 411 | }
|
448 | 412 | ]
|
| 413 | + }, |
| 414 | + { |
| 415 | + "cell_type": "code", |
| 416 | + "source": [ |
| 417 | + "with (open(\"sample_data/locations.csv\") as f):\n", |
| 418 | + " locations = f.readlines()[1:]\n", |
| 419 | + "\n", |
| 420 | + "date = \"2016-01-01\"\n", |
| 421 | + "for location in locations[:5]: # read only first five entries\n", |
| 422 | + " place = location.strip().split(\",\")\n", |
| 423 | + " lat = place[2]\n", |
| 424 | + " lon = place[1]\n", |
| 425 | + " #print(f\"lat: {place[2]} lon: {place[1]} \")\n", |
| 426 | + " url = f\"https://api.nasa.gov/planetary/earth/imagery?lon={lon}&lat={lat}&date={date}&dim={dim}&api_key={api_key}\"\n", |
| 427 | + " print(url)\n", |
| 428 | + " download = requests.get(url) # this will download the image file\n", |
| 429 | + " file = open(f\"sample_data/locations-{place[0]}.jpg\", \"wb\") # create a filehandler and give path\n", |
| 430 | + " file.write(download.content) # write image content to filename\n", |
| 431 | + " file.close() # close filehandler" |
| 432 | + ], |
| 433 | + "metadata": { |
| 434 | + "id": "o3ocl-Ro9WOG" |
| 435 | + }, |
| 436 | + "execution_count": null, |
| 437 | + "outputs": [] |
| 438 | + }, |
| 439 | + { |
| 440 | + "cell_type": "markdown", |
| 441 | + "source": [ |
| 442 | + "Try to replace the locations.csv file with coordinates that might be interesting for you to spot. Can you combine the dates and the locations into one big batch download?" |
| 443 | + ], |
| 444 | + "metadata": { |
| 445 | + "id": "mJspCWE1HEeG" |
| 446 | + } |
| 447 | + }, |
| 448 | + { |
| 449 | + "cell_type": "code", |
| 450 | + "source": [ |
| 451 | + "# experiment here" |
| 452 | + ], |
| 453 | + "metadata": { |
| 454 | + "id": "ItkoYVlcHQJg" |
| 455 | + }, |
| 456 | + "execution_count": null, |
| 457 | + "outputs": [] |
| 458 | + }, |
| 459 | + { |
| 460 | + "cell_type": "markdown", |
| 461 | + "source": [ |
| 462 | + "## Fetching satellite images with Google Maps API" |
| 463 | + ], |
| 464 | + "metadata": { |
| 465 | + "id": "G7BpldHgHRbO" |
| 466 | + } |
449 | 467 | }
|
450 | 468 | ],
|
451 | 469 | "metadata": {
|
|
0 commit comments