|
1 | 1 |
|
2 | 2 | <img src="figs/s1.gif" width="750" align="center"> |
3 | 3 |
|
4 | | -[](https://zenodo.org/badge/latestdoi/259046250) |
5 | 4 | [](https://coveralls.io/github/aalling93/Sentinel_1_python) |
6 | 5 |  |
7 | 6 | [](https://snyk.io/test/github/aalling93/Sentinel_1_python/) |
8 | 7 |  |
9 | 8 |
|
10 | 9 |
|
| 10 | +Kristian Aalling Sørensen |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | +# Brief Description |
| 15 | +<a class="anchor" id="intro"></a> |
11 | 16 |
|
12 | | -## Introduction <a class="anchor" id="intro"></a> |
13 | 17 |
|
14 | 18 | This is a Python module for working with Sentinel-1 satellite images, purly in Python. It allows you to find the images you want, download them and work with them (calibrate, speckle fitler etc.).. I use the SentinelSAT package for the metadata. The data is then downloaded from NASA ASF. |
15 | 19 |
|
16 | 20 |
|
17 | 21 |
|
18 | 22 |
|
19 | 23 |
|
20 | | -## Content <a class="anchor" id="content"></a> |
21 | | -* [Download Sentinel-1 images with Python](#dwl) |
22 | 24 |
|
| 25 | + |
| 26 | +# Table Of Contents |
| 27 | +<a class="anchor" id="content"></a> |
| 28 | + |
| 29 | +- [Introduction](#Introduction) |
| 30 | +- [Requirements](#Requirements) |
| 31 | +- [Install and Run](#Install-and-Run) |
23 | 32 | * [Use Sentinel-1 images in Python](#use) |
24 | | - * [Load Sentinel-1 GRD](#grd) |
| 33 | +* [SAR, briefly](#sar) |
| 34 | +- [Acknowledgments](#Acknowledgments) |
25 | 35 |
|
26 | | - * [Decode Sentinel-1 level-0](#decode) |
27 | | - * [Calibrate Sentinel-1 GRD](#calibrate) |
28 | 36 |
|
29 | 37 |
|
30 | | -* [SAR, briefly](#sar) |
| 38 | +# Requirements |
| 39 | + <a class="anchor" id="Requirements"></a> |
31 | 40 |
|
| 41 | +- [numpy](https://github.com/numpy) |
| 42 | +- [geopandas](https://github.com/geopandas) |
| 43 | +- [gdal](https://github.com/geopandas) |
| 44 | +- [mgrs](https://github.com/mgrs) (should be removed in later version.. sry..) |
| 45 | +- [scikit-learn](https://github.com/scikit-learn) (should be removed in later version.. sry..) |
| 46 | +- [scipy](https://github.com/scipy) (should be removed in later version.. sry..) |
| 47 | +- [cartopy](https://github.com/cartopy) |
| 48 | +- [rasterio](https://github.com/rasterio) |
| 49 | +- [Pillow](https://github.com/Pillow) |
| 50 | +- [pandas](https://github.com/pandas) |
| 51 | +- [sentinelsat](https://github.com/sentinelsat) |
| 52 | +- [matplotlib](https://github.com/matplotlib) |
32 | 53 |
|
33 | | -## Download Sentinel-1 images with Python <a class="anchor" id="dwl"></a> |
34 | | -The sentinel_download module can be used to find the images you need and subsequently to download them. |
35 | | -```python |
36 | | -#decide area, time, and level |
37 | | -# filter the data, e.g., only iw, vv, etc etc. |
38 | | -met.iw() |
39 | | -# Check the images before downloading |
40 | | -met.show_cross_pol() |
41 | | -``` |
42 | | -<img src="figs/slc_thumn.png" width="750" align="center"> |
43 | 54 |
|
| 55 | +# Install and Run |
| 56 | + <a class="anchor" id="Install-and-Run"></a> |
| 57 | + |
| 58 | +This repo can be installed using either git clone OR pypi.. Currently, I have only placed in pypi-test, so lets hope it stays there.. |
| 59 | + |
| 60 | + |
| 61 | +**Using Pypi** |
| 62 | + |
| 63 | + 1. GDAL. Make sure your gdal bindings are working... |
| 64 | + |
| 65 | + 2. Install sentinel_1_python using pypy test |
| 66 | + ``` |
| 67 | +python3 -m pip install sentinel-1-python --extra-index-url=https://test.pypi.org/simple/ |
| 68 | + ``` |
| 69 | + |
| 70 | + |
| 71 | +**Using clone** |
| 72 | + |
| 73 | + 1. Install all requirments |
| 74 | + |
| 75 | + 2. Clone |
| 76 | + ``` |
| 77 | + git clone https://github.com/aalling93/sentinel_1_python.git |
| 78 | +
|
| 79 | + ``` |
44 | 80 |
|
45 | | -We can now download the images we want, for instance the third and fourth |
46 | | -```python |
47 | | -with Satellite_download(met.products_df[2:3]) as dwl: |
48 | 81 |
|
49 | | -``` |
50 | 82 |
|
51 | | -And voila. You have now downloaded the images. |
52 | 83 |
|
53 | 84 |
|
54 | 85 | ## Use Sentinel-1 images in Python <a class="anchor" id="use"></a> |
55 | 86 | Go back to [Table of Content](#content) |
56 | 87 |
|
| 88 | +1. Get metadata of images |
| 89 | +------------ |
57 | 90 |
|
58 | | -### Load Sentinel-1 level-0 in python<a class="anchor" id="level0"></a> |
| 91 | +```python |
| 92 | +with Sentinel_metadata() as met: |
| 93 | + met.area([29.9,21,56.7,58]) |
| 94 | + met.get_metadata(sensor='s1_slc',start_data='20220109',end_date='20221010') |
| 95 | +``` |
| 96 | + |
| 97 | +2. Filter the images if you want |
| 98 | +---------------- |
| 99 | +```python |
| 100 | +met.iw() #filer so we only have IW |
| 101 | +``` |
| 102 | + |
| 103 | + |
| 104 | +3. Displaying the images before download: |
| 105 | +```python |
| 106 | +met.plot_image_areas() # Showing extent of images |
| 107 | +met.show_cross_pol(4) |
| 108 | +``` |
| 109 | +We can then see then extent of the images. |
| 110 | + |
| 111 | +<img src="figs/extent.png" width="450" align="center"> |
| 112 | + |
| 113 | +And display the images before downloading them... |
| 114 | +<img src="figs/slc_thumn.png" width="450" align="center"> |
| 115 | + |
| 116 | +4. Download the images |
| 117 | +-------------- |
| 118 | +```python |
| 119 | +folder = f'{os.getenv("raw_data_dir")}/slc_sweden' |
| 120 | +with Satellite_download(met.products_df) as dwl: |
| 121 | + os.makedirs(folder, exist_ok=True) |
| 122 | + #save metadata |
| 123 | + dwl.products_df.to_pickle(f'{folder}/slc_dataframe.pkl') |
| 124 | + #download the thumbnails |
| 125 | + dwl.download_thumbnails(folder=f'{folder}/slc_thumbnails') |
| 126 | + #download the slc images in .zip format and extract to .SAFE format.. |
| 127 | + dwl.download_sentinel_1(f'{folder}/slc') |
| 128 | +``` |
59 | 129 |
|
60 | | -### Load Sentinel-1 SLC <a class="anchor" id="slc"></a> |
61 | 130 |
|
62 | | -### Sentinel-1 GRD <a class="anchor" id="grd"></a> |
| 131 | +5. Load, calibrate, speckle filter image in python |
63 | 132 |
|
64 | | -### Sentinel-1 calibrate <a class="anchor" id="calibrate"></a> |
| 133 | +```python |
| 134 | +image_paths = glob.glob(f'{os.getenv("raw_data_dir")}/*/*/*.SAFE') |
| 135 | +img = s1_load(image_paths[0]) |
| 136 | +img =img.calibrate(mode='gamma') # could also use, e.g., 'sigma_0' |
| 137 | +img = img.boxcar(5) #could easily make, e.g., a Lee filter.. |
| 138 | +img.simple_plot(band_index=0) |
| 139 | +``` |
| 140 | + |
| 141 | +we can now exctract a region of the image, defined by either index or coordinate set. |
| 142 | +```python |
| 143 | +indx = img.get_index(lat=57.0047,long=19.399) |
| 144 | +img[indx[0]-125:indx[0]+125,indx[1]-125:indx[1]+125].simple_plot(band_index=1) |
| 145 | +``` |
65 | 146 |
|
66 | | -### Decode Sentinel-1 level-0 <a class="anchor" id="decode"></a> |
67 | 147 |
|
| 148 | +------------ |
68 | 149 |
|
| 150 | +<img src="figs/calibrate.png" width="450" align="center"> |
69 | 151 |
|
70 | 152 | ## SAR satellites <a class="anchor" id="sar"></a> |
71 | 153 | Go back to [Table of Content](#content) |
@@ -111,4 +193,22 @@ Double bounce scattering and occurs when the transmitted pulse is reflected spec |
111 | 193 |
|
112 | 194 | Due to the geometry of the SAR and its moving platform, typical SAR imaging sensors are designed to take focused images with good resolution under the assumption that their target is stationary during image acquisition. This focusing can not be made on moving targets, and normal SAR instruments are therefore ill suited to detect fast moving objects, such as ships. The results is a well resolved static background and poorly resolved moving target. In non-cooperative surveillance tasks, this is a significant problem. Under the assumption that a target is moving perpendicular to the line of sight of the SAR with a constant acceleration, it is possible to reduce the problem by taking the doppler shift of the SAR images into consideration. Maritime vessels do not normally follow such patterns. Hence, more complex trajectory patterns must be accounted for when looking at ships with SAR instruments. |
113 | 195 |
|
114 | | -In summary, using the capabilities of a SAR instrument, it should be possible to detect ships on the ocean surface. |
| 196 | +In summary, using the capabilities of a SAR instrument, it should be possible to detect ships on the ocean surface. |
| 197 | + |
| 198 | + |
| 199 | + |
| 200 | + |
| 201 | +# Acknowledgments |
| 202 | + <a class="anchor" id="Acknowledgments"></a> |
| 203 | +Myself, |
| 204 | +Simon Lupemba, |
| 205 | +Eigil Lippert |
| 206 | + |
| 207 | + # Licence |
| 208 | +See License file. In short: |
| 209 | + |
| 210 | +1. Cite me in your work! something like: Kristian Aalling Sørensen, 2022, [email protected] |
| 211 | +2. Get as many as possible to follow me on Github. You and your colleagues who use this at the very least. I am a like-hunter. |
| 212 | +3. Star this repository, conditioned to the same as above. |
| 213 | +4. Maybe write me an email or two, telling me how amazing job I did? |
| 214 | +5. Help me with improving the work. I am always looking for collaborators. |
0 commit comments