Esri / arcgis-python-api

Documentation and samples for ArcGIS API for Python
https://developers.arcgis.com/python/
Apache License 2.0
1.88k stars 1.1k forks source link

ObjectId has been updated #1375

Closed cyanineeee closed 1 year ago

cyanineeee commented 1 year ago

When I downloaded and tried to use this file, an error occured. The code 'ndvi_colorized = apply(delhi_image, 'NDVI Raw') ndvi_colorized' prompt a bug "Unable to complete operation. Failed to open raster dataset (Error Code: 400)" Thus I check code which over this part, and found that the output of df showed the objectid of 2017-10-15 is defferent from the example. changed from '2095521' to '2437835'. Finally I reset the objectid in the error codes, this bug disapear.

nanaeaubry commented 1 year ago

Can you provide us with an example item so we can try this on our end and more complete code as well? thank you It is not very clear what the issue is without having a better example or some screenshots to depict the changes

cyanineeee commented 1 year ago

Can you provide us with an example item so we can try this on our end and more complete code as well? thank you It is not very clear what the issue is without having a better example or some screenshots to depict the changes

I'm sorry for making a confusing problem description, the file I downloaded called 'How much green is Delhi as on 15 Oct 2017?' which address is 'arcgis-python-api/samples/04_gis_analysts_data_scientists/how-much-green-is-Delhi-as-on-15-oct-2017.ipynb ' the error happened in the part 'Filter imageries based on cloud cover and Acquisition Date'

The solution I founde was to change the code delhi_image = landsat.filter_by('OBJECTID=2095521') to delhi_image = landsat.filter_by('OBJECTID=2437835')

The result is fine:

nanaeaubry commented 1 year ago

@cyanineeee Ok thank you for the better description, @CMPeng can you help with this since it touches on the guides? Thanks!

CMPeng commented 1 year ago

Thanks @cyanineeee for reporting this issue. The object_id is the unique id that the specific image tile got stored on the cloud with, and theoretically should not change unless the backend has cleared this image out of the archive. I will check with the ArcGIS Online folks to have this straightened out. CC @nanaeaubry

CMPeng commented 1 year ago

Hi @cyanineeee Because the esri-living-atlas has been always updating its supported temporal range of the LandSat Data, they cannot guarantee for the OBJECTID being preserved or a certain set of images being archived in this particular raster datastore forever. For most cases, they usually only keep the latest 10 years of satellite data. That being said, a better way to have this objectid selection more automated, is to choose a narrower time range, and select the id specifically, e.g.

selected = landsat.filter_by(where="(Category = 1) AND (cloudcover <=0.05)",
                             time=[datetime(2017, 10, 10), datetime(2017, 10, 20)],
                             geometry=arcgis.geometry.filters.intersects(delhi_geom))

df = selected.query(out_fields="AcquisitionDate, GroupName, CloudCover, DayOfYear", 
                    order_by_fields="AcquisitionDate").sdf
df['AcquisitionDate'] = pd.to_datetime(df['AcquisitionDate'], unit='ms')
df

We can see that the filtered result will only have one timeframe - 2017/10/15, then we can just indicate this particular id, as in,

delhi_image = landsat.filter_by('OBJECTID=' + str(df['OBJECTID'][0])) # 2017-10-15 

This should be working regardless of how the object id changes then.