2015-07-14 2 views
0

Я использую gdal python для перепрограммирования файла grib. Я делаю этот python вместо gdalwarp, потому что я не хочу принимать удар по написанию нового файла и читать обратно в скрипте python для дальнейшей обработки. И работает gdalwarp очень медленно и создает очень большие файлы. В настоящее время я использую код перепрограммирования от http://jgomezdans.github.io/gdal_notes/reprojection.html.gdal reprojectimage cuts off image

osng = osr.SpatialReference() 
osng.ImportFromEPSG (epsg_to) 
wgs84 = osr.SpatialReference() 
wgs84.ImportFromEPSG (epsg_from) 
tx = osr.CoordinateTransformation (wgs84, osng) 
# Up to here, all the projection have been defined, as well as a 
# transformation from the from to the to :) 
# We now open the dataset 
g = gdal.Open (dataset) 
# Get the Geotransform vector 
geo_t = g.GetGeoTransform() 
x_size = g.RasterXSize # Raster xsize 
y_size = g.RasterYSize # Raster ysize 
# Work out the boundaries of the new dataset in the target projection 
(ulx, uly, ulz) = tx.TransformPoint(geo_t[0], geo_t[3]) 
(lrx, lry, lrz) = tx.TransformPoint(geo_t[0] + geo_t[1]*x_size, \ 
             geo_t[3] + geo_t[5]*y_size) 
# See how using 27700 and WGS84 introduces a z-value! 
# Now, we create an in-memory raster 
mem_drv = gdal.GetDriverByName('MEM') 
# The size of the raster is given the new projection and pixel spacing 
# Using the values we calculated above. Also, setting it to store one band 
# and to use Float32 data type. 
dest = mem_drv.Create('', int((lrx - ulx)/pixel_spacing), \ 
     int((uly - lry)/pixel_spacing), 1, gdal.GDT_Float32) 
# Calculate the new geotransform 
new_geo = (ulx, pixel_spacing, geo_t[2], \ 
      uly, geo_t[4], -pixel_spacing) 
# Set the geotransform 
dest.SetGeoTransform(new_geo) 
dest.SetProjection (osng.ExportToWkt()) 
# Perform the projection/resampling 
res = gdal.ReprojectImage(g, dest, \ 
      wgs84.ExportToWkt(), osng.ExportToWkt(), \ 
      gdal.GRA_Bilinear) 

Проблема в том, что она, кажется, отключает мои данные. я не совсем уверен, как изменить размер перепрограммированного изображения, чтобы он содержал все данные. вот как это выглядит: result

Что это предполагают, чтобы выглядеть expected

ответ

0

я должен был найти макс/мин X и Y. использование макс/мин, что вместо Л.Р., ул баллов.