[ncl-talk] creating tile layers from ncl map images
Micah Sklut
micahs2005 at gmail.com
Thu Oct 9 18:44:42 MDT 2014
Very cool Alan, thank you very much for passing on your NCL script.
One thing that is unclear to me, however, is how you code the geo
coordinates into the tile layer. Is this something that is just set in your
web map script? In all of the tutorial examples I have seen, it just simply
sets the tile layer directory, and thats it... So, I'm confused in where
the geo-cooridnates are communicated.
Thanks,
Micah
On Thu, Oct 9, 2014 at 7:19 PM, Alan Brammer <abrammer at albany.edu> wrote:
> Heres a reply I sent to someone on a vaguely similar thread a little while
> back. The number of images you plot increases quickly so above a zoom of ~
> 3 or 4 it can take a long time to work through them all. There may be
> (probably is) a better way to do it but this worked for me. Haven't used it
> for a while so it may not work the same in recent versions. Unfortunately
> the ncl-talk archive machine has changed all the resources so you'll need
> to do some find/replace to get it to work.
>
>
>
> I believe there was a KML function development somewhere in the archives of NCL talk. Not sure of the details there, but could be worth a google.
>
> I tested the tile idea a while back though and it was reasonably successful. Though it can require a lot of images this way and can therefore take a long time to plot them all up.
> Below is my test script, I put together a while back to trial this idea (using 6.1.2 at the time). The corners are the key part and are based on coordinate info from this page, which is very helpful for understanding how map tiling works, if you choose that route. http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/
>
>
> Good luck,
> Alan.
>
>
>
> undef("setlatlon")
> procedure setlatlon(res, z,x,y)
> begin
> math_pi = 355/113. ; The Approx for pi I use. res at mpLeftCornerLonF <http://mailman.ucar.edu/mailman/listinfo/ncl-talk> := x / 2^z * 360.0 - 180.0res at mpRightCornerLonF <http://mailman.ucar.edu/mailman/listinfo/ncl-talk> := (x+1) /2^z * 360.0 - 180.0res at mpRightCornerLatF <http://mailman.ucar.edu/mailman/listinfo/ncl-talk> := atan(sinh(math_pi * (1 - 2 * y / 2.^z))) * 180.0 / math_pires at mpLeftCornerLatF <http://mailman.ucar.edu/mailman/listinfo/ncl-talk> := atan(sinh(math_pi * (1 - 2 * (y+1) / 2.^z))) * 180.0 / math_pi
> end
>
>
> undef("check_dir")
> procedure check_dir(name)
> begin
> if(.not.isfilepresent(name)) ;; this should maybe be fileexists() now.
> system("mkdir "+name)
> end if
> end
>
>
>
> mpres = Truempres at mpLimitMode <http://mailman.ucar.edu/mailman/listinfo/ncl-talk> = "Corners" ; method to zoommpres at mpProjection <http://mailman.ucar.edu/mailman/listinfo/ncl-talk> = "mercator"mpres at mpPerimOn <http://mailman.ucar.edu/mailman/listinfo/ncl-talk> = False ; turn off map perimetermpres at mpOceanFillColor <http://mailman.ucar.edu/mailman/listinfo/ncl-talk> = -1; "darkslategray1"mpres at mpInlandWaterFillColor <http://mailman.ucar.edu/mailman/listinfo/ncl-talk> = -1; "deepskyblue"mpres at tmXTOn <http://mailman.ucar.edu/mailman/listinfo/ncl-talk> = Falsempres at tmXBOn <http://mailman.ucar.edu/mailman/listinfo/ncl-talk> = Falsempres at tmYROn <http://mailman.ucar.edu/mailman/listinfo/ncl-talk> = Falsempres at tmYLOn <http://mailman.ucar.edu/mailman/listinfo/ncl-talk> = Falsempres at gsnMaximize <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>= Truempres at mpGeophysicalLineThicknessF <http://mailman.ucar.edu/mailman/listinfo/ncl-talk> = 2.mpres at mpOutlineDrawOrder <http://mailman.ucar.edu/mailman/listinfo/ncl-talk> = "PostDraw"mpres at mpOutlineBoundarySets <http://mailman.ucar.edu/mailman/listinfo/ncl-talk> ="National" ; Turn on country boundariesmpres at mpFillOn <http://mailman.ucar.edu/mailman/listinfo/ncl-talk> = False
>
>
>
>
> wkst = "png"wkst at wkWidth <http://mailman.ucar.edu/mailman/listinfo/ncl-talk> = 268 ; 256 with 6 pixels for a border which will get cut off.wkst at wkHeight <http://mailman.ucar.edu/mailman/listinfo/ncl-talk> = 268 ;
>
> dir = “/plotting_directory/“
>
> do z = 2,4 ; Zoom level of maps.
> check_dir(dir+z) ; make sure there is a directory to put the image in.
>
> do x=0,(2^z)-1 ;
> check_dir(dir+z+"/"+x+"/“) ; make sure there is a directory to put the image in.
>
> do y=0,(2^z)-1
> wks = gsn_open_wks(wkst, dir+z+"/"+x+"/"+y ) ;; zoom/x/y.png directory structure is how most tile based utilites expect them.
> setlatlon(mpres, z,x,y) ;; Set corners of map based on zoom level, X, and Y locations.
> if(z.ge.4)
> mpres at mpDataBaseVersion <http://mailman.ucar.edu/mailman/listinfo/ncl-talk> = “MediumRes” ;; personal preference on plotting time vs coast line representation.
> end if
> map = gsn_csm_map(wks,mpres) ;; create map.
> system("mogrify -fuzz 2% -transparent white -shave 6x6 "+dir+z+"/"+x+"/"+y+".png”)
> ;; Call imagemagick to make background transparent (6.2. may have made this redundant) and trim the 6pixel border that NCL loves ( may be machine dependent );
> end do ; y- loop
>
> end do ; x-loop
>
> end do ; z-loop
>
>
>
>
>
>
>
>
>
> ##############################
> Alan Brammer,
> PhD candidate,
>
> Department of Atmospheric and Environmental Sciences,
> University at Albany, State University of New York, Albany, NY, 12222abrammer at albany.edu <http://mailman.ucar.edu/mailman/listinfo/ncl-talk><mailto:abrammer at albany.edu <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>>
> ##############################
>
>
> On Thu, Oct 9, 2014 at 5:18 PM, Micah Sklut <micahs2005 at gmail.com> wrote:
>
>> Hi,
>>
>> I was wondering if anyone has gone through the process of creating a tile
>> image layer from your NCL maps to use in a web software application or
>> otherwise?
>>
>> If so, what software did you use?
>>
>> Many of the popular mapping applications allow you to import your own
>> tile layers, like Google Maps. I have been looking at the open source
>> software leaflet - leafletjs.com. I am just struggling to find the most
>> appropriate way to create the tile layer from my NCL images. For my
>> purposes it has to be a command line tool for automation.
>>
>> As an example. Lets say I created a world wide map of precipitation. This
>> map would be viewable on the global scale, and then navigated or zoomed
>> into any area for greater detail.
>>
>> Thank you for any suggestions,
>>
>> --
>> Micah Sklut
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>
--
Micah Sklut
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20141009/e9d6f8fd/attachment.html
More information about the ncl-talk
mailing list