pytroll/python-geotiepoints

Issues with interpolation on a Sentinel Tie Point Grid.

Opened this issue · 7 comments

Code Sample, a minimal, complete, and verifiable piece of code

tie_cols = np.arange(
    1, image_data.shape[0], math.ceil(image_data.shape[0] / longitude.shape[1])
)
print(tie_cols.shape)
fine_cols = np.arange(image_data.shape[1])

tie_rows = np.arange(
    1, image_data.shape[1], math.ceil(image_data.shape[1] / latitude.shape[0])
)
print(tie_rows.shape)
fine_rows = np.arange(image_data.shape[0])

interpolator = GeoInterpolator(
    (longitude, latitude), (tie_rows, tie_cols), (fine_rows, fine_cols)
)

return interpolator.interpolate()

Problem description

I'm trying to interpolate a Tie Point Grid from a Sentinel SAR1A image but having issues with the results. The original tie grid is 10 x 21 and I'm trying to increase it to the same number of pixels as the image.

The code runs fine but visually checking the image location against the given pixel grid point gives the wrong coordinates. Is something I've doing obviously wrong?

I'd appreciate any guidance and thanks for spending time on the library.

Expected Output

Actual Result, Traceback if applicable

Versions of Python, package at hand and relevant dependencies

Thank you for reporting an issue !

These are the tie point grids involved.

Longitude:

[[ 0.14571583 0.32682806 0.50811565 0.6895768 0.8712096 1.0530123 1.2349826 1.417119 1.600425 1.7832005 1.966445 2.1483705 2.3305883 2.5141134 2.6974015 2.88026 3.0641165 3.2475178 3.4313965 3.6154175 3.7994082 ] [ 0.09239998 0.27414712 0.45607117 0.6381703 0.8204426 1.0028863 1.1854994 1.3682799 1.551301 1.735771 1.9178215 2.1015096 2.2849143 2.4686244 2.652506 2.836483 3.0208392 3.2052927 3.3896484 3.574216 3.7587206 ] [ 0.039953 0.22202377 0.40537393 0.587678 0.7697938 0.95268077 1.1359516 1.3193268 1.5029347 1.6869228 1.870654 2.0548017 2.2390354 2.4234357 2.6079986 2.7927117 2.9776149 3.1627395 3.3478067 3.5330904 3.7183886 ] [-0.0132739 0.17056847 0.3530507 0.5361213 0.7192378 0.9038486 1.0878266 1.2711986 1.4545357 1.6389832 1.8235972 2.0083723 2.1933064 2.3783982 2.5636451 2.7490456 2.9346004 3.120324 3.3061523 3.492142 3.678138 ] [-0.0669923 0.11779027 0.30116662 0.4838702 0.66905695 0.8523494 1.0366619 1.2211964 1.4057487 1.5907943 1.7760711 1.9615109 2.1471117 2.3328717 2.5187883 2.70486 2.8910842 3.0774593 3.263983 3.4506533 3.6373243 ] [-0.12171806 0.0628747 0.24719095 0.4309048 0.61639374 0.8004401 0.98546267 1.1709049 1.3564835 1.5422122 1.7281429 1.9142392 2.100499 2.2869198 2.4735 2.6602373 2.8471293 3.0341742 3.2213695 3.4087133 3.5960593 ] [-0.17614898 0.00807548 0.19330077 0.37852275 0.5640288 0.74905187 0.9348599 1.1209258 1.3071462 1.4935806 1.6801845 1.8669559 2.0538924 2.240992 2.4282525 2.6156719 2.8032477 2.990978 3.1788602 3.3668926 3.554928 ] [-0.2304723 -0.04594671 0.14006326 0.32634008 0.5123778 0.6981695 0.884526 1.0710118 1.2578312 1.4449129 1.6322105 1.8196768 2.0073094 2.1951063 2.3830655 2.5711844 2.7594612 2.9478934 3.136479 3.3252156 3.5139558 ] [-0.28569442 -0.09958667 0.08669566 0.27338758 0.46023896 0.6470768 0.83420163 1.0212812 1.2086767 1.3963965 1.5843688 1.7721901 1.9605231 2.1490233 2.337687 2.5265117 2.7154956 2.904636 3.093931 3.2833781 3.4728296 ] [-0.34177747 -0.15468074 0.03308187 0.2199161 0.40825504 0.5954306 0.78334504 0.97119117 1.1594783 1.3477794 1.5363904 1.724395 1.913423 2.1026223 2.2919865 2.4815137 2.6712015 2.8610475 3.0510497 3.2412055 3.4313667 ]]

Latitude

[[50.520092 50.54313 50.565884 50.588356 50.610546 50.632454 50.65408 50.67542 50.69659 50.717396 50.737946 50.75805 50.777885 50.797558 50.816902 50.835896 50.85469 50.87314 50.89133 50.90923 50.926826] [50.686073 50.709137 50.73192 50.754417 50.776627 50.798557 50.820198 50.841557 50.862637 50.88357 50.903934 50.92417 50.944073 50.963703 50.983044 51.00209 51.020874 51.039356 51.05753 51.075417 51.092995] [50.85218 50.875233 50.898132 50.920597 50.942734 50.96466 50.98632 51.00769 51.028778 51.049603 51.070087 51.090317 51.110245 51.129883 51.149235 51.168293 51.187065 51.20555 51.223724 51.24161 51.259197] [51.018204 51.04142 51.06416 51.086662 51.108864 51.130936 51.152622 51.173927 51.194927 51.21574 51.236263 51.256496 51.27644 51.29609 51.315445 51.33451 51.353283 51.37176 51.389942 51.40783 51.42541 ] [51.18418 51.207462 51.230255 51.25266 51.27505 51.29691 51.318577 51.339962 51.36104 51.381863 51.402397 51.42264 51.442593 51.46225 51.481613 51.500683 51.519455 51.537933 51.556114 51.573997 51.591576] [51.350044 51.37325 51.396107 51.41858 51.440956 51.462845 51.484543 51.505974 51.527107 51.547947 51.568497 51.58875 51.60871 51.628372 51.647743 51.666813 51.68559 51.704067 51.722248 51.740128 51.7577 ] [51.51596 51.539066 51.561985 51.584583 51.606907 51.628857 51.650585 51.67203 51.69318 51.71404 51.7346 51.754868 51.774834 51.794506 51.81388 51.83296 51.851734 51.870213 51.888393 51.906273 51.92384 ] [51.681908 51.704994 51.727955 51.75063 51.772957 51.79494 51.816673 51.838108 51.859264 51.880135 51.90071 51.92099 51.94097 51.96065 51.980034 51.999115 52.0179 52.036377 52.054558 52.072437 52.09 ] [51.847755 51.870987 51.893925 51.91659 51.93896 51.96101 51.982777 52.00422 52.02538 52.046257 52.066845 52.0871 52.107094 52.126785 52.146175 52.165264 52.184048 52.20253 52.22071 52.238586 52.25615 ] [52.013416 52.03672 52.059784 52.082413 52.1049 52.126934 52.14873 52.1702 52.191402 52.212284 52.232883 52.253094 52.273098 52.292797 52.312195 52.331287 52.35008 52.368565 52.386745 52.40462 52.422176]]

Thanks a lot for reaching to us about this issue!
I am a little familiar with S1A data, and I am curious as to whether the longitudes and latitudes you have are really on a grid? I've notice that the tiepoints in the GRD data at least are sometimes shifted after a couple of rows...

I've plotted the grid points and they have a slight shift due to the orbit I'm assuming. Would this skew them off?

Tie Point Grid

No, this should be fine. What I mean is that every tie point has an associated line and column number assigned to it. The way you build the grid, you assume that all the coordinates of the first column of your array are on the same column on the image, which in my experience is most of the times not the case for that type of data.

For example, I have seen case like tuples of (line, col, lon, lat) would be like
(0, 0, ..., ...)
(10, 0, ..., ...)
(20, 1, ..., ...)
(30, 1, ..., ...)
(0, 10, ..., ...)
(10, 10, ..., ...)
(20, 10, ..., ...)
(30, 11, ..., ...)
etc

I'm not saying this is the case for you data, but it happened to me a lot with Sentinel 1 data.

By the way, if you are reading Sentinel 1 GRD data, I can recommend the satpy package we are developing too. See an example usage here:
https://www.kaggle.com/martinraspaud/sar-ice-imagery

I'll take a look at the package, thanks!

From looking at the data, it does look like it is the same order as the image given how it increases and the corner points but I cannot be sure.

Does the fact there is a offset from the edge of the image to the first grid point matter?

According to the H5 dataset, there is a X and Y offset of 0.5.

If you are using H5 data then it's probably not the same than I am using. Could you produce the line and column numbers for each lon lat points so we would have a full dataset to test?