[ncl-talk] How to convert a contour map to a raster file from a nc file?
Dave Allured - NOAA Affiliate
dave.allured at noaa.gov
Wed Jun 10 13:03:19 MDT 2020
Okay, I understand. There are many possible reasons for can not download
properly, and I would rather not attempt to remote diagnose your systems.
Try the following as both a shortcut and to get some diagnostic
information. This is an attempt to circumvent unknown problems with a
mysterious remote file structure, by extracting a simplified file with
known behavior.
On the remote server, open that remote file in NCL. Get a single gridded
variable that is the 2-D data that you want for your initial test case.
This will probably be the same grid that you were plotting in your initial
example. Ensure that this variable has attached lat and lon coordinates.
All of this can be done with your original plotting program, you do not
even need to write new code lines so far. If there are parts you do not
understand, please ask.
Now still in NCL, create a new Netcdf data file. Write the single grid
with attached coordinates to this new file, then exit NCL. Here, it is
easier to show than explain.
newfile = addfile ("xdata.nc", "c")
newfile->x = x
exit
Now see if you can easily download this new small Netcdf file. If this
works, then you will have the grid that you want locally, in a format that
should be readable by Panoply, NCL, and GIS programs.
On Wed, Jun 10, 2020 at 12:11 PM zoe jacobs <zoejacobs1990 at gmail.com> wrote:
> Dear Dave,
> I meant that I have a nc file which is an output of a model. I can plot a
> contour map from that file through a remote server. I have both the model
> and NCL on a remote server. However, once I copy that nc file from remote
> server to my desktop Panoply cannot read that nc file.
> I hope it is clear now.
> Best wishes,
>
> On Wed, Jun 10, 2020 at 10:32 PM Dave Allured - NOAA Affiliate <
> dave.allured at noaa.gov> wrote:
>
>> This is a bit confusing. Are you saying you can run NCL on your remote
>> server, and make some kind of smaller file that you can then download? Or
>> are you running NCL locally and reading this Netcdf file through a server
>> path or a URL?
>>
>>
>> On Wed, Jun 10, 2020 at 10:45 AM zoe jacobs <zoejacobs1990 at gmail.com>
>> wrote:
>>
>>> Dear Dave,
>>> Many thanks for your explanations. My problem is that my nc file is just
>>> known by the remote server I work at. After copying the file to my desktop,
>>> and opening it by Panoply , it is no longer valid as a nc file ! . So I
>>> look for a way to sort it out. What can I do please?
>>> Many thanks in advance,
>>> Best wishes,
>>>
>>> On Tue, Jun 9, 2020 at 10:19 PM Dave Allured - NOAA Affiliate <
>>> dave.allured at noaa.gov> wrote:
>>>
>>>> According to this article, your original Netcdf file is already in a
>>>> GIS raster format.
>>>>
>>>> https://en.wikipedia.org/wiki/GIS_file_formats
>>>>
>>>> You should be able to skip the plotting step, and use the Netcdf file
>>>> directly in ArcGIS. Minor adjustments may be needed for coordinates and
>>>> area subsetting. My guess is that this is really what you want to do.
>>>>
>>>> The expression "raster format" is problematical because it is used for
>>>> at least three fundamentally different things in computer graphics.
>>>> Generically, this refers to common "bit-mapped" image file formats such as
>>>> png, gif, and jpeg. In GIS and satellite imagery, it refers to a variety
>>>> of gridded data formats, including Netcdf. And NCL has a specialized
>>>> usage, referring to the rendering of gridded data as visibly rectangular
>>>> blocks when making plots, rather than smooth or segmented outlines. It
>>>> would be nice if these nuances of terminology were discussed in NCL
>>>> documentation, but, um, they are not.
>>>>
>>>> To make things more confusing, some of these formats can be "rendered"
>>>> in one of the other formats, often losing software compatibility in the
>>>> process. The picture on your example raster_4.ncl is a perfect example of
>>>> this. That is an NCL "raster plot" projected onto a PNG "raster format"
>>>> image file for website display. The "pixels" before and after are
>>>> completely different. So be careful about which usage you are discussing.
>>>>
>>>>
>>>> On Tue, Jun 9, 2020 at 10:06 AM zoe jacobs via ncl-talk <
>>>> ncl-talk at mailman.ucar.edu> wrote:
>>>>
>>>>> Dear all NCL users,
>>>>>
>>>>> I would like to create a map plot in raster format from a nc file . So
>>>>> I can then use it on ArcGIS. Please have a look at the following link
>>>>> https://www.ncl.ucar.edu/Applications/raster.shtml , example
>>>>> easter_4.ncl . I already could plot a contour map from my nc file,
>>>>> and I just wonder which command should I add to my script to convert my
>>>>> plot to be in a raster format?
>>>>> Would you please kindly advise me in this regard?
>>>>> Best wishes,
>>>>>
>>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20200610/66c825b1/attachment.html>
More information about the ncl-talk
mailing list