Re: NCL library for creating Google Earth kml and kmz files

From: Ryan Pavlick <ryan.pavlick_at_nyahnyahspammersnyahnyah>
Date: Wed Sep 15 2010 - 08:28:12 MDT

Thanks, Álvaro.

I've added all of your recommendations to my TODO list and will
acknowledge you in the list of contributors.

I've also had many problems with convert and transparency.

 For instance, I'd like to be able make the oceans or land transparent
in kml_plot_groundoverlay. Unfortunately, Google Earth requires that
the specified latitude and longitude boundaries correspond with the
extent of the non-transparent pixels. Which turned out to be very
tricky to code, so I've put it off for now.

Cheers,
Ryan

On Wed, Sep 15, 2010 at 3:54 PM, "Álvaro M. Valdebenito B."
<alvaro.valdebenito@met.no> wrote:
> Dear Ryan,
>
> thanks for your efforts creating the kml/kmz library.
>
> I noticed that the labelbar prodiced by kml_add_labelbar
> calls to drawNDCGrid (line 757),
> so the labelbar.png has a the placement grid also.
>
> I would also suggest the addition of transparency to the convert call on
>  kml_add_labelbar, but my experiment with "convert -transparent white
> ..." failed to produce good results.
>
> I also noticed many lines as the following:
>   if (isatt(res,"kmlRefreshMode")) then
>     kml_entry = "<refreshMode>"+res@kmlRefreshMode+"</refreshMode>"
>     kml_setline(kml,kml_entry)
>     delete(kml_entry)
>   end if
> and
>   if (isatt(res,"kmlOverlayXY")) then
>     if (res@kmlOverlayXY)
>     kml_entry = "<overlayXY x="+kml@quote+res@kmlOverlayXYx+kml@quote+"
> y="+kml@quote+res@kmlOverlayXYy+kml@quote+"
> xunits="+kml@quote+res@kmlOverlayXYxunits+kml@quote+"
> yunits="+kml@quote+res@kmlOverlayXYyunits+kml@quote+"/>"
>     kml_setline(kml,kml_entry)
>     delete(kml_entry)
>     end if
>   end if
>
> I understand that the keeping the kml output and ncl code as close as
> possible is a design decision. Nevertheless, I would like to suggest the
> introduction of two specialized procedures to remove the repetitive
> code, which is prone to typos, as follows:
>
> procedure
> kml_setline_singletag(kml:string,kml_tags[*]:string,res[1]:logical)
> local kml_entry, atts, i
> begin
> ; add "single tag" lines to kml file
>
>   atts="kml"+str_capital(kml_tags)
>   do i=0,dimsizes(kml_tags)-1
>     if (isatt(res,atts(i)).and.dimsizes(res@$atts(i)$).eq.1) then
>       kml_entry = "<"+kml_tags(i)+">"+res@$atts(i)$+"</"+kml_tags(i)+">"
>       kml_setline(kml,kml_entry)
>     end if
>   end do
> end
>
> and
>
> undef("kml_setline_xytag")
> procedure kml_setline_xytag(kml:string,kml_tags[*]:string,res[1]:logical)
> local kml_entry, atts, i, tagsXY, attsXY, j
> begin
> ; add "XY tag" lines to kml file
>
>   tagsXY=(/"x","y","xunits","yunits"/)
>   atts="kml"+str_capital(kml_tags)
>   do i=0,dimsizes(kml_tags)-1
>     attsXY=atts(i)+tagsXY
>     if (isatt(res,atts(i)).and.dimsizes(res@$atts(i)$).eq.1.and.\
>         typeof(res@$atts(i)$).eq."logical".and.res@$atts(i)$.and.\
>         all(isatt(res,attsXY))) then
>       do j=0,dimsizes(attsXY)-1
>         attsXY(j)=kml@quote+res@$attsXY(j)$+kml@quote
>       end do
>       kml_entry="<"+kml_tags(i)+" "+str_join(tagsXY+"="+attsXY," ")+"/>"
>       kml_setline(kml,kml_entry)
>     end if
>   end do
> end
>
> Then, lines 101-141 will be reduced to
>    kml_tags=(/"refreshMode","refreshInterval",
> "viewRefreshMode","viewRefreshTime",\
>                "viewBoundScale","viewFormat","httpQuery"/)
>   kml_setline_singletag(kml,kml_tags,res)
>   delete(kml_tags)
>
> Then, lines 589-619 will be reduced to
>   kml_tags = (/"overlayXY","screenXY","rotationXY","sizeXY"/)
>   kml_setline_xytag(kml,kml_tags,res)
>   delete(kml_tags)
>
> Best wishes,
> Álvaro.
>
> ncl-talk-request@ucar.edu wrote:
>> Message: 3
>> Date: Tue, 14 Sep 2010 00:22:44 +0200
>> From: Ryan Pavlick <ryan.pavlick@gmail.com>
>> Subject: NCL library for creating Google Earth kml and kmz
>>       files
>> To: ncl-talk@ucar.edu
>> Message-ID:
>>       <AANLkTi=6SEn5ZKGiFd8bNpZ6S8yyBqMyfp2-i4sTp4K9@mail.gmail.com>
>> Content-Type: text/plain; charset=ISO-8859-1
>>
>> NCLers,
>>
>> I am developing an NCL library for creating kml/kmz files to visualize
>> geographic data in Earth browsers (e.g. Google Earth).
>>
>> You can see my progress so far along with several example scripts and
>> output files at: http://github.com/rpavlick/kmlncl
>>
>> This is very much an alpha release. It has plenty of bugs and limited
>> documentation. Nor is it feature complete.
>>
>> Most KML elements are basically working though (Document, Folder,
>> Placemark, Point, LineString, Polygon, GroundOverlay, ScreenOverlay,
>> PhotoOverlay, NetworkLink, LookAt, Camera, some Style elements).
>>
>> If you find bugs or have feature ideas, just respond to this thread in
>> ncl-talk (I hope this is ok with the admins). There is also an issue
>> tracker on the github project page.  Although, I make no promises
>> about speedy responses, this is a spare-time project.
>>
>> Cheers,
>> Ryan
>>
>
> --
> Álvaro M. Valdebenito B., Dr. rer. nat.       alvaro.valdebenito@met.no
> Air Pollution Section/Research Department     Tel. +47-2296 3397
> Norwegian Meteorological Institute            http:\\www.met.no
> P.O. Box 43 Blindern, 0313 Oslo, NORWAY       http:\\www.emep.int/CWF
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>

-- 
------------------------------------------
Ryan Pavlick
Doctoral Student
Biospheric Theory and Modellling Group
Max Planck Institute for Biogeochemistry
mail: P.O. Box 10 01 64, D-07701 Jena, Germany
email: rpavlick@bgc-jena.mpg.de
phone: +49.36.41.57.6262
web: http://gaia.mpg.de
------------------------------------------
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Sep 15 08:28:44 2010

This archive was generated by hypermail 2.1.8 : Wed Oct 06 2010 - 09:53:35 MDT