You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sis.apache.org by Martin Desruisseaux <ma...@geomatys.com> on 2016/08/04 07:42:59 UTC

GeoTIFF tags for bounding box

Hello Hao

I'm moving a question on the public list since I believe that some other
peoples know better than me.

About how to get the geographic bounding box from a GeoTIFF file: I
didn't saw tags specifically for this purpose in GeoTIFF, but this can
be computed indirectly. First we need to build the mathematical function
that convert pixel coordinates to geographic or projected coordinates.
Then we can use that function for converting the raster bounds (in pixel
coordinates) to geographic or projected envelope.

For creating the mathematical function as an "affine transform", we need
one of the following tags [1]:

  * ModelPixelScaleTag
  * ModelTiepointTag

or

  * ModelTransformationTag

What are the tags that you have in your GeoTIFF file? For starting, we
would focus on what you have.

    Martin


[1] http://www.remotesensing.org/geotiff/spec/geotiff2.7.html#2.7


Re: GeoTIFF tags for bounding box

Posted by Martin Desruisseaux <ma...@geomatys.com>.
Le 04/08/16 � 09:58, phuong hao nguyen thi a �crit :
> Sorry , I'm confused , I haven't  ModelTransformationTag I just read
> ModelPixelScaleTag, ModelTiepointTag ,  width  and height image

Then it is the same steps than before, except that the way to create the
matrix is a little bit more complicated. You can create an instance of
org.apache.sis.referencing.operation.matrix.Matrix4 and assign the
following values:

    matrix.m00 = scaleX;
    matrix.m11 = scaleY;
    matrix.m22 = scaleZ;

For the tie points, if (I, J, K) a zero then:

    matrix.m03 = X;
    matrix.m13 = Y;
    matrix.m23 = Z;

If (I, J, K) are not zero, then this is a little bit more complicated.

    Martin



Re: GeoTIFF tags for bounding box

Posted by phuong hao nguyen thi <ng...@gmail.com>.
Sorry , I'm confused , I haven't  ModelTransformationTag I just read
ModelPixelScaleTag, ModelTiepointTag ,  width  and height image

On Thu, Aug 4, 2016 at 2:53 PM, phuong hao nguyen thi <
nguyenthiphuonghao243@gmail.com> wrote:

> Hello Martin and all ,
> Thank for your help .
> The present I haved 3 tag ModelPixelScaleTag, ModelTiepointTag,
> ModelTransformationTag and I haved wide image  and height image too ,
> So What would I do next ?
>
> Hao
>
> On Thu, Aug 4, 2016 at 2:42 PM, Martin Desruisseaux <
> martin.desruisseaux@geomatys.com> wrote:
>
>> Hello Hao
>>
>> I'm moving a question on the public list since I believe that some other
>> peoples know better than me.
>>
>> About how to get the geographic bounding box from a GeoTIFF file: I
>> didn't saw tags specifically for this purpose in GeoTIFF, but this can
>> be computed indirectly. First we need to build the mathematical function
>> that convert pixel coordinates to geographic or projected coordinates.
>> Then we can use that function for converting the raster bounds (in pixel
>> coordinates) to geographic or projected envelope.
>>
>> For creating the mathematical function as an "affine transform", we need
>> one of the following tags [1]:
>>
>>   * ModelPixelScaleTag
>>   * ModelTiepointTag
>>
>> or
>>
>>   * ModelTransformationTag
>>
>> What are the tags that you have in your GeoTIFF file? For starting, we
>> would focus on what you have.
>>
>>     Martin
>>
>>
>> [1] http://www.remotesensing.org/geotiff/spec/geotiff2.7.html#2.7
>>
>>
>

Re: GeoTIFF tags for bounding box

Posted by Martin Desruisseaux <ma...@geomatys.com>.
Le 04/08/16 � 09:53, phuong hao nguyen thi a �crit :
> The present I haved 3 tag ModelPixelScaleTag, ModelTiepointTag,
> ModelTransformationTag and I haved wide image  and height image too ,
> So What would I do next ?

If you have ModelTransformationTag, I suggest to use that one. The other
tags will also need to be supported, but we can do that later.

According http://www.remotesensing.org/geotiff/spec/geotiff2.6.html this
tag should have 16 values of type 'double' (IEEE754). This value needs
to be stored in a matrix. The geotiff2.6.html page give the layout.
After you have read the double[] array from the GeoTIFF file, you can
use org.apache.sis.referencing.operation.matrix.Matrices.create(4, 4,
elements) method - but please read the javadoc for making sure that the
layout of the 'elements' array is the same than the layout of the
GeoTIFF array.

After you got a matrix, you can build a "math transform" from it using
org.apache.sis.referencing.operation.transform.MathTransforms.linear(matrix)
method. What you get is called "affine transform". If you are not
familiar with them, it may be worth to search "affine transform
tutorial" on Google. Affine transforms are very important in GIS and
there is many tutorial on the web about them.

After you got the transform, you can test it with a few points:

    DirectPosition pix = new DirectPosition2D(0, 0);    // Pixel coordinates
    DirectPosition geo = mt.transform(pix, null);
    System.out.println(geo);

Martin



Re: GeoTIFF tags for bounding box

Posted by phuong hao nguyen thi <ng...@gmail.com>.
Hello Martin and all ,
Thank for your help .
The present I haved 3 tag ModelPixelScaleTag, ModelTiepointTag,
ModelTransformationTag and I haved wide image  and height image too ,
So What would I do next ?

Hao

On Thu, Aug 4, 2016 at 2:42 PM, Martin Desruisseaux <
martin.desruisseaux@geomatys.com> wrote:

> Hello Hao
>
> I'm moving a question on the public list since I believe that some other
> peoples know better than me.
>
> About how to get the geographic bounding box from a GeoTIFF file: I
> didn't saw tags specifically for this purpose in GeoTIFF, but this can
> be computed indirectly. First we need to build the mathematical function
> that convert pixel coordinates to geographic or projected coordinates.
> Then we can use that function for converting the raster bounds (in pixel
> coordinates) to geographic or projected envelope.
>
> For creating the mathematical function as an "affine transform", we need
> one of the following tags [1]:
>
>   * ModelPixelScaleTag
>   * ModelTiepointTag
>
> or
>
>   * ModelTransformationTag
>
> What are the tags that you have in your GeoTIFF file? For starting, we
> would focus on what you have.
>
>     Martin
>
>
> [1] http://www.remotesensing.org/geotiff/spec/geotiff2.7.html#2.7
>
>