We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
in base.py
# DEM起始点:左上角,X:经度,Y:纬度 originX = geotransform[0] originY = geotransform[3] # 研究区左上角在DEM矩阵中的位置 yoffset1 = int((originY - pointUL['lat']) / pixelWidth) xoffset1 = int((pointUL['lon'] - originX) / (-pixelHight)) # 研究区右下角在DEM矩阵中的位置 yoffset2 = int((originY - pointDR['lat']) / pixelWidth) xoffset2 = int((pointDR['lon'] - originX) / (-pixelHight)) # 研究区矩阵行列数 xx = xoffset2 - xoffset1 yy = yoffset2 - yoffset1 # 读取研究区内的数据,并计算高程 DEMRasterData = DEMBand.ReadAsArray(xoffset1, yoffset1, xx, yy)<br class="Apple-interchange-newline"><!--EndFragment-->
计算出的影像区域行列起始号与行列数存在问题,建议如下写法:
geo = ds.GetGeoTransform() inv_geo = gdal.InvGeoTransform(geo) pointUL = dict() pointDR = dict() pointUL["lat"] = float(''.join(re.findall('CORNER_UL_LAT_PRODUCT.+',data2)).split("=")[1]) pointUL["lon"] = float(''.join(re.findall('CORNER_LL_LON_PRODUCT.+',data2)).split("=")[1]) pointDR["lat"] = float(''.join(re.findall('CORNER_LR_LAT_PRODUCT.+',data2)).split("=")[1]) pointDR["lon"] = float(''.join(re.findall('CORNER_UR_LON_PRODUCT.+',data2)).split("=")[1]) extent = [pointUL["lon"], pointUL["lat"], pointDR["lon"], pointDR["lat"]]
off_ulx, off_uly = map(int, gdal.ApplyGeoTransform(inv_geo, extent[0], extent[1])) off_drx, off_dry = map(math.ceil, gdal.ApplyGeoTransform(inv_geo, extent[2], extent[3])) columns = off_drx - off_ulx rows = off_dry - off_uly
data = ds.GetRasterBand(1).ReadAsArray(off_ulx, off_uly, columns, rows)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
in base.py
# DEM分辨率 pixelWidth = geotransform[1] pixelHight = geotransform[5]计算出的影像区域行列起始号与行列数存在问题,建议如下写法:
geo = ds.GetGeoTransform()
inv_geo = gdal.InvGeoTransform(geo)
pointUL = dict()
pointDR = dict()
pointUL["lat"] = float(''.join(re.findall('CORNER_UL_LAT_PRODUCT.+',data2)).split("=")[1])
pointUL["lon"] = float(''.join(re.findall('CORNER_LL_LON_PRODUCT.+',data2)).split("=")[1])
pointDR["lat"] = float(''.join(re.findall('CORNER_LR_LAT_PRODUCT.+',data2)).split("=")[1])
pointDR["lon"] = float(''.join(re.findall('CORNER_UR_LON_PRODUCT.+',data2)).split("=")[1])
extent = [pointUL["lon"], pointUL["lat"], pointDR["lon"], pointDR["lat"]]
off_ulx, off_uly = map(int, gdal.ApplyGeoTransform(inv_geo, extent[0], extent[1]))
off_drx, off_dry = map(math.ceil, gdal.ApplyGeoTransform(inv_geo, extent[2], extent[3]))
columns = off_drx - off_ulx
rows = off_dry - off_uly
data = ds.GetRasterBand(1).ReadAsArray(off_ulx, off_uly, columns, rows)
The text was updated successfully, but these errors were encountered: