Using psconvert to make a kml - failing

Trying to make a kml of some data.

The data is read in from .asc files and is in geographic coordinates.

I make the image, plots up fine as a .png (using psconvert)

then i make another one (to a different file name) as a ,kml but i get the error:
“To GE images must be in geographical coordinates. Very likely this won’t work as you wish inside GE.”

and it won’t open in GE.

so it seems that it does not know I have geographic coordinates…

the commands I am using are:

grdimage flowdepth2.grd $region -J$project -Cfd.cpt -K -P -B$border_h_kml --MAP_FRAME_TYPE=inside -Q >> $plot2

psscale -D$scale_loc_h -Cfd.cpt -B$sc_int_H -P -O --FONT_LABEL=8p,white --MAP_FRAME_PEN=0.5p,white --FONT_ANNOT_PRIMARY=6p,white --MAP_ANNOT_OFFSET_PRIMARY=2p --MAP_LABEL_OFFSET=3p --MAP_DEFAULT_PEN=+white --FORMAT_FLOAT_OUT=%.f >> $plot2

psconvert -A -Tg -W+k -E300 $plot2

i’ve included a plot of the data showing it is indeed in geographical coordinates. The KML i am trying to make is just the coloured data (not the topo/bathy below). Also attaching the .png that gets made from the psconvert (-W+k) call.

what am i doing wrong?

Thanks!

Not sure but, what is the value of $project?

Sorry, I’m a bit lost with the KML part. psconvert does not produce kml. grd2kml or gmt2kml do.

Ah, it’s just the projection info… it comes in from another part of the code. I have it set to M180/0/3i

1 Like

ummm, ok… I thought that was the way to do it, I recall doing it like that in the past… In the manual for psconvert it says:

“Use -W+k to create a minimalist KML file that allows loading the image in GoogleEarth. Note that for this option the image must be in geographical coordinates. If not, a warning is issued but the KML file is created anyway.”

But I will look at grd2kml and gmt2kml now and report back. Thanks!

Not true @Joaquim, remember psconvert -W+k.

yeah, that is what I thought… I am looking at grd2kml, but i can’t figure out where the actual kml file gets named or created… There is something missing that i obviously don’t understand. Also, there would dbe no way to put on a color bar using grd2kml from what I can tell.

so, back to psconvert… how to i get ti to believe me that my data are in geographical coordinates?

in the past i had psconvert doing it for me no problem, but somehow now it isn’t working.

in the workflow, i start with a .asc file which is most definitely in geographical coordinates (lat/long)

then i do a grdconvert to change it to a GMT grid
then i do some grdmath on it to mask out some nodes and make them transparent
then i plot it and all that is fine… just this last step with psconvert it gets weird.

thanks,

-jose

Set projection to -JQ instead so you are making a longlat plot for GE.

Ofc (and I wrote it)

Hi Paul, Joaquim,

OK, I tried:

-JQ/176.985/-37.944/3i (the center lines of my output area) and it is still not loading properly.

When I double click the kml, it take me to the right place on earth, but it just does not show the image.

When i ‘get info’ (MacOS or ‘properties’ on Windows) in GE, and click on the location tab, the file name is ok, and the extents of the image are ok. If i manually select the file location through the GE dialog, it still does not show the image.

Looking inside the .kml file itself (attached here from the run using the -JQ option), I see that the information in the <LatLonBox> seems ok, but the <LatLonAltBox> has non-geographical numbers in it.

When i copy/paste the lines from <LatLonBox> to overwrite the lines below <LatLonAltBox> , then re-save the kml and double click it, it loads up fine in GE.

As a check, i re-ran the script using my original -JM projection setting and the .kml file was nearly the same as with -JQ, just that the numbers inside the <LatLonAltBox> settings were different. I got the same result if i copied the values from <LatLonBox> to <LatLonAltBox> inside the .kml.

so yeah, not sure what is happening. I have a bit of a wonky workaround, but not sure why the image does not load when the .kml is double clicked.

(i’ve zipped the .kml)

Thanks,

-jose

max_fd_kml.kml.zip (1.0 KB)

Can you add the ps file? The one that psconvert -W+k should work with.

Hi Joaquim,

Attached here. This is the .ps made using -JQ for the projection.

I have zipped it.

Thanks,

-jose

max_fd_kml.ps.zip (46.4 KB)

@Joaquim @pwessel apologies guys… i found the error. need to use -JX

i’d actually had this problem three years ago, and we discussed the solution in the old forum… then i totally forgot about it since i haven’t needed that functionality since then.

anyway, now it works. i’ll ask the same question again in 2023…

-jose

Yes, when psconvert see this line

%@PROJ: eqc 176.94000000 177.03000000 -37.98000000 -37.90800000 -3946.039 3946.039 -4223188.074 -4215182.030 +proj=eqc +lat_ts=-37.944 +lat_0=0 +lon_0=176.985 +x_0=0 +y_0=0 +units=m +a=6371007.181 +b=6371007.180918 +units=m +no_defs

it sees projected coordinates after the geogs. The warning message should improved.

Ah, and I think you want -TG instead of -Tg to preserve the transparency.

If you were on Windows I would recommend that you use Mirone to visualize your tsunami modelings. Specially if you can have the results in the form of a 3D netcdf stack.
And it would also be nice to see some comparisons with NSWING but again this guy is only parallelized on Windows.

If possible could you add a line to the manual for psconvert and the -W+k option that one needs to use -JX or -Jx as the projection to make it show up properly in Google Earth. Seems counter intuitive since the data ARE in geographical coordinates, but the error that is given says they are not. Then you need to use -JX (which is specifically listed as a ‘non geographical’ projection) in order to get it to work.

Agree that it’s a bit confusing but the question is not only that data is geographical. What matters here is that the image must in cartesian geographical. That is, not projected … but all maps are projected somehow.
Addressed in issue 3413