import pyproj
import numpy as np
import math
# convert corners in lat/lon degrees to provided projection (RD)
# geographic_geo_product_corners
coords = [[0, 49.362053],
[0, 55.973602],
[10.856429, 55.388977],
[9.0092793, 48.895298]]
lons, lats = list(zip(*coords))
inproj4 = '+proj=stere +lat_0=90 +lon_0=0 +lat_ts=60 +a=6378.14 +b=6356.75 +x_0=0 y_0=0'
crobj = pyproj.Proj(inproj4)
mapx, mapy = crobj(lons, lats, inverse=False)
ulx = mapx[1]
lrx = mapx[3]
uly = mapy[1]
lry = mapy[3]
ulx, uly, lrx, lry
(0.0, -3649.9991119177544, 700.000903671186, -4415.003881997636)
# geographic_geo_pixel_size_x
yres = -1.0000052 # km
xres = 1.0000013
# geographic_geo_column_offset
xoffset = 0
yoffset = 3649.9802
# geographic_geo_number_columns
ncol = 700
nrow = 765
ulx = xoffset * math.copysign(1, xres)
uly = yoffset * math.copysign(1, yres)
uly = yoffset * yres
lrx = ulx + ncol * xres
lry = uly + nrow * yres
ulx, uly, lrx, lry
(0.0, -3649.9991798970395, 700.0009100000001, -4415.003157897039)
# geographic_geo_pixel_size_x
yres = -1.0000052 * 0.5 # km
xres = 1.0000013 * 0.5
# geographic_geo_column_offset
xoffset = 0
yoffset = 3649.9802*2
# geographic_geo_number_columns
ncol = 700*2
nrow = 765*2
ulx = xoffset * xres
uly = yoffset * yres
lrx = ulx + ncol * xres
lry = uly + nrow * yres
ulx, uly, lrx, lry
(0.0, -3649.9991798970395, 700.0009100000001, -4415.003157897039)