<p>The coordinates defined in <a href="https://www.ncdc.noaa.gov/data-access/model-data/model-datasets/global-forcast-system-gfs" rel="nofollow noreferrer">Global Forecast System (GFS -0.5º Degree)</a> data defined somewhat unusual. In the GFS, longitudes and latitude contains 720 and 361 values respectively. Therefore to convert them to a common geographic coordinate system follow the procedure below:</p>

<p>Suppose you are looking for index of coordinate pairs (36.5, -78.5) in the GFS data:</p>

<pre><code>your_lat_start = x
your_lat_end = x
your_lon_start = x
your_lon_end = x
your_dataset = half_degree_gfs_dataset

lat_index_start = np.where(np.array(your_dataset['lat'][:].data)==your_lat)[0][0]
lat_index_end = np.where(np.array(your_dataset['lat'][:].data)==your_lat_end)[0][0] 
lon_index_start = np.where(np.array(your_dataset['lon'][:].data)==your_lon_start)[0]
lon_index_end = np.where(np.array(your_dataset['lon'][:].data)==your_lon_end)[0][0]

if lat_index_start &gt; lat_index_end:
    lat_index_start, lat_index_end = lat_index_end, lat_index_start + 1 
    lon_index_start, lon_index_end = lon_index_start , lon_index_end + 1

dataset[var_name][:,lat_index_start:lat_index_end, lon_index_start:lon_index_end].data
</code></pre>

CC BY-SA 4.0
2019-07-16T01:40:14.627Z
2019-07-16T06:14:24.020Z
2019-07-16T06:14:24.020Z
morteza omidipoor
<p>** <strong>All of the links given with times will need to be adjusted to current dates if reading this at later times or else will appear dead</strong> **</p>

<p>Once upon a time I dealt with such files, but not in quite a few years... and Google wasn't the best help at first in finding documentation on what the .ascii is exactly... but thanks to Kevin Goebbert's code <a href="https://github.com/rsignell-usgs/notebook/blob/master/Cartopy/4-panel-plot.py" rel="nofollow noreferrer">here</a>, I was able to find the description page for the model in question is located by removing the .ascii and inputs (and thus <a href="http://nomads.ncep.noaa.gov:9090/dods/gfs_0p50/gfs20170707/gfs_0p50_12z" rel="nofollow noreferrer">here</a>):</p>

<p>And so right now it lists:</p>

<pre><code>Longitude:  
0.00000000000°E to 359.50000000000°E
     (720 points, avg. res. 0.5°)
Latitude:   
-90.00000000000°N to 90.00000000000°N
     (361 points, avg. res. 0.5°)
Altitude:   
1000.00000000000 to 1.00000000000
     (47 points, avg. res. 21.717)
Time:   
12Z07JUL2017 to 12Z17JUL2017
     (81 points, avg. res. 0.125 days) 
</code></pre>

<p>The p50 indicates a grid space of only half a degree in that file, so you couldn't actually use your point in this moel.</p>

<p>However, use <a href="http://nomads.ncep.noaa.gov:9090/dods/gfs_0p25/gfs20170707/gfs_0p25_12z.ascii?tmax2m[0:0][0:0][0:0]" rel="nofollow noreferrer">the 0.25 resolution instead</a> (<a href="http://nomads.ncep.noaa.gov:9090/dods/gfs_0p25/gfs20170707/gfs_0p25_12z" rel="nofollow noreferrer">description</a>):</p>

<p>So first is time first is time, the second is longitude points starting at the Prime Meridian and going east, and the third is latitude starting at the South Pole and going north.  (GFS time steps have always been a mire... but based on <a href="http://nomads.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/gfs.2017062706/" rel="nofollow noreferrer">this full list</a> of data files and the info page previously given, it indeed appears the data provided here is just every 3 hours for the first 10 days.)</p>

<p>So to pick your value for the second input, it'd be something like  </p>

<blockquote>
  <p>ifpositive: (longitude)*4 - 1
  ifnegative: (180+longitude)*4 + 719</p>
</blockquote>

<p>And for latitude:  </p>

<blockquote>
  <p>360+(latitude)*4</p>
</blockquote>

<p>And so if I didn't make a mistake, that'd be <a href="http://nomads.ncep.noaa.gov:9090/dods/gfs_0p25/gfs20170707/gfs_0p25_12z.ascii?tmax2m[0:80][505:505][1124:1124]" rel="nofollow noreferrer">this point</a> (lat gridpoint 505, lon gridpoint 1124).</p>

CC BY-SA 3.0
2017-07-11T06:09:09.000Z
2017-07-11T06:09:09.000Z
JeopardyTempest
<p>Looking at this GFS <a href="http://nomads.ncep.noaa.gov:9090/dods/gfs_0p50/gfs20170707/gfs_0p50_12z.ascii?tmax2m[0:2][124:128][279:283]" rel="nofollow noreferrer">http://nomads.ncep.noaa.gov:9090/dods/gfs_0p50/gfs20170707/gfs_0p50_12z.ascii?tmax2m[0:2][124:128][279:283]</a></p>

<p>The range defined by the second and third set of brackets specify the grid coordinates, however I'm not sure how to convert between what NOAA is using and the common geographic coordinate system. </p>

<p>What would the NOAA equivalent be for this coordinate pair: (36.25, -78.75)?</p>

CC BY-SA 3.0
2017-07-10T16:37:27.120Z
Hi Rafael, I edited the question to make it more clear as to what I think you are asking.  Please revert it back if this is not what you mean.
f.thorpe
<weather-forecasting><gfs>
How do I convert a latitude/longitude coordinate to a NOAA GFS grid cell location?
Rafael
# How do I convert a latitude/longitude coordinate to a NOAA GFS grid cell location?

(Asked by: username_0 on 2017-07-10)

Looking at this GFS <http://nomads.ncep.noaa.gov:9090/dods/gfs_0p50/gfs20170707/gfs_0p50_12z.ascii?tmax2m[0:2][124:128][279:283]>

The range defined by the second and third set of brackets specify the grid coordinates, however I'm not sure how to convert between what NOAA is using and the common geographic coordinate system.

What would the NOAA equivalent be for this coordinate pair: (36.25, -78.75)?

**Tags:** weather-forecasting, gfs

> **Comments:**
> **username_1**: Hi username_0, I edited the question to make it more clear as to what I think you are asking.  Please revert it back if this is not what you mean.  

---

## 2 answers

### Answer by username_2 on 2019-07-16. Score: 1

The coordinates defined in [Global Forecast System (GFS -0.5º Degree)](https://www.ncdc.noaa.gov/data-access/model-data/model-datasets/global-forcast-system-gfs) data defined somewhat unusual. In the GFS, longitudes and latitude contains 720 and 361 values respectively. Therefore to convert them to a common geographic coordinate system follow the procedure below:

Suppose you are looking for index of coordinate pairs (36.5, -78.5) in the GFS data:

```
your_lat_start = x
your_lat_end = x
your_lon_start = x
your_lon_end = x
your_dataset = half_degree_gfs_dataset

lat_index_start = np.where(np.array(your_dataset['lat'][:].data)==your_lat)[0][0]
lat_index_end = np.where(np.array(your_dataset['lat'][:].data)==your_lat_end)[0][0] 
lon_index_start = np.where(np.array(your_dataset['lon'][:].data)==your_lon_start)[0]
lon_index_end = np.where(np.array(your_dataset['lon'][:].data)==your_lon_end)[0][0]

if lat_index_start > lat_index_end:
    lat_index_start, lat_index_end = lat_index_end, lat_index_start + 1 
    lon_index_start, lon_index_end = lon_index_start , lon_index_end + 1

dataset[var_name][:,lat_index_start:lat_index_end, lon_index_start:lon_index_end].data

```


---

### Answer by username_3 on 2017-07-11. Score: 1

\*\* **All of the links given with times will need to be adjusted to current dates if reading this at later times or else will appear dead** \*\*

Once upon a time I dealt with such files, but not in quite a few years... and Google wasn't the best help at first in finding documentation on what the .ascii is exactly... but thanks to Kevin Goebbert's code [here](https://github.com/rsignell-usgs/notebook/blob/master/Cartopy/4-panel-plot.py), I was able to find the description page for the model in question is located by removing the .ascii and inputs (and thus [here](http://nomads.ncep.noaa.gov:9090/dods/gfs_0p50/gfs20170707/gfs_0p50_12z)):

And so right now it lists:

```
Longitude:  
0.00000000000°E to 359.50000000000°E
     (720 points, avg. res. 0.5°)
Latitude:   
-90.00000000000°N to 90.00000000000°N
     (361 points, avg. res. 0.5°)
Altitude:   
1000.00000000000 to 1.00000000000
     (47 points, avg. res. 21.717)
Time:   
12Z07JUL2017 to 12Z17JUL2017
     (81 points, avg. res. 0.125 days) 

```

The p50 indicates a grid space of only half a degree in that file, so you couldn't actually use your point in this moel.

However, use [the 0.25 resolution instead](http://nomads.ncep.noaa.gov:9090/dods/gfs_0p25/gfs20170707/gfs_0p25_12z.ascii?tmax2m[0:0][0:0][0:0]) ([description](http://nomads.ncep.noaa.gov:9090/dods/gfs_0p25/gfs20170707/gfs_0p25_12z)):

So first is time first is time, the second is longitude points starting at the Prime Meridian and going east, and the third is latitude starting at the South Pole and going north. (GFS time steps have always been a mire... but based on [this full list](http://nomads.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/gfs.2017062706/) of data files and the info page previously given, it indeed appears the data provided here is just every 3 hours for the first 10 days.)

So to pick your value for the second input, it'd be something like

> ifpositive: (longitude)\*4 - 1
> ifnegative: (180+longitude)\*4 + 719

And for latitude:

> 360+(latitude)\*4

And so if I didn't make a mistake, that'd be [this point](http://nomads.ncep.noaa.gov:9090/dods/gfs_0p25/gfs20170707/gfs_0p25_12z.ascii?tmax2m[0:80][505:505][1124:1124]) (lat gridpoint 505, lon gridpoint 1124).


---

