Re: shifted .kml created with IDL [message #81044 is a reply to message #80955] |
Tue, 31 July 2012 04:56   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
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.")
|
|
|