Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 如何在tfrecord中使用python API从google earth引擎下载sentinel图像_Python 3.x_Tiff_Tfrecord_Google Earth Engine_Sentinel2 - Fatal编程技术网

Python 3.x 如何在tfrecord中使用python API从google earth引擎下载sentinel图像

Python 3.x 如何在tfrecord中使用python API从google earth引擎下载sentinel图像,python-3.x,tiff,tfrecord,google-earth-engine,sentinel2,Python 3.x,Tiff,Tfrecord,Google Earth Engine,Sentinel2,尝试下载特定位置的sentinel映像时,默认情况下会在驱动器中生成tif文件,但openCV或PIL.image()无法读取该文件。下面是相同的代码。如果我使用文件格式作为tfrecord。驱动器中没有下载图像 starting_time = '2018-12-15' delta = 15 L = -96.98 B = 28.78 R = -97.02 T = 28.74 cordinates = [L,B,R,T] my_scale = 30 fname = 'sin

尝试下载特定位置的sentinel映像时,默认情况下会在驱动器中生成tif文件,但openCV或PIL.image()无法读取该文件。下面是相同的代码。如果我使用文件格式作为tfrecord。驱动器中没有下载图像

starting_time = '2018-12-15' 
delta = 15  
L = -96.98  
B = 28.78  
R = -97.02  
T = 28.74

cordinates = [L,B,R,T] 
my_scale = 30 
fname = 'sinton_texas_30'


llx = cordinates[0] 
lly = cordinates[1] 
urx = cordinates[2] 
ury = cordinates[3]

geometry = [[llx,lly], [llx,ury], [urx,ury], [urx,lly]]

tstart = datetime.datetime.strptime(starting_time, '%Y-%m-%d') tend =
tstart+datetime.timedelta(days=delta)
collSent = ee.ImageCollection('COPERNICUS/S2').filterDate(str(tstart).split('')[0], str(tend).split(' ')[0]).filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 20)).map(mask2clouds)


medianSent = ee.Image(collSent.reduce(ee.Reducer.median())) cropLand = ee.ImageCollection('USDA/NASS/CDL').filterDate('2017-01-01','2017-12-31').first() 
task_config = {
 'scale': my_scale,
 'region': geometry,
 'fileFormat':'TFRecord'
   }

f1 = medianSent.select(['B1_median','B2_median','B3_median'])


taskSent = ee.batch.Export.image(f1,fname+"_Sent",task_config)
taskSent.start()

我希望输出在python中可读,这样我就可以转换成numpy。如果文件格式为“tfrecord”,我希望该文件可以在我的驱动器中下载。

我认为您应该考虑以下事项:

文件格式 如果您想用PIL或OpenCV而不是TensorFlow打开文件,您更愿意使用GeoTIFF。尝试使用这种格式,看看是否有改进

省钱开车 通常,保存到驱动器是默认行为。但是,您可以尝试强制写入驱动器:

ee.batch.Export.image.toDrive(image=f1, ...)
您还可以尝试设置一个文件夹,将图像发送到该文件夹:

ee.batch.Export.image.toDrive(image=f1, folder='foo', ...)

此外,和这是进一步研究的良好起点。

您能提供一个无法打开的示例图像文件吗?GeoTIFF可以工作,但我无法使用TFRecord保存,是的,我想将其与tensorflow一起使用。地球引擎文档说明我们可以用TFR记录保存它。提前谢谢。