import pandas as pd from pull_MODIS import export_oneimage, appendBand_0 """ MODIS landcover provides classification of land types: cropland, grassland, sea, etc. This script is to pull that data to use it as a mask. """ ee.Initialize() locations = pd.read_csv('locations_final_1.csv') imgcoll = ee.ImageCollection('MODIS/051/MCD12Q1') \ .filterBounds(ee.Geometry.Rectangle(-106.5, 50,-64, 23)) img = imgcoll.iterate(appendBand_0) for loc1, loc2, lat, lon in locations.values: file_name = '{}_{}'.format(int(loc1), int(loc2)) offset = 0.11 scale = 500 crs = 'EPSG:4326' region = str([[lat - offset, lon + offset], [lat + offset, lon + offset], [lat + offset, lon - offset], [lat - offset, lon - offset]]) while True: try: export_oneimage(img, 'Data_mask', file_name, region, scale, crs) except: print 'retry' time.sleep(10) continue break
# img=ee.Image(ee.Number(100)) # img=ee.ImageCollection('LC8_L1T').mosaic() for country, index in locations.values: fname = 'index' + '{}'.format(int(index)) # offset = 0.11 scale = 500 crs = 'EPSG:4326' # filter for a county region = world_region.filterMetadata('Country', 'equals', country) if region == None: print country, index, 'not found' continue region = region.first() region = region.geometry().coordinates().getInfo()[0] # region = str([ # [lat - offset, lon + offset], # [lat + offset, lon + offset], # [lat + offset, lon - offset], # [lat - offset, lon - offset]]) while True: try: export_oneimage(img, 'Data_world', fname, region, scale, crs) except: print 'retry' time.sleep(10) continue # break
# img=ee.ImageCollection('LC8_L1T').mosaic() for loc1, loc2, lat, lon in locations.values: fname = '{}_{}'.format(int(loc1), int(loc2)) # offset = 0.11 scale = 500 crs = 'EPSG:4326' # filter for a county region = county_region.filterMetadata('StateFips', 'equals', int(loc1)) region = ee.FeatureCollection(region).filterMetadata( 'CntyFips', 'equals', int(loc2)) region = ee.Feature(region.first()) # region = str([ # [lat - offset, lon + offset], # [lat + offset, lon + offset], # [lat + offset, lon - offset], # [lat - offset, lon - offset]]) while True: try: # export_oneimage(img, 'Data_test', fname, region, scale, crs) export_oneimage(img.clip(region), 'data_temperature', fname, region, scale, crs) except Exception as e: print e print 'retry' time.sleep(10) continue break
# filter for a county region = county_region.filterMetadata('StateFips', 'equals', int(loc1)) region = ee.FeatureCollection(region).filterMetadata( 'CntyFips', 'equals', int(loc2)) region = ee.Feature(region.first()) # region = region.geometry().coordinates().getInfo()[0] # region = str([ # [lat - offset, lon + offset], # [lat + offset, lon + offset], # [lat + offset, lon - offset], # [lat - offset, lon - offset]]) while True: try: export_oneimage(img.clip(region), 'test', file_name, scale, None, crs) # TODO: None for region except: print 'retry' time.sleep(10) continue break # while True: # try: # export_oneimage(img,'Data_test',fname,region,scale,crs) # except: # print 'retry' # time.sleep(10) # continue # break
for loc1, loc2, lat, lon in locations.values: file_name = '{}_{}'.format(int(loc1), int(loc2)) offset = 0.11 scale = 500 crs = 'EPSG:4326' # filter for a county region = county_region.filterMetadata('STATE num', 'equals', loc1) region = ee.FeatureCollection(region).filterMetadata( 'COUNTY num', 'equals', loc2) region = region.first() region = region.geometry().coordinates().getInfo()[0] # region = str([ # [lat - offset, lon + offset], # [lat + offset, lon + offset], # [lat + offset, lon - offset], # [lat - offset, lon - offset]]) while True: try: export_oneimage(img, 'Data_county_temperature', file_name, region, scale, crs) except Exception as e: print e print 'retry' time.sleep(10) continue break
# img=ee.Image(ee.Number(100)) # img=ee.ImageCollection('LC8_L1T').mosaic() for loc1, loc2, lat, lon in locations.values: fname = '{}_{}'.format(int(loc1), int(loc2)) # offset = 0.11 scale = 500 crs = 'EPSG:4326' # filter for a county region = county_region.filterMetadata('StateFips', 'equals', int(loc1)) region = ee.FeatureCollection(region).filterMetadata('CntyFips', 'equals', int(loc2)) region = ee.Feature(region.first()) # region = str([ # [lat - offset, lon + offset], # [lat + offset, lon + offset], # [lat + offset, lon - offset], # [lat - offset, lon - offset]]) while True: try: # export_oneimage(img, 'Data_test', fname, region, scale, crs) export_oneimage(img.clip(region), 'data_mask', fname, scale, None, crs) # TODO: None. Seems like 'clip.py' has no region except: print 'retry' time.sleep(10) continue break
crs = 'EPSG:4326' # filter for a county region = county_region.filterMetadata('STATE num', 'equals', loc1) region = ee.FeatureCollection(region).filterMetadata( 'COUNTY num', 'equals', loc2) region = region.first() region = region.geometry().coordinates().getInfo()[0] # region = str([ # [lat - offset, lon + offset], # [lat + offset, lon + offset], # [lat + offset, lon - offset], # [lat - offset, lon - offset]]) while True: try: export_oneimage(img, 'Data_county', file_name, region, scale, crs) except: print 'retry' time.sleep(10) continue break # while True: # try: # export_oneimage(img,'Data_test',fname,region,scale,crs) # except: # print 'retry' # time.sleep(10) # continue # break