Add Sentinel-2 Layer by Code and Acquisition Date

1745
4
06-22-2018 05:38 AM
MathieuOuellette1
New Contributor II

Hi, I started working in ArcMap with Sentinel-2 layers from the Living Atlas. I would like to know if it is possible to add those layers by code to ArcMap and especially by specifying an acquisition date? Thanks!

Tags (1)
0 Kudos
4 Replies
PeterBecker
Esri Regular Contributor

Image Services can be added to ArcMap and Pro using code. See

http://resources.esri.com/help/9.3/ArcGISServer/apis/ArcObjects/esriCarto/IImageServerLayer.htm

  //create an image server layer by passing an URL
  IImageServerLayer2 imageserverlayer = new ImageServerLayerClass();
  string URL = "http://myserver/arcgis/services/amazon/imageserver";
  imageserverlayer.Initialize(URL);

Or  call the make image service layer tool.

http://pro.arcgis.com/en/pro-app/tool-reference/data-management/make-image-server-layer.htm

You will likely find that you do not need to add through code. Look to make use of the mosaic method and rules that are available with such dynamic image services. You will see that the default mosaic method for the Sentinel Services is "By Attribute" Best 0. This sorts the data based on a field is computed to define the image with the best (latest, least cloud cover) on top. You can change the mosaic method to define an other fields. Eg Acquisition Date and specific a date in which case imagery closet to that date will be shown. You can also add filters that return only specific subsets. Eg you could specify image closest to a specific date and where cloud cover is less than a specified value. The layer will be dynamic in that if better imagery becomes available then it will automatically display the better imagery. Naturally you can also specify one of the predefined functions or append into the layer definition your own function to be processed on the server, so that only the required pixels need be returned.

MathieuOuellette1
New Contributor II

Thanks for your answer! I tried the following call in the Python window of ArcMap and I got an error 440:

arcpy.MakeImageServerLayer_management("https://sentinel.arcgis.com/arcgis/services/Sentinel2/ImageServer", "test", mosaic_method = "BY_ATTRIBUTE", order_field = "AcquisitionDate", order_base_value = "2018/06/22")

Then I remove the last part of the URL and no error was raise but nothing was added to the TOC. I also tried so assign the call to a variable and called arcpy.Describe() on a runtime error was returned. Do you not what's wrong? My ArcMap version is 10.4.1.5696.

arcpy.MakeImageServerLayer_management("https://sentinel.arcgis.com/arcgis/services", "test", mosaic_method = "BY_ATTRIBUTE", order_field = "AcquisitionDate", order_base_value = "2018/06/22")

I was looking a the sort field values available and was wondering what SyncDateTime and DateUpdated meant? Could I use one of these in order to always have the most recent image in my map document? Do you know where I can find the documentation on all those values?

Thanks a lot !

0 Kudos
AbhijitDoshi
Esri Contributor

 You can use the Below command

arcpy.MakeImageServerLayer_management("https://sentinel.arcgis.com/arcgis/rest/services/Sentinel2/ImageServer", "test", mosaic_method = "BY_ATTRIBUTE", order_field = "AcquisitionDate", order_base_value = "2018/06/22")

Note : The sentinel2 layer is secured so you need to be logged into ArcGIS online 

0 Kudos
MathieuOuellette1
New Contributor II

Hi, I'm logged into ArcGIS Online and I copy/pasted the command (which seems identical as the one I used) and I get an error 840.

Do you know why it doesn't work?

Thanks!

0 Kudos