# Script to use ground control points to add a geotransform to a raster.
# coding=utf-8
import glob
import math
import os
from osgeo import gdal, osr
# The get_extent function from the text is in ch10funcs.py.
import ch10funcs
# Don't forget to change the directory.
os.chdir(r'D:\DeskTop\learn_py_must\Learn_GDAL\osgeopy-data\osgeopy-data\Massachusetts')
# Get the list of tiffs that start with O.
in_files = glob.glob('O*.tif') #会返回所有模糊查询:'O*.tif'的列表
# Loop through all of the files and get the bounding coordinates for the
# whole batch. This will be the output extent.
min_x, max_y, max_x, min_y = ch10funcs.get_extent(in_files[0])
for fn in in_files[1:]:
minx, maxy, maxx, miny = ch10funcs.get_extent(fn)
min_x = min(min_x, minx)
max_y = max(max_y, maxy)
max_x = max(max_x, maxx)
min_y = min(min_y, miny)
# Calculate the dimensions for the output based on the ou
GDAL 镶嵌至新图像(7)
最新推荐文章于 2024-04-15 14:39:01 发布