[ncl-talk] [EXTERNAL] Re: Swapped x, y coordinates of shapefile?

Holman, Kathleen D kholman at usbr.gov
Mon Jan 25 16:01:37 MST 2021


Rick,

Yes, this is exactly my situation.  I am using a version installed from conda.  I managed to create a copy of the shapefile_utils.ncl function and swapped out all the x, y calls.  So far, this appears to have worked.  Though, I do not know why this version is different than the non-conda-installed version.

Thank you for replying.

Katie Holman, PhD
Meteorologist
Technical Service Center
Bureau of Reclamation
303-445-2571
________________________________
From: Rick Brownrigg <brownrig at ucar.edu>
Sent: Monday, January 25, 2021 3:53 PM
To: Holman, Kathleen D <kholman at usbr.gov>
Cc: ncl-talk at mailman.ucar.edu <ncl-talk at mailman.ucar.edu>
Subject: [EXTERNAL] Re: [ncl-talk] Swapped x, y coordinates of shapefile?




 This email has been received from outside of DOI - Use caution before clicking on links, opening attachments, or responding.



Hi,

Yes, there have been reports of this with NCL v6.6.2 as distributed via conda (does that describe your circumstances?)  I don't know the root cause nor am I in a position to investigate. However, as a kludge, you can certainly swap the shapefile's x/y coordinates in any of a number of ways, perhaps something like:
     myShpFile = addfile(....)
     ...
     theActualXCoord = myShpFile->y   ; Swap X/Y to fix known bug...
     theActualYCoord = myShpFile->x

Hope that helps...
Rick

On Mon, Jan 25, 2021 at 3:30 PM Holman, Kathleen D via ncl-talk <ncl-talk at mailman.ucar.edu<mailto:ncl-talk at mailman.ucar.edu>> wrote:
Hello,

I am trying to use the shapefile_mask_data() function to mask precipitation data (time, lat, lon) using boundaries defined in a shapefile, subs_buff_mod.shp.  When I plot the shapefile in ArcGIS, the spatial extent appears correct (see screenshot).  This basin is in Colorado, so the latitude extent should be between 40 and 40.5 north, while the longitude extent should be between -106 and -105 east.  Unfortunately, the mask function continues to produce missing values, and I *think* the reason for this is because the x and y coordinates of the shapefile are getting swapped when I import the shapefile into NCL.  Here is a snippet of text from the print_shapefile_info() command.  The latitude and longitude ranges are swapped from what they should be for Colorado, but again, the shapefile properly plots in ArcGIS.  Can I swap the coordinates somehow?  Any idea where this happening or how to remedy this?

(0)     ======================================================================
(0)     Filename: "../GIS/subs_buff_mod.shp"
(0)        Geometry type: polygon
(0)        # of features: 8
(0)        Min/max lat:   -105.82/-105.45
(0)        Min/max lon:     40.23/  40.50
(0)        Variable names and their types:
(0)            geometry : integer
(0)            segments : integer
(0)            x : double
(0)            y : double
(0)            Shape_Leng : double
(0)            Shape_Area : double
(0)            HydroID : int64
(0)            Name : string
(0)            BUFF_DIST : double
(0)            ORIG_FID : int64
(0)     ======================================================================

Here are the min/max values of the latitude and longitude coordinates associated with the precipitation data.

(0)     latitude (degrees_north) : min=36.532672   max=50.232124
(0)
(0)     longitude (degrees_east) : min=-114.7339440000123   max=-90.00160000003234


[cid:1773bbb6f2dcb971f161]

Thank you,

Katie Holman, PhD
Meteorologist
Technical Service Center
Bureau of Reclamation
303-445-2571
_______________________________________________
ncl-talk mailing list
ncl-talk at mailman.ucar.edu<mailto:ncl-talk at mailman.ucar.edu>
List instructions, subscriber options, unsubscribe:
https://mailman.ucar.edu/mailman/listinfo/ncl-talk<https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmailman.ucar.edu%2Fmailman%2Flistinfo%2Fncl-talk&data=04%7C01%7Ckholman%40usbr.gov%7C1ac3f783cb524e930b3e08d8c1841af1%7C0693b5ba4b184d7b9341f32f400a5494%7C0%7C0%7C637472120426520274%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=76%2FW6jsZ3aRfALllRUb9nSJjaN%2BA8N3zDnU6dioVYbk%3D&reserved=0>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20210125/25739555/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 655381 bytes
Desc: image.png
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20210125/25739555/attachment-0001.png>


More information about the ncl-talk mailing list