Issues - Extracting satellite image using sentinelsat

713 Views Asked by At

I am using the below code to extract satellite image using sentinelsat

from sentinelsat import SentinelAPI, read_geojson, geojson_to_wkt
from datetime import date
api = SentinelAPI('userid', 'password', 'https://scihub.copernicus.eu/dhus')

footprint = geojson_to_wkt(read_geojson('./map.geojson'))

products = api.query(footprint,
                     date = ('20180101', '20191010'),
                     platformname = 'Sentinel-2',
                     processinglevel = 'Level-2A',
                     cloudcoverpercentage = (0,3)
                    )

products_gdf = api.to_geodataframe(products)
products_gdf_sorted = products_gdf.sort_values(['cloudcoverpercentage'], ascending=[True])

products_gdf_sorted.index

api.download('fed1003b-effa-41f5-9079-5d017af0eea2')

I have ensured that my geojson is pointing to the correct position.

{
  "type": "Polygon",
  "coordinates": [
    [
      [
    80.265872,13.064500
      ],
      [
    80.265526,13.064076
      ],
      [
    80.266435,13.064190
      ],
      [
    80.265872,13.064500
      ]
    ]
  ]
} 

I am expecting building to be part of my tiff file. But I am just getting green patch as the output.

I am using the following code to create the tiff file.

import rasterio as rio
R10 = '.\S2A_MSIL2A_20190511T045701_N0212_R119_T44PMV_20190511T104102.SAFE\GRANULE\L2A_T44PMV_A020279_20190511T050605\IMG_DATA\R10m'


b4 = rio.open(R10+'\T44PMV_20190511T045701_B04_10m.jp2' , driver='JP2OpenJPEG')
b3 = rio.open(R10+'\T44PMV_20190511T045701_B03_10m.jp2' , driver='JP2OpenJPEG')
b2 = rio.open(R10+'\T44PMV_20190511T045701_B02_10m.jp2', driver='JP2OpenJPEG')


with rio.open('RGB.tiff','w',driver='Gtiff', width=b4.width, height=b4.height, 
              count=3,crs=b4.crs,transform=b4.transform, dtype=b4.dtypes[0]) as rgb:
    rgb.write(b2.read(1),1) 
    rgb.write(b3.read(1),2) 
    rgb.write(b4.read(1),3) 
    rgb.close()

Where am I going wrong, whether I am missing any parameter while doing the extraction or my expectation is wrong. Kindly clarify. Thanks in advance.

0

There are 0 best solutions below