Trying to use jupyter notebooks and arcgis api to access sentinel data

211
6
08-18-2020 06:50 AM
BobClark
New Contributor

Hi,

I am just getting started with python and the arcgis api and I’m trying to use jupyter notebook to analyse sentinel data for pre and post fire processing assignment. I found some help online but I keep getting stuck calling in the sentinel data and wonder if someone could please help me?

I would like to try filter by the date and intersection. Do I need to obtain a Token for the sentinel dataset?

 

from arcgis import GIS

gis = GIS()

 

 

sentinel_item = gis.content.search('Sentinel-2 Views', outside_org=True)[0]

sentinel_item

 

import arcgis

 

sentinel = sentinel_item.layers[0]

aoi = {'spatialreference': 'WGS 1984',

      'xmax': 15804453,

      'xmin': 17113072,

      'ymax': -3049737,

      'ymin': -3888071}

arcgis.env.analysis_extent = aoi

sentinel.extent = aoi

 

import pandas as pd

from datetime import datetime

startdate = pd.to_datetime(input("What is the fire start date "))

enddate = pd.to_datetime(input("What is the fire end date "))

selected = sentinel.filter_by(where="acquisitiondate BETWEEN timestamp 'startdate' AND timestamp 'enddate'",

                              geometry=arcgis.geometry.filters.intersects(aoi))

 

df = selected.query(out_fields='AcquisitionDate, Tile_ID, CloudCover', order_by_fields='AcquisitionDate').df

df['acquisitiondate'] = pd.to_datetime(df['acquisitiondate'], unit = 'ms')

 

Thanks,

Bob

Reply
0 Kudos
6 Replies
GuneetMutreja
Esri Contributor

Hi, 

You would require an ArcGIS Online account to use Sentinel 2 Views. I would suggest you use : gis = GIS("https://www.arcgis.com", "arcgis_python", "P@ssword123") as your GIS object. The details of this account is mentioned in the guide here.

A screenshot is attached to show its working with the gis object mentioned.

Reply
0 Kudos
BobClark
New Contributor

Thanks for your help Guneet!!

Reply
0 Kudos
BobClark
New Contributor

Hi,

I progressed the code further and was wondering if you could help with an arcgis method to mosaic all the sentinel tiles as my area is large. I'm also stuck on filtering by each day the capture was taken and saving throughout a fire event. I have screenshot where i am up to below.

Thank  you so much!!

Reply
0 Kudos
GuneetMutreja
Esri Contributor

Hey Bob,

have a look at the notebook here. There are certain calculations that are performed here similar to what you are looking for. I believe this may help you out.

Reply
0 Kudos
GuneetMutreja
Esri Contributor

Also, for creating mosaic the API has a mosaic function available. Have a look at this link.

Reply
0 Kudos
BobClark
New Contributor

Thanks again Guneet. The links were very helpful!

Reply
0 Kudos