Hi all,
I'm creating a .kml starting from a geotiff image. After reading this geotiff file I transformed it as a .png file and then I create the .kml file.
the code I'm using is the following
img_tiff=READ_TIFF(file_tiff, GEOTIFF=geotag)
png_fname='test' + tag + '.png'
WRITE_PNG, png_fname, img_tiff,/ORDER
The UL and LR coordinates I'm using are calculated in a previous section of the code and they are the following:
ul_lat = 47.653348
ul_lon = 8.9734384
lr_lat = 45.292876
lr_lon = 13.830713
My problem is that when I open the .kml file it is shifted and is not correctly overlaying with the features likes lake or border lines.
Even if I inserted the coordinates taken from google earth:
titan writes: > My problem is that when I open the .kml file it is shifted and is not correctly overlaying with the features likes lake or border lines.
> Even if I inserted the coordinates taken from google earth:
> I'm still not able to correctly overlay my image :(
> Could someone tell me what I'm doing wrong?
I would guess the map projection in your GeoTiff
file is different from the map projection Google
Earth uses. You will probably have to convert
your GeoTiff coordinates to the proper map
projection.
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.")
lon_range=[lonlat[0,0],lonlat[0,1]]
lat_range=[lonlat[1,0],lonlat[1,1]]
; Set the center of the projection
c_lat = (lat_range(0) + lat_range(1)) * 0.5
c_lon = (lon_range(0) + lon_range(1)) * 0.5
titan writes: > If I'm wrong could you please tell me which kind of projection is google earth using?is it a particular one?
I haven't made KML files, but when I work with Google Maps,
they always come back in a Mercator projection. I presume
that is what they are using.
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.")
David Fanning writes: > I haven't made KML files, but when I work with Google Maps,
> they always come back in a Mercator projection. I presume
> that is what they are using.
To navigate the Google Static Maps that I get from Google,
I use a Mercator projection with a WGS84 datum:
mapCoord = Obj_New('cgMap', 105, Datum=8)
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.")
> > Sepore ma de ni thui. ("Perhaps thou speakest truth.")
> Thanks a lot David,
> Tomorrow I will try using it as structure in the MAP_PROJ_INVERSE function and I will let you know as soon as possible
> cheers
Hi David,
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!!
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!!
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!
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.")
I'm not sure if these are the *centers* of the corner
pixels or the outside edge. I would probably get this
information directly from the GeoTiff file. If you did,
you would be getting the outside edge boundaries.
In other words, you can get this information from the
GeoTiff structure using tie points, the scale in the
X and Y direction, and the size of the image. All info
that is available for the GeoTiff file:
Unfortunately, the "limit" parameter in Map_Proj_Image is documented
incorrectly in some on-line help versions. (I think this was fixed in
IDL 7.1.2 or something like that.) Those limits should be in terms of XY coordinates, not lat/lon coordinates!
(Latitude and longitude are not rectangular coordinates, so using those
as the "limits" makes no sense at all, except in a few map projections.)
These limits are the limits of your input image. The UVRANGE keyword returns the limits of your re-projected image. It is *these* limits that
you want to turn into lat/lon values for your input to your KML file.
> in the third step should I convert again the warp24 file or not in the google earth projection?
You Inverse project the UVRANGE limits to lat/lon to
pass this to your KML code.
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.")
David Fanning writes: > I'm not sure if these are the *centers* of the corner
> pixels or the outside edge. I would probably get this
> information directly from the GeoTiff file. If you did,
> you would be getting the outside edge boundaries.
> In other words, you can get this information from the
> GeoTiff structure using tie points, the scale in the
> X and Y direction, and the size of the image. All info
> that is available for the GeoTiff file:
The boundary is in the variable b. Or you can use the ranges.
Same numbers, just presented differently, depending on what
you need.
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.")
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Hi David,
I tried to collect all your useful suggestions to get the rid of this problem but I think I'm still missing something and I'm getting confused :( (Do I need holiday???)
I had two approaches:
1. I'm calculating the center of the corner pixels and from this (using http://www.idlcoyote.com/map_tips/pixel_to_ll.html) I calculated the lat and lon for all pixel of the image in the Google Earth projection
2. Then I tried the FindMapBoundary function to get the border of my tiff image and then using in a correct way the map_proj_image function. After reading the tiff file and cr4eating a warped image using the Google Earth map structure I convert the uvrange in lat/lon to be passed to my kml.
The problem is that I expected coordinate near to these ul_lat = 47.653348
ul_lon = 8.9734384
lr_lat = 45.292876
lr_lon = 13.830713
which are the corners of the area in which I'm interest.
Am I still doing everything wrong?? :(
> The problem is that I expected coordinates near to these > ul_lat = 47.653348
> ul_lon = 8.9734384
> lr_lat = 45.292876
> lr_lon = 13.830713
> which are the corners of the area in which I'm interest.
> Am I still doing everything wrong?? :(
I would say the art of programming is reconciling what
we expect with what we get. :-)
I don't know how to answer you questions. I had my
own set of assumptions from the get-go. The first
is that you described the problem correctly and
accurately. But, since I've never *seen* the problem,
I can't judge if my assumption is correct. I based
my assumption on my experience that when things are
a "little bit off" it usually involves a mismatch
in map projection parameters.
If things are as bad as you now say they are, then
I'm at a complete loss. I suppose you have good
reasons for expecting something different?
Can you confirm the lat/lon values at the corners
of your geoTiff image (with, for example, Map_Proj_Forward) are what you expect them to be?
They should not change very much, I don't think,
in this coordinate transformation from UTM to Mercator.
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.")