SHARE
TWEET

Untitled

a guest Aug 14th, 2019 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Load Sentinel 1 and filter data
  2. def load_dataset(ImageCollection_ID,begin,end,aoi):
  3.     ic = ee.ImageCollection(ImageCollection_ID).filterDate(begin,end).filterBounds(aoi)
  4.     return ic
  5.  
  6. def filter_sentinel1(ImageCollection,polarisation,instrumentMode,resolution):
  7.     ic = ImageCollection.filter(ee.Filter.listContains('transmitterReceiverPolarisation',polarisation)).filter(ee.Filter.eq('instrumentMode',instrumentMode)).filterMetadata('resolution_meters','equals', resolution)
  8.     return ic
  9.  
  10. def seperate_look_angels(ImageCollection,polarisation):
  11.     Ascending = ImageCollection.filter(ee.Filter.eq('orbitProperties_pass', 'ASCENDING')).select(polarisation)
  12.     Descending = ImageCollection.filter(ee.Filter.eq('orbitProperties_pass', 'DESCENDING')).select(polarisation)
  13.     return Ascending,Descending
  14.  
  15.  
  16. def get_properties(ImageCollection):
  17.     features = ImageCollection.getInfo()['features']
  18.     dict_list = []
  19.     for f in features:
  20.         prop = f['properties']
  21.         dict_list.append(prop)
  22.     df = pd.DataFrame.from_records(dict_list).drop(['system:footprint','transmitterReceiverPolarisation'],axis=1)
  23.     #Pandas Series of unique distinc values in df
  24.     unique = df.nunique()
  25.     im_id_list = [item.get('id') for item in ImageCollection.getInfo().get('features')]
  26.     date_list = [datetime.datetime.strptime(x[35:43],'%Y%m%d') for x in im_id_list]
  27.     #property_names = list(df.columns.values)
  28.     return unique, im_id_list, date_list
  29.  
  30. def make_mosaic(date):
  31.     date = ee.Date(date['value'])
  32.     filterCollection = VV_Ascending.filterDate(date, date.advance(1,'day'))
  33.     image = ee.Image(filterCollection.mosaic()).copyProperties(filterCollection.first(),["system:time_start"])
  34.     return image
  35.  
  36. #Time of interest
  37. begin = ee.Date.fromYMD(2016,1,1)
  38. end = ee.Date.fromYMD(2016,3,1)
  39. date_range = end.difference(begin, 'day')
  40.  
  41. #Source dataset
  42. ried_225_222 = ee.FeatureCollection('users/tillmueller1990/ried_225_222')
  43. sentinel1 = load_dataset('COPERNICUS/S1_GRD',begin,end,ried_225_222)
  44. #Filter dataset for High resolution and Vertical transmitt vertical receive
  45. sentinel1_VV = filter_sentinel1(sentinel1,'VV','IW',10)
  46. #Filter for different look angles
  47. VV_Ascending,VV_Descending = seperate_look_angels(sentinel1_VV,'VV')
  48.  
  49.  
  50. #Get list of ids,dates and unique count of prop
  51. unique, im_id_list, date_list = get_properties(VV_Ascending)
  52. date_list = ee.List([ee.Date(x) for x in date_list])
  53. newList = ee.List([])
  54.  
  55. for date in date_list.getInfo():
  56.     mosaic = ee.Image(make_mosaic(date))
  57.     print(mosaic.getInfo())
  58.     newList.add(mosaic)
  59. newcol = ee.ImageCollection(newList)
  60. print(newcol.getInfo())
  61.      
  62. {'type': 'Image', 'bands': [{'id': 'VV', 'data_type': {'type': 'PixelType', 'precision': 'double'}, 'crs': 'EPSG:4326', 'crs_transform': [1.0, 0.0, 0.0, 0.0, 1.0, 0.0]}], 'properties': {'system:time_start': 1452618462260.0}}
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top