On Tuesday, July 31, 2012 1:56:40 PM UTC+2, David Fanning wrote:
> Titan writes:
>
>
>
>> unfortunately it does not work or probably I'm still missing something :(
>
>> Using the following code I get coordinates that are pointing to an area near Corsica!!
>
>>
>
>> mapCoord_Google_earth = MAP_PROJ_INIT('Mercator', Datum=8)
>
>> lonlat_Google_Earth = MAP_PROJ_INVERSE([xLL,yLL,xUR,yUR], MAP_STRUCTURE=mapCoord_Google_earth)
>
>>
>
>> lon_range_Google_Earth=[lonlat_Google_Earth[0,0],lonlat_Goog le_Earth[0,1]]
>
>> lat_range_Google_Earth=[lonlat_Google_Earth[1,0],lonlat_Goog le_Earth[1,1]]
>
>>
>
>> UL_lat_Google_Earth=lonlat_Google_Earth[1,1]
>
>> UL_lon_Google_Earth=lonlat_Google_Earth[0,0]
>
>>
>
>> LR_lat_Google_Earth=lonlat_Google_Earth[1,0]
>
>> LR_lon_Google_Earth=lonlat_Google_Earth[0,1]
>
>>
>
>> print ,'UL_lat_Google_Earth',UL_lat_Google_Earth
>
>> print ,'UL_lon_Google_Earth',UL_lon_Google_Earth
>
>> print ,'LR_lat_Google_Earth',LR_lat_Google_Earth
>
>> print ,'LR_lon_Google_Earth',LR_lon_Google_Earth
>
>>
>
>> UL_lat_Google_Earth 47.512672
>
>> UL_lon_Google_Earth 4.4728665
>
>> LR_lat_Google_Earth 45.054882
>
>> LR_lon_Google_Earth 7.7499209
>
>>
>
>> What I'm doing wrong?!?
>
>
>
> Pretty much everything, as far as I can tell. ;-)
>
>
>
> Let's see. I think the goal was to take an image that is in
>
> a GeoTiff file and in one map projection (which one?) and
>
> convert it to another map projection (that we presume is
>
> a Mercator map projection), so we can make a KML file that
>
> overlaps.
>
>
>
> So, we need:
>
>
>
> 1. A map structure that represents the image in the GeoTiff
>
> file.
>
>
>
> 2. A map structure that represents the map projection we
>
> want to eventually get the image into (Google Earth's
>
> map projection.
>
>
>
> 3. Some method to convert from one map projection to the
>
> other.
>
>
>
> If we are lucky, we can get the map structure for (1) from
>
> cgGeoMap. That will save us about 10 hours of work pawing
>
> though the GeoTiff documentation!
>
>
>
> mapCoord = cgGeoMap(geoTiffFileName)
>
> geoTiffMapStruct = mapCoord -> GetMapStruct()
>
>
>
> We get the second map structure for (2) the way you set it up.
>
>
>
> geMapStruct = Map_Proj_Init('Mercator', /GCTP, Datum=8)
>
>
>
> For (3), we use Map_Proj_Image. We convert the XY projected
>
> meter values of the geoTiff image into the XY projected meter
>
> values of the Goggle Earth image. Then, convert those XY projected
>
> meter values into the lat/lon values we want to save in our
>
> KML file.
>
>
>
> If we have done all this correctly (we make MANY assumptions
>
> that we hope are correct!), we will have shifted the lat/lon
>
> values in the GeoTiff image just a little bit, so that they
>
> align with the lat/lon values on a Google Earth map.
>
>
>
> Cheers,
>
>
>
> David
>
>
>
> --
>
> David Fanning, Ph.D.
>
> Fanning Software Consulting, Inc.
>
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Hi david,
thanks for your answer.
my tiff file is in UTM WGS 84 32N projection and I'm not sure if I understood well your step 3.
Translating (I hope correctly!!)your suggestions I have
mapCoord = cgGeoMap(tiff_image)
geoTiffMapStruct = mapCoord -> GetMapStruct()
geMapStruct = Map_Proj_Init('Mercator', /GCTP, Datum=8)
image=Read_Tiff(path_fname+tiff_image, GEOTIFF=geotag)
ul_lat = 47.653348
ul_lon = 8.9734384
lr_lat = 45.292876
lr_lon = 13.830713
warp_r = Map_Proj_image(Reform(image[0,*,*]),[lr_lat,ul_lon,ul_lat,lr _lon], IMAGE_STRUCTURE=geoTiffMapStruct,MAP_STRUCTURE=geMapStruct, UVRANGE=warp_r_uvrange)
s = Size(warp_r, /Dimensions)
warp_g = Map_Proj_image(Reform(image[1,*,*]),[lr_lat,ul_lon,ul_lat,lr _lon], IMAGE_STRUCTURE=geoTiffMapStruct,MAP_STRUCTURE=geMapStruct, UVRANGE=warp_g_uvrange)
warp_b = Map_Proj_image(Reform(image[2,*,*]),[lr_lat,ul_lon,ul_lat,lr _lon], IMAGE_STRUCTURE=geoTiffMapStruct,MAP_STRUCTURE=geMapStruct, UVRANGE=warp_b_uvrange)
warp24 = BytArr(3, s[0], s[1])
warp24[0, *, *] = ROTATE(warp_r,7)
warp24[1, *, *] = ROTATE(warp_g,7)
warp24[2, *, *] = ROTATE(warp_b,7)
in the third step should I convert again the warp24 file or not in the google earth projection?
thanks a lot for your patience
|