# [ncl-talk] Produce very big figure resolution -- google map tiles

Brammer, Alan P abrammer at albany.edu
Mon Aug 11 14:14:31 MDT 2014

```Rabah,

This message is unrelated to the ability of NCL to create such an image.  If it is able to go that big though it’s going to be an incredibly large image that takes a incredible amount of time to load in any browser. If not crash most peoples browsers due to the size of it.

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 trialled 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 = pi    ;  a global constant I have set, would need to be set; if run elsewhere !!!
res at mpLeftCornerLonF   := x / 2^z * 360.0 - 180.0
res at mpRightCornerLonF := (x+1) /2^z * 360.0 - 180.0
res at mpRightCornerLatF  :=  atan(sinh(math_pi * (1 - 2 * y / 2.^z))) * 180.0 / math_pi
res at mpLeftCornerLatF    :=  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))
system("mkdir "+name)
end if
end

mpres = True
mpres at mpLimitMode                 = "Corners"        ; method to zoom
mpres at mpProjection = "mercator"
mpres at mpPerimOn            = False          ; turn off map perimeter
mpres at mpOceanFillColor = -1; "darkslategray1"
mpres at mpInlandWaterFillColor = -1; "deepskyblue"
mpres at tmXTOn  = False
mpres at tmXBOn = False
mpres at tmYROn = False
mpres at tmYLOn = False
mpres at gsnMaximize= True
mpres at mpGeophysicalLineThicknessF = 2.
mpres at mpOutlineDrawOrder = "PostDraw"
mpres at mpOutlineBoundarySets  ="National"      ; Turn on country boundaries
mpres at mpFillOn = False

wkst = "png"
wkst at wkWidth = 268 ; 256 with 6 pixels for a border which will get cut off.
wkst at wkHeight = 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 = “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, 12222
abrammer at albany.edu<mailto:abrammer at albany.edu>
##############################

On Aug 9, 2014, at 10:51, Rick Brownrigg <brownrig at ucar.edu<mailto:brownrig at ucar.edu>> wrote:

Hi Rabah,

The image size is going to be constrained by the amount of memory on your system, and at 524288**2, I calculate 270G pixels!!  While there are a number of other factors that can limit the amount of memory available (user limits, older versions of NCL were 32-bit, etc.), I might expect you could at least double your 16384**2 image size. I suppose you could construct your large image in pieces and then tile them all together into on large image, but not only will that be a bit tedious to manage, I am also unaware of what out-of-core image tools might be available.  Finally, I don't know much about Google Map internals, but I would think it could deal with tiled imagery (?)

Good luck!
Rick

On Fri, Aug 8, 2014 at 11:13 PM, Rabah Hachelaf <hachelaf at sca.uqam.ca<mailto:hachelaf at sca.uqam.ca>> wrote:
Hi Rick,

Thanks for quick response :) ,

this happen with png workstation type and i want to attain 524288 X 524288 pixel resolution !! this is a big image i wonder if NCL can plot it.

2014-08-09 0:59 GMT-04:00 Rick Brownrigg <brownrig at ucar.edu<mailto:brownrig at ucar.edu>>:

Hi Rabah,

That is an interesting error message, indeed!  Does this happen with a specific workstation type (png, pdf, etc.), and what is the ideal resolution you would like to attain?

Rick

On Fri, Aug 8, 2014 at 9:52 PM, Rabah Hachelaf <hachelaf at sca.uqam.ca<mailto:hachelaf at sca.uqam.ca>> wrote:
Hi All,

- Can NCL produced a high resolution images?  the maximum what i can plot is
16384 X 16384, when i increase this pixel resolution i get this message error :
*****************************************************************************
GKS ERROR NUMBER -502 ISSUED FROM SUBROUTINE GCLRWK:
-- cairo driver error: error opening output file
*****************************************************
- I need those high resolution images to overlay it in google map.

Thanks for any suggestion.
--
------------------------------
Cordialement,
Best regards,
Rabah Hachelaf

--
------------------------------
Cordialement,
Best regards,
Rabah Hachelaf

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

--
------------------------------
Cordialement,
Best regards,
Rabah Hachelaf

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20140811/1f48659e/attachment.html
```

More information about the ncl-talk mailing list