Advertisement
goatbar

pystac.Item

Oct 10th, 2020
1,069
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.52 KB | None | 0 0
  1. # What is the minimum required to make a valid pystac.Item?
  2.  
  3. import datetime
  4. import pystac
  5.  
  6. year = 1999
  7. asset_id = f'USGS/GAP/CONUS/{year}'
  8. bbox = [-160.26, 18.85, -154.66, 22.29]
  9. start = datetime.datetime(year, 1, 2)
  10.  
  11. item = pystac.Item(
  12.         id=asset_id, geometry=None, bbox=bbox, datetime=start, properties={})
  13. item.set_self_href(URL_TEMPLATE % year)
  14. print(item)
  15.  
  16. import pprint
  17. pprint.pprint(item_dict)
  18.  
  19. item.validate()  # boom
  20.  
  21. item_dict = item.to_dict()
  22. pystac.validation.validate_dict(item_dict)  # boom
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement