[ncl-talk] Convert data frame to spatial coordinates

Rick Brownrigg brownrig at ucar.edu
Mon Nov 11 21:14:16 MST 2019


Follow up to the scriptlet I sent -- why it doesn't work:

Short story: it appears that (for some versions (?) of proj4) the
source/destination proj4-strings require an ellipsoid definition. So in the
script I sent, if you replace these lines:

  srcProj = "+proj=lonlat"
  dstProj = "+proj=eqc"

with something like:

  srcProj = "+proj=lonlat +ellps=sphere"
  dstProj = "+proj=eqc +ellps=sphere"

it then works for me across two distinct versions of NCL (6.3.0 and 6.2.2)
Another reasonable alternative to "sphere" would be "WGS84". More
generally, in your destination proj4 string, you will want to pay careful
attention to the intended projection parameters -- many non-global
projections incorporate specific ellipsoids, standard parallels, meridians,
and even false eastings/northings. And by default, the unit of projected
coordinates in proj4 is meters.

Long story:
  Short story to the long story: "I don't know"
  Full version: "I don't know". The original script I sent *should* have
worked, and indeed does work on my home system. I've used proj4-strings
without specifying +ellps  many times in the past. Evidently, some versions
of proj4 require the ellipsoid, others have a default (?)  In any case, my
access to NCL testing platforms is now limited, and I don't have the time
available to diligently track down which versions of proj4 do/do-not
require the ellipsoid string (I'm no longer part of the NCL dev-team).

I hope that helps...
Rick

On Mon, Nov 11, 2019 at 12:05 PM Vanúcia Schumacher <
vanucia-schumacher at hotmail.com> wrote:

> Hi Rick
>
> Indeed returns an error. I wait without problems. Take your time.
> If it works the "proj4 strings" will pass x/y/z arrays associated with
> the value of the variable at each lat-lon point? That would be exactly the
> idea.
>
> Thank you so much for the support.
> ------------------------------
> *De:* Rick Brownrigg <brownrig at ucar.edu>
> *Enviado:* segunda-feira, 11 de novembro de 2019 15:15
> *Para:* Vanúcia Schumacher <vanucia-schumacher at hotmail.com>
> *Cc:* ncl-talk at ucar.edu <ncl-talk at ucar.edu>
> *Assunto:* Re: [ncl-talk] Convert data frame to spatial coordinates
>
> Hi,
>
> The attached scriptlet is a framework for what the interface looks like.
> However it does *not* work for me at the moment. The general idea is that
> you set so-called "proj4 strings" that describe the source and destination
> projections, and pass in x/y/z arrays. The function transform_coordinate
> returns the transformed coordinates back in the x/y/z arrays.
>
> More on proj4:
>
>     https://proj.org/usage/index.html
>
> I don't know why this is not working -- I've done this a number of times.
> I will need to wrangle a debugger around the code to determine the issue,
> and I unfortunately do not have access to such an environment until I get
> home this evening.
>
> Rick
>
>
> On Mon, Nov 11, 2019 at 8:46 AM Vanúcia Schumacher <
> vanucia-schumacher at hotmail.com> wrote:
>
> My data is in ascii format (e.g. attached). Yes, I would like to use some
> kind of cartographic projection, type Cylindrical equidistant or Mercator.
> That would be exactly what this library does (Proj4).
> The specific region of the projection would be Brazil, maybe I will use
> some shapefile to cut some specific region.
> It would be great to have this interface. Let me know everything you need
> to work out.
> Thanks for the support
> ------------------------------
> *De:* Rick Brownrigg <brownrig at ucar.edu>
> *Enviado:* segunda-feira, 11 de novembro de 2019 12:16
> *Para:* Vanúcia Schumacher <vanucia-schumacher at hotmail.com>
> *Cc:* ncl-talk at ucar.edu <ncl-talk at ucar.edu>
> *Assunto:* Re: [ncl-talk] Convert data frame to spatial coordinates
>
> To me, points with lat/lon are spatial data with coordinates (?)  Do you
> mean you want the coordinates in some kind of cartographic projection, such
> as Lambert Conformal, UTM, Mercator, etc?  If so, NCL has an undocumented
> interface to the Proj4 casrtographic projection library. I can elaborate
> further, but you need to know all the projection parameters involved
> (standard parallels, meridian,  etc.).
>
> Rick
>
>
>
> On Mon, Nov 11, 2019 at 8:11 AM Vanúcia Schumacher via ncl-talk <
> ncl-talk at ucar.edu> wrote:
>
> Hi users,
>
> I would like to know if NCL or NCL-Phyton has any function for converting
> points (just lat and lon) to spatial data with coordinates?
>
> Data frame like this:
> type,year,mon,day,hr,min,seg,lat,lon,var
> CGC,2015,8,29,0,0,1,-5.0811541,-52.1089013,-11538
> ...
> ...
> ...
>
> Thanks for any support
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> 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/20191111/525c50f3/attachment.html>


More information about the ncl-talk mailing list