# Re: calculating mercator coordinates

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Thu Apr 25 2013 - 14:48:02 MDT

I should have added that the formula for getting the y index is a little more complicated because vpYF specifies the top of the viewport rather than the bottom, so

iy = ((data_y - (y -h)) / h) * (nlat -1)

On Apr 25, 2013, at 2:39 PM, David Brown <dbrown@ucar.edu> wrote:

> Hi Micah,
> There is no specific function to do this in NCL. However, it is possible to do what you want with a bit of effort. The recipe goes something like this:
> Create a map using the native projection of the data. That is, a mercator map with corners as specified by the metadata (left: lat 15, lon 284.5 right: lat 22.005, 297.491).
> Discover the location and width and height of the viewport using getvalues;
> getvalues mapid
> "vpXF" : x
> "vpYF" y
> "vpWidthF" : w
> "vpHeightF" : h
> end get values
>
> Now you can use the function datatondc to find the NDC locations of any data location within the boundaries of the map.
>
> The index values of the coordinate can now be determined using a simple proportion:
>
> ix =((data_x - x) / w) * (nlon -1)
>
> Of course this produces a floating point number which usually lies in between two indexes.
>
> Hope this helps.
> -dave
>
> On Apr 24, 2013, at 2:42 PM, Micah Sklut <micahs2005@gmail.com> wrote:
>
>> Hi there,
>>
>> I have a dataset that is from a mercator projection.
>> So, my usual routine to find the data coordinates of a particular lat/lon don't exactly work, since the grid isn't equidistant.
>>
>> Are there any NCL function that will calculate or convert lat/lon from mercator data.
>>
>> Example. lat 38.5, lon -100.
>> What coordinates in my dataset contains this point.
>> Lat/Lon attributes are below.
>>
>> float lat_0 ( lat_0 )
>> long_name : latitude
>> GridType : Mercator Projection Grid
>> units : degrees_north
>> Dj : 2.5
>> Di : 2.5
>> Lo2 : 297.491
>> La2 : 22.005
>> Lo1 : 284.5
>> La1 : 15
>>
>> float lon_0 ( lon_0 )
>> long_name : longitude
>> grid_type : Mercator
>> units : degrees_east
>> Dj : 2.5
>> Di : 2.5
>> Lo2 : 297.491
>> La2 : 22.005
>> Lo1 : 284.5
>> La1 : 15
>>
>>
>> Thank you,
>>
>> --
>> Micah
>>
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Apr 25 14:48:17 2013

This archive was generated by hypermail 2.1.8 : Fri Apr 26 2013 - 17:10:25 MDT