MODIS Tile 拼接和重投影

import arcpy, os, sys
from arcpy import env
from arcpy.sa import *
arcpy.env.overwriteOutput = True
arcpy.CheckOutExtension("Spatial")
from os import listdir
from os.path import isfile, join
import numpy as np
from osgeo import gdal

##Mosaic To New Raster
##Usage: MosaicToNewRaster_management inputs;inputs... output_location raster_dataset_name_with_extension 
##                                    {coordinate_system_for_the_raster} 8_BIT_UNSIGNED | 1_BIT | 2_BIT | 4_BIT 
##                                    | 8_BIT_SIGNED | 16_BIT_UNSIGNED | 16_BIT_SIGNED | 32_BIT_FLOAT | 32_BIT_UNSIGNED 
##                                    | 32_BIT_SIGNED | | 64_BIT {cellsize} number_of_bands {LAST | FIRST | BLEND  | MEAN 
##                                    | MINIMUM | MAXIMUM} {FIRST | REJECT | LAST | MATCH}    


# ----------------------
# STEP1: Read data 
# ----------------------

# Date 
year         = 2008;  
date_list = np.arange(1,362,8);

# Output folder
folder_ouput = "E:/MODIS/GPP500m/gpp_"+str(year)+"/gpp_"+str(year)+"_mosaic";


# Input file folder
folder_input_list = ['E:/MODIS/GPP500m/gpp_'+str(year)+"/gpp_"+str(year)+'/h08v04',\
                     'E:/MODIS/GPP500m/gpp_'+str(year)+"/gpp_"+str(year)+'/h08v05',\
                     'E:/MODIS/GPP500m/gpp_'+str(year)+"/gpp_"+str(year)+'/h08v06',\
                     'E:/MODIS/GPP500m/gpp_'+str(year)+"/gpp_"+str(year)+'/h09v04',\
                     'E:/MODIS/GPP500m/gpp_'+str(year)+"/gpp_"+str(year)+'/h09v05',\
                     'E:/MODIS/GPP500m/gpp_'+str(year)+"/gpp_"+str(year)+'/h09v06',\
                     'E:/MODIS/GPP500m/gpp_'+str(year)+"/gpp_"+str(year)+'/h10v04',\
                     'E:/MODIS/GPP500m/gpp_'+str(year)+"/gpp_"+str(year)+'/h10v05',\
                     'E:/MODIS/GPP500m/gpp_'+str(year)+"/gpp_"+str(year)+'/h10v06',\
                     'E:/MODIS/GPP500m/gpp_'+str(year)+"/gpp_"+str(year)+'/h11v04',\
                     'E:/MODIS/GPP500m/gpp_'+str(year)+"/gpp_"+str(year)+'/h11v05',\
                     'E:/MODIS/GPP500m/gpp_'+str(year)+"/gpp_"+str(year)+'/h12v04',\
                     'E:/MODIS/GPP500m/gpp_'+str(year)+"/gpp_"+str(year)+'/h12v05',\
                     'E:/MODIS/GPP500m/gpp_'+str(year)+"/gpp_"+str(year)+'/h13v04',\
                     ]
    
# Tiles which we want to mosaic
tile_list = ['.h08v04.tif',
             '.h08v05.tif',
             '.h08v06.tif',
             '.h09v04.tif',
             '.h09v05.tif',
             '.h09v06.tif',  
             '.h10v04.tif', 
             '.h10v05.tif', 
             '.h10v06.tif', 
             '.h11v04.tif', 
             '.h11v05.tif', 
             '.h12v04.tif', 
             '.h12v05.tif',
             '.h13v04.tif' ]
             
           
# ----------------------
# STEP2: Processing
# ----------------------
for date in date_list:
    
    #### Defeine output file name ####
    file_list = []
    filename1  = 'GPP.'+str(year)+'{:03d}'.format(date)+'.tif'
    filename2  = 'GPP.'+str(year)+'{:03d}'.format(date)+'_wgs84_0005D'+'.tif'
    
    #### Read input file ####
    for tile, folder in zip(tile_list,folder_input_list):
    
       file_list.append( folder+ '/'+'GPP.'+str(year)+'{:03d}'.format(date)+ tile)
    
    
    #### Merge all raster ####
    mosaic = arcpy.MosaicToNewRaster_management(file_list, folder_ouput, filename1, "",  "16_BIT_SIGNED", "", "1", "LAST","FIRST")
    print(filename1)
    


    #### eproject to wgs84 ####
    
    # open dataset
    #dataset = gdal.Open(filename1,gdal.GA_ReadOnly)
    
    # gdalwarp
    #kwargs = {'format': 'GTiff', 'dstSRS': 'EPSG:4326','xRes':0.005,'yRes':0.005}
    #ds = gdal.Warp(destNameOrDestDS=filename2,srcDSOrSrcDSTab=dataset, **kwargs)
    #del ds 



[1] MosaicToNewRaster_management 
主要参考:https://community.esri.com/t5/python-questions/merge-rasters-mosaic-to-new-raster/td-p/88308
官方文档:https://pro.arcgis.com/zh-cn/pro-app/2.7/tool-reference/data-management/mosaic-to-new-raster.htm
CSDN: https://www.twblogs.net/a/5d539b54bd9eee541c317cd9/?lang=zh-cn

[2] Reproject to wgs84
reproject to wgs84:https://gis.stackexchange.com/questions/386381/converting-
reproject to wgs84: https://www.programcreek.com/python/example/116446/gdal.Warp (!)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值