[ncl-talk] convert png to nc file after plot command

Dave Allured - NOAA Affiliate dave.allured at noaa.gov
Thu Jul 30 09:48:06 MDT 2020


Zoe, I think what you really want is numeric regridding or interpolation.
NCL has many routines to support these numeric operations.  Yes this can
theoretically be done by going through the PNG image format, but that will
be very complicated and very inaccurate.

It is also possible that you just want to keep your original data grid, but
the program is somehow losing the original grid coordinates.  This is
common.  If something like this is happening, please let us know.

Please look through the NCL regridding examples page and see if there is
anything close to what you need.  If you want further advice, please
describe the data grid at input to your current plot routine (where you
said axes converted to something else).  Also describe the grid that you
want.


On Thu, Jul 30, 2020 at 4:17 AM zoe jacobs via ncl-talk <
ncl-talk at mailman.ucar.edu> wrote:

> Many thanks of both you .
> Dear Tabith the method you suggested actually work, but it does not give
> me what I need. I want to have exactly the plotted result but in nc format.
> Once I did your suggestion, I got a nc file, with no exact values of
> precipitation for each grid cell, and x and y axises converted to
> something else. Would any one have other suggestions please?
> Best wishes,
>
> On Wed, Jul 29, 2020 at 8:54 PM Tabish Ansari <tabishumaransari at gmail.com>
> wrote:
>
>> Hi Zoe,
>>
>> If you just want to store the resultant variable (monthly averages of
>> precipitation) to a new netcdf file, you can achieve that just by adding 2
>> lines of code before or after the plotting routine:
>>
>> b = addfile("myNCfile.nc", "c") ; open in create mode
>> b->prcClm = prcClm
>>
>> Cheers,
>>
>> Tabish
>>
>>
>> On Wed, 29 Jul 2020 at 14:16, Rick Brownrigg via ncl-talk <
>> ncl-talk at mailman.ucar.edu> wrote:
>>
>>> Hi,
>>>
>>> I don't believe there's a way to do this directly with NCL. However,
>>> "gdal" is a set of utilities that are extremely useful for dealing with
>>> geospatial (raster) data. In particular, the "gdal_translate" command can
>>> convert a png to netCDF. See example 9 at the link below for an example
>>> command line invocation to convert a jpg to netCDF.  Please be advised that
>>> gdal has dozens of optional libraries that can be used to build it, netCDF
>>> being one. The gdal_translate --format" command will list the formats
>>> supported by a given binary.
>>>
>>> http://ncl.ucar.edu/Applications/rgbacolor.shtml
>>>
>>> Rick
>>>
>>>
>>> On Wed, Jul 29, 2020 at 12:59 AM zoe jacobs via ncl-talk <
>>> ncl-talk at mailman.ucar.edu> wrote:
>>>
>>>> Dear all NCL users,
>>>> I have a script (attached) which gives me monthly averages of
>>>> precipitation and plots the result as png files. I wonder if there is any
>>>> command in NCL which could convert the png file to nc file after plot
>>>> command?
>>>> Please kindly advise me in this regard,
>>>> Many thanks in advance,
>>>> Best wishes,
>>>>
>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20200730/4e6a5794/attachment.html>


More information about the ncl-talk mailing list