AnsweredAssumed Answered

Get imagery samples from imagery layer with raster function applied

Question asked by aplesoianuesri-ro-esridist Employee on Sep 17, 2018

Hi everyone!

 

I encountered a problem while attempting to use the get_samples method of the Imagery Layer from the Python API.

I accessed the Landsat Imagery layer, applied the NDVI raster function, but the get_samples method does not return the correct values.

 

This is the code

import arcgis

from arcgis.raster.functions import *

from arcgis.geocoding import geocode

 

 

## skipped connection lines

 

# access Landsat Imagery

landsat_item = gis.content.search('Multispectral Landsat', 'Imagery Layer', outside_org=True)[0]

landsat = landsat_item.layers[0]

 

# Create geometry

area = geocode('Bucharest, RO', out_sr=landsat.properties.spatialReference)[0]

geom = arcgis.geometry.Geometry(area['extent'])

 

# Get samples

ndvi_lyr = ndvi(landsat, '5 4')
sam = ndvi_lyr.get_samples(geom, sample_count=1)
sam[0]['value']  # get only the pixel values

The output is:

'1405 1198 1012 927 1367 1146 857 9 2720'

I expected to get the values as NDVI values (-1 to +1 interval), not unprocessed data.

Am I doing something wrong?

 

Thanks for any help,
Alin

Outcomes