Re: rong coordinates with write tiff [message #93192 is a reply to message #93175] |
Tue, 10 May 2016 20:32  |
jiashenyue
Messages: 10 Registered: January 2013
|
Junior Member |
|
|
On Friday, May 6, 2016 at 9:25:43 PM UTC-7, omar ali wrote:
> Hi,
> I have subset a tiff image and use write_tiff, file, output, GEOTIFF = GEO, /float. the coordinates of the subset is wrong. the upper left corner coordinates of the subset is the same of the original image although the subset is located at the middle of the image. Anyone faced such a problem !!!!
>
>
> Thanks,
>
> Omar
If you just "subset" your tiff by obtaining a new matrix through specifying the start and end col/row, this WON'T change anything you have in the geo_tiff structure. If you keep using the original geo_tiff structure for your output, it will still create exactly the same spatial extent as it used to be. So if you want to get the correct extent, you have to manually calculate the upper (upper left, UL) and lower (lower right, LR) bounds of the new subset.
First obtain the upper left and lower right corner coordinates, then check the cell size of your original data. With the above information, it is very easy to calculate the upper left and lower right coordinates of your subset.
For example, you have a matrix named ARR, and the origin of your coordinate system is to the northwest of your upper left corner. In other words, the X (column) of the original UL is smaller than the X of the original LR, the Y (row) of the original UR is smaller than the Y of the original LR. It is extremely important to compare the original UL and LR coordinates, since if this step is missing, you won't know if you move your upper left corner, your new UL will have a smaller or large X (or Y).
Suppose the coordinate of UL corner is (-123456,5678) (unit = meters if you are using a standard projected coordinate system) and your cell size is 30 m, and your new subset start from the 2nd row and 2nd column of the original data (start from ARR[1,1]). Your new UL coordinates are:
(-123445+30*1,5678-30*1)
Do this for lower right corner as well, be careful about whether to add or subtract distance from the original coordinates.
After getting the new bounds, assign the new bounds to the geo_tiff structure and use the new structure for output.
Hope it helps!
Shenyue
|
|
|