comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: get LAT/LON from georef image
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: get LAT/LON from georef image [message #65075] Wed, 11 February 2009 11:08 Go to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
titan writes:

> Could this article be used even if my image is not e GEOTIFF image?

If you have map projection information, and you know
the location of one corner (or center, I guess) of
your image, yes.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: get LAT/LON from georef image [message #65076 is a reply to message #65075] Wed, 11 February 2009 11:02 Go to previous messageGo to next message
titan is currently offline  titan
Messages: 59
Registered: March 2006
Member
On 11 Feb, 14:43, "Jean H." <jghas...@DELTHIS.ucalgary.ANDTHIS.ca>
wrote:
> titan wrote:
>> Hello! I have a georef image and I would like to extract the LAT and
>> LON values from it.
>> the dims of my image are not equal, let's say [65,80].
>> I create two vectors to be associated with the x_pixel and y_pixel of
>> the image
>
>> x_pixel=indgen(65)
>> y_pixel=indgen(80)
>
>> I know that there is the envi routine ENVI_CONVERT_FILE_COORDINATES to
>> convert X and Y pixel coordinates into their corresponding X and Ymap
>> coordinates and vice-versa.
>
>> Unfortunately it seems to work only if the lat and lon array are of
>> the same dimension in fact if we consider this example I should write
>
>> envi_convert_file_coordinates, fid, x_pixel, y_pixel, xmap, ymap, /
>> to_map
>
>> in this way I should have the respective vector xmap and ymap of lat
>> and lon
>> but if I write
>
>> help, xmap
>> help, ymap
>
>> I get
>
>> LAT_MAP DOUBLE = Array[65]
>> LON_MAP DOUBLE = Array[65]
>
>> two vector of the same dims (in this case 65) and one of 65 elements
>> and the other with 80 elements
>
>> Could someone tell me where I'm wrong??Are there any methods to
>> overpass this problem??
>> thanks
>
> Titan,
>
> yes, this is normal. x_pixel and y_pixel represent the XY pairs of
> coordinates... I am not too sure of what you are trying to extract
> exactly, but the idea is to create, in pixel index, the coordinates of
> your points of interests.
>
> So, if you want to have the coordinates of the 1st line of pixels, you
> would have:
> X_pixel = indgen(65) ; 0,1,2,3,...
> Y_pixels = intarr(65) ; 0,0,0,0,...
>
> So the pairs are [0,0],[1,0],[2,0] ....
>
> If you want to have the coords of the first column, do
> X_pixel = intarr(85)
> Y_pixels = indgen(85)
>
> And if you want the coord of every pixels,
>
> X_pixels = rebin(indgen(65),65*85) ;0*85 times, 1*85 times etc
> Y_pixels = reform(rebin(indgen(85),85,65),85*65) ;0 to 85, * 65 times
>
> Jean

What I would like to do is to obtain the vector of lat and lon of my
image in order to create an HDF image of the same dims and with the
data of lat and lon associated

thanks
Re: get LAT/LON from georef image [message #65077 is a reply to message #65076] Wed, 11 February 2009 10:58 Go to previous messageGo to next message
titan is currently offline  titan
Messages: 59
Registered: March 2006
Member
On 11 Feb, 14:43, David Fanning <n...@dfanning.com> wrote:
> titan writes:
>> Hello! I have a georef image and I would like to extract the LAT and
>> LON values from it.
>
> Here is an article that explains how I would do it:
>
> http://www.dfanning.com/map_tips/pixel_to_ll.html
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")

Could this article be used even if my image is not e GEOTIFF image?
thanks
Re: get LAT/LON from georef image [message #65087 is a reply to message #65077] Wed, 11 February 2009 05:43 Go to previous messageGo to next message
Jean H. is currently offline  Jean H.
Messages: 472
Registered: July 2006
Senior Member
titan wrote:
> Hello! I have a georef image and I would like to extract the LAT and
> LON values from it.
> the dims of my image are not equal, let's say [65,80].
> I create two vectors to be associated with the x_pixel and y_pixel of
> the image
>
> x_pixel=indgen(65)
> y_pixel=indgen(80)
>
> I know that there is the envi routine ENVI_CONVERT_FILE_COORDINATES to
> convert X and Y pixel coordinates into their corresponding X and Ymap
> coordinates and vice-versa.
>
> Unfortunately it seems to work only if the lat and lon array are of
> the same dimension in fact if we consider this example I should write
>
> envi_convert_file_coordinates, fid, x_pixel, y_pixel, xmap, ymap, /
> to_map
>
> in this way I should have the respective vector xmap and ymap of lat
> and lon
> but if I write
>
> help, xmap
> help, ymap
>
> I get
>
> LAT_MAP DOUBLE = Array[65]
> LON_MAP DOUBLE = Array[65]
>
> two vector of the same dims (in this case 65) and one of 65 elements
> and the other with 80 elements
>
> Could someone tell me where I'm wrong??Are there any methods to
> overpass this problem??
> thanks

Titan,

yes, this is normal. x_pixel and y_pixel represent the XY pairs of
coordinates... I am not too sure of what you are trying to extract
exactly, but the idea is to create, in pixel index, the coordinates of
your points of interests.

So, if you want to have the coordinates of the 1st line of pixels, you
would have:
X_pixel = indgen(65) ; 0,1,2,3,...
Y_pixels = intarr(65) ; 0,0,0,0,...

So the pairs are [0,0],[1,0],[2,0] ....

If you want to have the coords of the first column, do
X_pixel = intarr(85)
Y_pixels = indgen(85)

And if you want the coord of every pixels,

X_pixels = rebin(indgen(65),65*85) ;0*85 times, 1*85 times etc
Y_pixels = reform(rebin(indgen(85),85,65),85*65) ;0 to 85, * 65 times

Jean
Re: get LAT/LON from georef image [message #65088 is a reply to message #65087] Wed, 11 February 2009 05:43 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
titan writes:

> Hello! I have a georef image and I would like to extract the LAT and
> LON values from it.

Here is an article that explains how I would do it:

http://www.dfanning.com/map_tips/pixel_to_ll.html

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: get LAT/LON from georef image [message #65159 is a reply to message #65075] Thu, 12 February 2009 02:03 Go to previous messageGo to next message
titan is currently offline  titan
Messages: 59
Registered: March 2006
Member
On Feb 11, 8:08 pm, David Fanning <n...@dfanning.com> wrote:
> titan writes:
>> Could this article be used even if my image is not e GEOTIFF image?
>
> If you have map projection information, and you know
> the location of one corner (or center, I guess) of
> your image, yes.
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")

I have another idea and I would like to know if you think it's
correct.
Considering the answer of Jean H. I realize that I could still use the
ENVI routine ENVI_CONVERT_FILE_COORDINATES but in an "handcrafted"
way:

;; transform the number of sample and line in integer value

ns_int = fix(img_ns) ;lat
nl_int = fix(img_nl) ;lon

;; Jean H. suggests that every pixel should be defined by a couple of
values so I have to determine who between ns_int and nl_int is the
biggest value
IF (ns_int GT nl_int) THEN BEGIN
;; once the higher value has been defined, I could create two vector
of the same length
x_coord=indgen(fix(img_ns))
y_coord=indgen(fix(img_ns))
;; and now I can use the ENVI routine

ENVI_CONVERT_FILE_COORDINATES,img_fid_open,x_coord,y_coord,l at_map,lon_map,/
TO_MAP
;; in order to obtain the correct dims again and knowing that, in this
case, vector of ns (lat) is bigger than the vector of nl (lon) I have
to cut this one to its original dimension
lon_map=lat_map[0:img_nl-1]
;; if, on the contrary, integer value of nl (lon) is bigger than the
the one of ns (lat)
;; the procedure considers two vectors of the same dims vector of ns
has
ENDIF ELSE BEGIN
IF (nl_int GT ns_int) THEN $
x_coord=indgen(fix(img_nl))
y_coord=indgen(fix(img_nl))

ENVI_CONVERT_FILE_COORDINATES,img_fid_open,x_coord,y_coord,l at_map,lon_map,/
TO_MAP
;; and now the vector to be cut is the one of latitude
lat_map=lat_map[0:img_ns-1]
ENDELSE
;; finally we have the two vector of lat and lon and we can also can
create a matrix of lat lon with the same dims of our image

matrix_coord=dblarr(fix(img_ns),fix(img_nl))
matrix_coord = [lat_map,lon_map]

David or Jean H. what do you think about this procedure?
thanks

Bartolomeo (alias Titan)
Re: get LAT/LON from georef image [message #65193 is a reply to message #65159] Mon, 16 February 2009 08:13 Go to previous messageGo to next message
Jean H. is currently offline  Jean H.
Messages: 472
Registered: July 2006
Senior Member
> I have another idea and I would like to know if you think it's
> correct.
> Considering the answer of Jean H. I realize that I could still use the
> ENVI routine ENVI_CONVERT_FILE_COORDINATES but in an "handcrafted"
> way:
>
> ;; transform the number of sample and line in integer value
>
> ns_int = fix(img_ns) ;lat
> nl_int = fix(img_nl) ;lon
>
> ;; Jean H. suggests that every pixel should be defined by a couple of
> values so I have to determine who between ns_int and nl_int is the
> biggest value
> IF (ns_int GT nl_int) THEN BEGIN
> ;; once the higher value has been defined, I could create two vector
> of the same length
> x_coord=indgen(fix(img_ns))
> y_coord=indgen(fix(img_ns))
> ;; and now I can use the ENVI routine
>
> ENVI_CONVERT_FILE_COORDINATES,img_fid_open,x_coord,y_coord,l at_map,lon_map,/
> TO_MAP
> ;; in order to obtain the correct dims again and knowing that, in this
> case, vector of ns (lat) is bigger than the vector of nl (lon) I have
> to cut this one to its original dimension
> lon_map=lat_map[0:img_nl-1]
> ;; if, on the contrary, integer value of nl (lon) is bigger than the
> the one of ns (lat)
> ;; the procedure considers two vectors of the same dims vector of ns
> has
> ENDIF ELSE BEGIN
> IF (nl_int GT ns_int) THEN $
> x_coord=indgen(fix(img_nl))
> y_coord=indgen(fix(img_nl))
>
> ENVI_CONVERT_FILE_COORDINATES,img_fid_open,x_coord,y_coord,l at_map,lon_map,/
> TO_MAP
> ;; and now the vector to be cut is the one of latitude
> lat_map=lat_map[0:img_ns-1]
> ENDELSE
> ;; finally we have the two vector of lat and lon and we can also can
> create a matrix of lat lon with the same dims of our image
>
> matrix_coord=dblarr(fix(img_ns),fix(img_nl))
> matrix_coord = [lat_map,lon_map]
>
> David or Jean H. what do you think about this procedure?
> thanks
>
> Bartolomeo (alias Titan)

Bartolomeo,
Sorry for the delay in the answer... I just recovered from the flu!
Ok, so there are several conceptional errors in your text.

By doing x_coord=y_coord=indgen(img_ns), you would be getting the
coordinate of a 45degres line starting at pixel 0;0, until the line
touch the other side of the image (the diagonal of the image is the
image is a square). I doubt this information can be of any help. (see below)

You do:
matrix_coord=dblarr(fix(img_ns),fix(img_nl))
matrix_coord = [lat_map,lon_map]

This would not work, for a conceptual reason: what makes you believe
that the pixel size, in degrees, is the same at the top and at the
bottom of your image? or, seen with a different view, that the extent of
your image (again, in degrees, not in meters) is the same at the top and
the bottom of your image?
If you want to have every pixel coord, you must built the X.Y
coordinates of every pixels as I did in my previous post.

Jean
Re: get LAT/LON from georef image [message #65248 is a reply to message #65193] Wed, 18 February 2009 23:57 Go to previous message
titan is currently offline  titan
Messages: 59
Registered: March 2006
Member
Thank you for the answer Jean.
probably I have to study more your suggestion because
I tried it but what I get are two vectors with a bigger dimension than
the initial one!
is it possible or am I doing something wrong?

thank you
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: How to simplify or mesh a IDLgrLegend Obj ?
Next Topic: Update text widget

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:28:07 PDT 2025

Total time taken to generate the page: 0.00457 seconds