{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Discover Sentinel-1 pairs for pre-seismic and coseismic coherence change analysis" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "* Import the Python packages" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "%matplotlib inline\n", "\n", "import warnings\n", "warnings.filterwarnings(\"ignore\")\n", "import os\n", "import sys\n", "import glob\n", "\n", "import cioppy\n", "ciop = cioppy.Cioppy()\n", "\n", "import numpy as np\n", "import matplotlib\n", "import matplotlib.pyplot as plt\n", "import matplotlib.colors as colors\n", "\n", "from snappy import jpy\n", "from snappy import ProductIO\n", "from snappy import GPF\n", "from snappy import HashMap\n", "\n", "import gc\n", "\n", "from shapely.geometry import box\n", "from shapely.wkt import loads \n", "\n", "import py_earthquakes\n", "\n", "from datetime import datetime, timedelta\n", "import dateutil.parser\n", "\n", "import geopandas as gp\n", "\n", "import folium" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "* Use an earthquake" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": true }, "outputs": [], "source": [ "bbox=[21.944860, 36.940880,23.944860, 38.940880]\n", "\n", "min_mag = 4.1\n", "\n", "start_date = '2016-10-01'\n", "\n", "stop_date = '2016-11-30'" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": true }, "outputs": [], "source": [ "eq_search = py_earthquakes.EarthQuakes(start_date,\n", " stop_date,\n", " min_mag = min_mag,\n", " bbox=bbox)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "'M 4.2 - 1km SSW of Makrakomi, Greece'" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "eq_search.earthquakes[0].title" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "'us20007gi7'" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "eq_search.earthquakes[0].id" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "'2016-10-25T00:09:56.590000Z'" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "eq_search.earthquakes[0].date" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Create a buffer of 0.5 degrees" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "'POINT(22.1115 38.9244)'" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "eq_search.earthquakes[0].wkt" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": true }, "outputs": [], "source": [ "aoi_wkt = box(*loads(eq_search.earthquakes[0].wkt).buffer(0.5).bounds).wkt" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "'POLYGON ((22.6115 38.4244, 22.6115 39.4244, 21.6115 39.4244, 21.6115 38.4244, 22.6115 38.4244))'" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "aoi_wkt" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "* Search parameters" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Set the catalogue endpoint to Sentinel-1:" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "collapsed": true }, "outputs": [], "source": [ "series = 'https://catalog.terradue.com/sentinel1/search'" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Define the end of the time of interest:" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "collapsed": false }, "outputs": [], "source": [ "slave_search_stop_date = (dateutil.parser.parse(eq_search.earthquakes[0].date) + timedelta(days=6)).isoformat()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "* Build and submit the catalog search\n" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "collapsed": true }, "outputs": [], "source": [ "search_params = dict([('geom', aoi_wkt),\n", " ('start', eq_search.earthquakes[0].date),\n", " ('stop', slave_search_stop_date),\n", " ('pt', 'SLC')])" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "collapsed": false }, "outputs": [], "source": [ "slave_search = ciop.search(end_point = series,\n", " params = search_params,\n", " output_fields='self,productType,track,enclosure,identifier,wkt,startdate', \n", " model='EOP')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "* Put all slaves in a geodataframe and plot the Sentinel-1 slave candidates" ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "collapsed": true }, "outputs": [], "source": [ "aoi = loads(aoi_wkt)" ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "collapsed": false }, "outputs": [], "source": [ "result = []\n", "\n", "locations = []\n", "\n", "for index, elem in enumerate(slave_search):\n", " \n", " locations.append([t[::-1] for t in list(loads(elem['wkt']).exterior.coords)])\n", " \n", " slave_wkt = loads(elem['wkt'])\n", " \n", " result.append({'self' : elem['self'],\n", " 'identifier' : elem['identifier'],\n", " 'enclosure' : elem['enclosure'],\n", " 'date' : elem['startdate'],\n", " 'wkt': loads(elem['wkt']),\n", " 'aoi_intersec' : (slave_wkt.intersection(aoi).area/aoi.area) * 100,\n", " 'contains': slave_wkt.contains(aoi)\n", " })\n", " \n", "slaves = gp.GeoDataFrame(result)" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "lat = loads(eq_search.earthquakes[0].wkt).y\n", "lon = loads(eq_search.earthquakes[0].wkt).x\n", "\n", "zoom_start = 7\n", "\n", "m = folium.Map(location=[lat, lon], zoom_start=zoom_start)\n", "\n", "radius = 4\n", "folium.CircleMarker(\n", " location=[lat, lon],\n", " radius=radius,\n", " color='#FF0000',\n", " stroke=False,\n", " fill=True,\n", " fill_opacity=0.6,\n", " opacity=1,\n", " popup='{} pixels'.format(radius),\n", " tooltip='I am in pixels',\n", ").add_to(m)\n", "\n", "\n", "folium.PolyLine(\n", " locations=np.asarray([t[::-1] for t in list(loads(aoi_wkt).exterior.coords)]).tolist(),\n", " color='#FF0000',\n", " weight=2,\n", " tooltip='Japan flooding',\n", ").add_to(m)\n", "\n", "folium.PolyLine(\n", " locations=locations,\n", " color='orange',\n", " weight=1,\n", " opacity=1,\n", " smooth_factor=0,\n", ").add_to(m)\n", "\n", "m.save(os.path.join('results', '%s_search.html' % eq_search.earthquakes[0].id))\n", "\n", "m" ] }, { "cell_type": "code", "execution_count": 17, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
aoi_interseccontainsdateenclosureidentifierselfwkt
0100.000000True2016-10-30T16:31:41.3695830Zhttps://store.terradue.com/download/sentinel1/...S1A_IW_SLC__1SDV_20161030T163141_20161030T1632...https://catalog.terradue.com/sentinel1/search?...POLYGON ((19.736723 39.341087, 22.701288 39.74...
197.711574False2016-10-30T04:38:48.2069410Zhttps://store.terradue.com/download/sentinel1/...S1B_IW_SLC__1SDV_20161030T043848_20161030T0439...https://catalog.terradue.com/sentinel1/search?...POLYGON ((22.34882 37.795399, 19.450127 38.198...
25.551913False2016-10-30T04:38:22.4261540Zhttps://store.terradue.com/download/sentinel1/...S1B_IW_SLC__1SDV_20161030T043822_20161030T0438...https://catalog.terradue.com/sentinel1/search?...POLYGON ((22.728542 39.285812, 19.762106 39.68...
371.287095False2016-10-25T16:23:37.9832800Zhttps://store.terradue.com/download/sentinel1/...S1A_IW_SLC__1SDV_20161025T162337_20161025T1624...https://catalog.terradue.com/sentinel1/search?...POLYGON ((21.63916 39.960037, 24.634281 40.361...
45.062699False2016-10-25T16:23:13.1686030Zhttps://store.terradue.com/download/sentinel1/...S1A_IW_SLC__1SDV_20161025T162313_20161025T1623...https://catalog.terradue.com/sentinel1/search?...POLYGON ((22.016951 38.469093, 24.94478 38.871...
593.929883False2016-10-25T04:30:36.4692880Zhttps://store.terradue.com/download/sentinel1/...S1B_IW_SLC__1SDV_20161025T043036_20161025T0431...https://catalog.terradue.com/sentinel1/search?...POLYGON ((24.384764 37.672104, 21.492056 38.07...
\n", "
" ], "text/plain": [ " aoi_intersec contains date \\\n", "0 100.000000 True 2016-10-30T16:31:41.3695830Z \n", "1 97.711574 False 2016-10-30T04:38:48.2069410Z \n", "2 5.551913 False 2016-10-30T04:38:22.4261540Z \n", "3 71.287095 False 2016-10-25T16:23:37.9832800Z \n", "4 5.062699 False 2016-10-25T16:23:13.1686030Z \n", "5 93.929883 False 2016-10-25T04:30:36.4692880Z \n", "\n", " enclosure \\\n", "0 https://store.terradue.com/download/sentinel1/... \n", "1 https://store.terradue.com/download/sentinel1/... \n", "2 https://store.terradue.com/download/sentinel1/... \n", "3 https://store.terradue.com/download/sentinel1/... \n", "4 https://store.terradue.com/download/sentinel1/... \n", "5 https://store.terradue.com/download/sentinel1/... \n", "\n", " identifier \\\n", "0 S1A_IW_SLC__1SDV_20161030T163141_20161030T1632... \n", "1 S1B_IW_SLC__1SDV_20161030T043848_20161030T0439... \n", "2 S1B_IW_SLC__1SDV_20161030T043822_20161030T0438... \n", "3 S1A_IW_SLC__1SDV_20161025T162337_20161025T1624... \n", "4 S1A_IW_SLC__1SDV_20161025T162313_20161025T1623... \n", "5 S1B_IW_SLC__1SDV_20161025T043036_20161025T0431... \n", "\n", " self \\\n", "0 https://catalog.terradue.com/sentinel1/search?... \n", "1 https://catalog.terradue.com/sentinel1/search?... \n", "2 https://catalog.terradue.com/sentinel1/search?... \n", "3 https://catalog.terradue.com/sentinel1/search?... \n", "4 https://catalog.terradue.com/sentinel1/search?... \n", "5 https://catalog.terradue.com/sentinel1/search?... \n", "\n", " wkt \n", "0 POLYGON ((19.736723 39.341087, 22.701288 39.74... \n", "1 POLYGON ((22.34882 37.795399, 19.450127 38.198... \n", "2 POLYGON ((22.728542 39.285812, 19.762106 39.68... \n", "3 POLYGON ((21.63916 39.960037, 24.634281 40.361... \n", "4 POLYGON ((22.016951 38.469093, 24.94478 38.871... \n", "5 POLYGON ((24.384764 37.672104, 21.492056 38.07... " ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "slaves" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Select the slave that 'best' covers the AOI" ] }, { "cell_type": "code", "execution_count": 18, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "{'enclosure': 'https://store.terradue.com/download/sentinel1/files/v1/S1A_IW_SLC__1SDV_20161030T163141_20161030T163208_013722_01603F_4094',\n", " 'identifier': 'S1A_IW_SLC__1SDV_20161030T163141_20161030T163208_013722_01603F_4094',\n", " 'productType': 'SLC',\n", " 'self': 'https://catalog.terradue.com/sentinel1/search?format=atom&uid=S1A_IW_SLC__1SDV_20161030T163141_20161030T163208_013722_01603F_4094',\n", " 'startdate': '2016-10-30T16:31:41.3695830Z',\n", " 'track': '175',\n", " 'wkt': 'POLYGON((19.736723 39.341087,22.701288 39.742973,23.034481 38.123413,20.138891 37.720314,19.736723 39.341087))'}" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "slave = slave_search[slaves['aoi_intersec'].idxmax()]\n", "\n", "slave" ] }, { "cell_type": "code", "execution_count": 19, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "'2016-10-30T16:31:41.3695830Z'" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "slave['startdate']" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Search for the pre-event masters**" ] }, { "cell_type": "code", "execution_count": 20, "metadata": { "collapsed": true }, "outputs": [], "source": [ "master_search_start_date = (dateutil.parser.parse(slave['startdate']) + timedelta(days=-24)).isoformat()" ] }, { "cell_type": "code", "execution_count": 21, "metadata": { "collapsed": false }, "outputs": [], "source": [ "master_search_stop_date = (dateutil.parser.parse(slave['startdate']) + timedelta(days=-1)).isoformat()" ] }, { "cell_type": "code", "execution_count": 22, "metadata": { "collapsed": true }, "outputs": [], "source": [ "master_search_params = dict([('geom', slave['wkt']),\n", " ('track', slave['track']),\n", " ('pt',slave['productType']),\n", " ('start', master_search_start_date),\n", " ('stop', master_search_stop_date)])" ] }, { "cell_type": "code", "execution_count": 23, "metadata": { "collapsed": false }, "outputs": [], "source": [ "try:\n", " master_search = ciop.search(end_point=series, \n", " params=master_search_params,\n", " output_fields='identifier,enclosure,self,startdate,wkt',\n", " model='EOP')\n", "except IndexError:\n", " print('no masters')" ] }, { "cell_type": "code", "execution_count": 24, "metadata": { "collapsed": false }, "outputs": [], "source": [ "result = []\n", "\n", "for index, elem in enumerate(master_search):\n", " \n", " master_wkt = loads(elem['wkt'])\n", " \n", " result.append({'self' : elem['self'],\n", " 'identifier' : elem['identifier'],\n", " 'enclosure' : elem['enclosure'],\n", " 'wkt': loads(elem['wkt']),\n", " 'aoi_intersec' : (master_wkt.intersection(aoi).area/aoi.area) * 100,\n", " 'slave_intersec' : (master_wkt.intersection(loads(slave['wkt']))).area / loads(slave['wkt']).area * 100,\n", " 'contains': master_wkt.contains(aoi),\n", " 'days': (dateutil.parser.parse(slave['startdate']) - dateutil.parser.parse(elem['startdate'])).days\n", " })\n", " \n", "masters = gp.GeoDataFrame(result)" ] }, { "cell_type": "code", "execution_count": 25, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
aoi_interseccontainsdaysenclosureidentifierselfslave_intersecwkt
068.636837False6https://store.terradue.com/download/sentinel1/...S1B_IW_SLC__1SDV_20161024T163111_20161024T1631...https://catalog.terradue.com/sentinel1/search?...55.755995POLYGON ((19.520258 40.118217, 22.542038 40.52...
144.640286False6https://store.terradue.com/download/sentinel1/...S1B_IW_SLC__1SDV_20161024T163046_20161024T1631...https://catalog.terradue.com/sentinel1/search?...52.199313POLYGON ((19.906658 38.567837, 22.860817 38.97...
20.000000False11https://store.terradue.com/download/sentinel1/...S1A_IW_SLC__1SDV_20161018T163206_20161018T1632...https://catalog.terradue.com/sentinel1/search?...7.893120POLYGON ((19.368031 40.835575, 22.396507 41.23...
3100.000000True12https://store.terradue.com/download/sentinel1/...S1A_IW_SLC__1SDV_20161018T163141_20161018T1632...https://catalog.terradue.com/sentinel1/search?...99.881697POLYGON ((19.736567 39.342892, 22.70108 39.744...
40.000000False12https://store.terradue.com/download/sentinel1/...S1A_IW_SLC__1SDV_20161018T163116_20161018T1631...https://catalog.terradue.com/sentinel1/search?...7.974487POLYGON ((20.105968 37.850845, 23.007288 38.25...
50.000000False23https://store.terradue.com/download/sentinel1/...S1A_IW_SLC__1SDV_20161006T163206_20161006T1632...https://catalog.terradue.com/sentinel1/search?...7.933108POLYGON ((19.367752 40.834766, 22.396078 41.23...
6100.000000True24https://store.terradue.com/download/sentinel1/...S1A_IW_SLC__1SDV_20161006T163141_20161006T1632...https://catalog.terradue.com/sentinel1/search?...99.917743POLYGON ((19.736254 39.342201, 22.700668 39.74...
70.000000False24https://store.terradue.com/download/sentinel1/...S1A_IW_SLC__1SDV_20161006T163116_20161006T1631...https://catalog.terradue.com/sentinel1/search?...7.912009POLYGON ((20.105749 37.849777, 23.00696 38.252...
\n", "
" ], "text/plain": [ " aoi_intersec contains days \\\n", "0 68.636837 False 6 \n", "1 44.640286 False 6 \n", "2 0.000000 False 11 \n", "3 100.000000 True 12 \n", "4 0.000000 False 12 \n", "5 0.000000 False 23 \n", "6 100.000000 True 24 \n", "7 0.000000 False 24 \n", "\n", " enclosure \\\n", "0 https://store.terradue.com/download/sentinel1/... \n", "1 https://store.terradue.com/download/sentinel1/... \n", "2 https://store.terradue.com/download/sentinel1/... \n", "3 https://store.terradue.com/download/sentinel1/... \n", "4 https://store.terradue.com/download/sentinel1/... \n", "5 https://store.terradue.com/download/sentinel1/... \n", "6 https://store.terradue.com/download/sentinel1/... \n", "7 https://store.terradue.com/download/sentinel1/... \n", "\n", " identifier \\\n", "0 S1B_IW_SLC__1SDV_20161024T163111_20161024T1631... \n", "1 S1B_IW_SLC__1SDV_20161024T163046_20161024T1631... \n", "2 S1A_IW_SLC__1SDV_20161018T163206_20161018T1632... \n", "3 S1A_IW_SLC__1SDV_20161018T163141_20161018T1632... \n", "4 S1A_IW_SLC__1SDV_20161018T163116_20161018T1631... \n", "5 S1A_IW_SLC__1SDV_20161006T163206_20161006T1632... \n", "6 S1A_IW_SLC__1SDV_20161006T163141_20161006T1632... \n", "7 S1A_IW_SLC__1SDV_20161006T163116_20161006T1631... \n", "\n", " self slave_intersec \\\n", "0 https://catalog.terradue.com/sentinel1/search?... 55.755995 \n", "1 https://catalog.terradue.com/sentinel1/search?... 52.199313 \n", "2 https://catalog.terradue.com/sentinel1/search?... 7.893120 \n", "3 https://catalog.terradue.com/sentinel1/search?... 99.881697 \n", "4 https://catalog.terradue.com/sentinel1/search?... 7.974487 \n", "5 https://catalog.terradue.com/sentinel1/search?... 7.933108 \n", "6 https://catalog.terradue.com/sentinel1/search?... 99.917743 \n", "7 https://catalog.terradue.com/sentinel1/search?... 7.912009 \n", "\n", " wkt \n", "0 POLYGON ((19.520258 40.118217, 22.542038 40.52... \n", "1 POLYGON ((19.906658 38.567837, 22.860817 38.97... \n", "2 POLYGON ((19.368031 40.835575, 22.396507 41.23... \n", "3 POLYGON ((19.736567 39.342892, 22.70108 39.744... \n", "4 POLYGON ((20.105968 37.850845, 23.007288 38.25... \n", "5 POLYGON ((19.367752 40.834766, 22.396078 41.23... \n", "6 POLYGON ((19.736254 39.342201, 22.700668 39.74... \n", "7 POLYGON ((20.105749 37.849777, 23.00696 38.252... " ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "masters" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "* Select the two masters according to the ranking of AOI coverage and nearest cycles in time" ] }, { "cell_type": "code", "execution_count": 26, "metadata": { "collapsed": false }, "outputs": [], "source": [ "master_1 = master_search[masters.sort_values(['aoi_intersec', 'days'], ascending=[False, False]).iloc[1].name]\n", "master_2 = master_search[masters.sort_values(['aoi_intersec', 'days'], ascending=[False, False]).iloc[0].name]" ] }, { "cell_type": "code", "execution_count": 34, "metadata": { "collapsed": false }, "outputs": [], "source": [ "s1_identifiers = []\n", "s1_references = [] \n", "locations = []\n", "\n", "for product in [slave, master_1, master_2]:\n", " \n", " locations.append([t[::-1] for t in list(loads(product['wkt']).exterior.coords)])\n", " \n", " s1_identifiers.append(product['identifier'])\n", " s1_references.append(product['self'])\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Plot the Sentinel-1 products (slave, master 1 and master 2), the earthquake point and its area of interest" ] }, { "cell_type": "code", "execution_count": 35, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 35, "metadata": {}, "output_type": "execute_result" } ], "source": [ "lat = loads(eq_search.earthquakes[0].wkt).y\n", "lon = loads(eq_search.earthquakes[0].wkt).x\n", "\n", "zoom_start = 7\n", "\n", "m = folium.Map(location=[lat, lon], zoom_start=zoom_start)\n", "\n", "radius = 4\n", "folium.CircleMarker(\n", " location=[lat, lon],\n", " radius=radius,\n", " color='#FF0000',\n", " stroke=False,\n", " fill=True,\n", " fill_opacity=0.6,\n", " opacity=1,\n", " popup='{} pixels'.format(radius),\n", " tooltip='I am in pixels',\n", ").add_to(m)\n", "\n", "\n", "folium.PolyLine(\n", " locations=np.asarray([t[::-1] for t in list(loads(aoi_wkt).exterior.coords)]).tolist(),\n", " color='#FF0000',\n", " weight=2,\n", " tooltip='Japan flooding',\n", ").add_to(m)\n", "\n", "folium.PolyLine(\n", " locations=locations,\n", " color='orange',\n", " weight=1,\n", " opacity=1,\n", " smooth_factor=0,\n", ").add_to(m)\n", "\n", "m.save(os.path.join('results', '%s_final.html' % eq_search.earthquakes[0].id))\n", "\n", "m" ] }, { "cell_type": "code", "execution_count": 36, "metadata": { "collapsed": true }, "outputs": [ { "data": { "text/plain": [ "['https://catalog.terradue.com/sentinel1/search?format=atom&uid=S1A_IW_SLC__1SDV_20161030T163141_20161030T163208_013722_01603F_4094',\n", " 'https://catalog.terradue.com/sentinel1/search?format=atom&uid=S1A_IW_SLC__1SDV_20161018T163141_20161018T163208_013547_015AEB_5994',\n", " 'https://catalog.terradue.com/sentinel1/search?format=atom&uid=S1A_IW_SLC__1SDV_20161006T163141_20161006T163208_013372_01554F_F08D']" ] }, "execution_count": 36, "metadata": {}, "output_type": "execute_result" } ], "source": [ "s1_references" ] }, { "cell_type": "code", "execution_count": 37, "metadata": {}, "outputs": [], "source": [ "pair_coseismic = [s1_references[0], \n", " s1_references[1]]\n", "\n", "pair_preseismic = [s1_references[1], \n", " s1_references[2]]\n" ] }, { "cell_type": "code", "execution_count": 45, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "aoi_wkt = 'POLYGON ((22.6115 38.4244, 22.6115 39.4244, 21.6115 39.4244, 21.6115 38.4244, 22.6115 38.4244))'\n" ] } ], "source": [ "print ('aoi_wkt = \\'%s\\'' % aoi_wkt)" ] }, { "cell_type": "code", "execution_count": 40, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "pair_coseismic = ['https://catalog.terradue.com/sentinel1/search?format=atom&uid=S1A_IW_SLC__1SDV_20161030T163141_20161030T163208_013722_01603F_4094', 'https://catalog.terradue.com/sentinel1/search?format=atom&uid=S1A_IW_SLC__1SDV_20161018T163141_20161018T163208_013547_015AEB_5994']\n" ] } ], "source": [ "print ('pair_coseismic = %s' % pair_coseismic)" ] }, { "cell_type": "code", "execution_count": 41, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "pair_preseismic = ['https://catalog.terradue.com/sentinel1/search?format=atom&uid=S1A_IW_SLC__1SDV_20161018T163141_20161018T163208_013547_015AEB_5994', 'https://catalog.terradue.com/sentinel1/search?format=atom&uid=S1A_IW_SLC__1SDV_20161006T163141_20161006T163208_013372_01554F_F08D']\n" ] } ], "source": [ "print ('pair_preseismic = %s' % pair_preseismic)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.12" } }, "nbformat": 4, "nbformat_minor": 2 }