Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

item.links() shouldn't be an dictionary instead of method? #84

Open
marujore opened this issue Aug 27, 2019 · 1 comment
Open

item.links() shouldn't be an dictionary instead of method? #84

marujore opened this issue Aug 27, 2019 · 1 comment

Comments

@marujore
Copy link

Hi, I am new to sat-search and quite new to python
I was following the definitions in http://sat-utils.github.io/sat-api/?python#tocslinks
Based on that, on the bellow script, shouldn't "items.links" be accessed as dictionary containing "href, rel, type and title"? If I try access based on ['href'] I receive

TypeError: 'method' object is not subscriptable

The only way i could access was using items.links()

def sat_search(wlon,nlat,elon,slat,startdate,enddate,cloud,limit, collection):
	search = Search(bbox=[wlon, slat, elon, nlat],
                    time ='{}/{}'.format(startdate, enddate),
				    query={'eo:cloud_cover': {'lt': cloud},
						   'collection': { 'eq': collection}})
	
	items = search.items( limit = limit )
	print('%s items found' % len(items))
	print(items.summary( ['date', 'id', 'eo:cloud_cover', 'landsat:product_id']) )
	# print( items.calendar() )
	# items.save('test.json')

	scenes = {}
	for item in items:
		identifier = item.properties['landsat:product_id']
		scenes[identifier] = {}
		scenes[identifier]['sceneid'] = identifier
		scenes[identifier]['scene_id'] = item.id
		scenes[identifier]['cloud'] = int(item.properties['eo:cloud_cover'])
		scenes[identifier]['date'] = item.properties['datetime'][:10]
		scenes[identifier]['wlon'] = float(item.bbox[0])
		scenes[identifier]['elon'] = float(item.bbox[2])
		scenes[identifier]['slat'] = float(item.bbox[1])
		scenes[identifier]['nlat'] = float(item.bbox[3])
		scenes[identifier]['path'] = int(item.properties['eo:column'])
		scenes[identifier]['row'] = int(item.properties['eo:row'])
		scenes[identifier]['resolution'] = item.properties['eo:bands'][3]['gsd']
		scenes[identifier]['icon'] = item.assets['thumbnail']['href']
		scenes[identifier]['link'] = item.links()[0]
	return scenes

collection='landsat-8-l1'
wlon = -45.97 
elon = -45.80 
slat = -12.95
nlat = -12.89

startdate = '2018-01-01'
enddate = '2018-12-31'
cloud = 100#20
limit = 299
b = sat_search(wlon,nlat,elon,slat,startdate,enddate,cloud,limit, collection)		

Other observation, the search I performed also returned scenes that shouldn't overlap with my study area (my area is 220|069 and in search I also got from 074|069 a pacific ocean scene). I noticed that their bounding box are wrong (-179.11958 to 178.78202). I am using an if statement to eliminate them from my search. But this is a catalogation problem right?
if ( (item.bbox[0] - item.bbox[2]) > -3 ):

@matthewhanson
Copy link
Member

Almost 1 year since this opened! Closing since it's so stale, but to answer your questions:

  • item.links is a method that can be used to return all links with a certain rel type, e.g., item.links('derived_from')
  • the issue with the catalog is from the DevSeed sat-api deployment, which is outdated now but this issue can be raised there: https://github.com/sat-utils/sat-api/issues

I would recommend using https://earth-search.aws.element84.com/v0 as a STAC API which has Sentinel-2 (L1C, L2A, and L2A COGs), and Landsat will be added in the next couple weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants