# Grid Interpolation of Data from Polar-Orbiting Satellites

**URL:** <https://discourse.julialang.org/t/grid-interpolation-of-data-from-polar-orbiting-satellites/10080>\
**Category:** New to Julia\
**Tags:** interpolations, geo, gmt\
**Created:** [March 30, 2018, 11:42pm UTC](https://discourse.julialang.org/t/grid-interpolation-of-data-from-polar-orbiting-satellites/10080 "2018-03-30T23:42:02Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![Balinus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/balinus/32/243_2.png) [@Balinus](https://discourse.julialang.org/u/Balinus)\
**Post date:** [May 9, 2018, 1:34pm UTC](https://discourse.julialang.org/t/grid-interpolation-of-data-from-polar-orbiting-satellites/10080/21 "2018-05-09T13:34:12Z")

</div>

Still haven’t found the time! 😕 It’s on my to-do list!

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [May 9, 2018, 1:40pm UTC](https://discourse.julialang.org/t/grid-interpolation-of-data-from-polar-orbiting-satellites/10080/22 "2018-05-09T13:40:24Z")

</div>

> [@juliohm](#):
>
> GMT visualizations look amazing as usual.

Thanks, and it can even be made nicer if one translates [this example with SSTs](https://github.com/GenericMappingTools/GMT.jl/blob/master/WL_Example_III.ipynb) to Julia. It would be almost a ono-to-one operation.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [May 9, 2018, 3:34pm UTC](https://discourse.julialang.org/t/grid-interpolation-of-data-from-polar-orbiting-satellites/10080/23 "2018-05-09T15:34:20Z")

</div>

The thing I wish GMT.jl could do is hide this complex syntax from the user by wrapping the low-level gmt commands into a Julian API. The raw commands are too low-level for daily usage. I came to the conclusion that nothing can beat the high-quality map visualizations that gmt produces, but only a few people are capable of generating them.

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [May 9, 2018, 7:55pm UTC](https://discourse.julialang.org/t/grid-interpolation-of-data-from-polar-orbiting-satellites/10080/24 "2018-05-09T19:55:17Z")

</div>

I mentioned that before. Given the level of details that GMT offers to parameterize the plots/calculus it’s virtually impossible to completely replace its condensed syntax by a verbose one. But for the more common options we can (and have done) do it. I see that you have not consulted the GMT.jl [man](https://genericmappingtools.github.io/GMT.jl/latest/modules/) and [examples](https://genericmappingtools.github.io/GMT.jl/latest/examples/) lately.

> [@juliohm](#):
>
> but only a few people are capable of generating them.

Our (long, ~30 years) historical record tells us that many tens of thousands of people have learn to do it.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [May 9, 2018, 8:14pm UTC](https://discourse.julialang.org/t/grid-interpolation-of-data-from-polar-orbiting-satellites/10080/25 "2018-05-09T20:14:35Z")

</div>

Just sharing what I think as someone that is not following the GMT trends nor history 🙂 if it is a tool for experts on GMT only, that is fine. But it is great to hear that some parts of it are being ported to a more Julian API.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [May 28, 2019, 12:48am UTC](https://discourse.julialang.org/t/grid-interpolation-of-data-from-polar-orbiting-satellites/10080/26 "2019-05-28T00:48:36Z")

</div>

Hi @naufalwx,

I would like to share an update regarding structured grids in GeoStats.jl.

Here is how you can load and plot the data:

```julia
using GeoStats
using NetCDF
using Plots

# load 2D matrices containing data
X = ncread("Matthew.nc", "x");
Y = ncread("Matthew.nc", "y");
P = ncread("Matthew.nc", "sfc_precip")

# spatial data
sdata = StructuredGridData(Dict(:precipitation => P), X, Y)

# may take some time depending on the Plots.jl backend
# good idea to set gr(format=:png) for quick plots
plot(sdata, ms=0.1, size=(1000,1000))

```

 ![Screenshot%20from%202019-05-27%2021-20-57](https://global.discourse-cdn.com/julialang/original/3X/e/c/eca3d1d52ca4394b337792e64e6400ee9002fa30.jpeg)

Notice that this plot recipe is sub-optimal. It is just plotting the structured grid data as a collection of points with color. This is a fallback recipe for all spatial data types in GeoStats.jl. We cannot do better until Plots.jl backends implement something like `pcolormesh` from matplotlib.

You can plot subsets of spatial data (or any spatial object in GeoStats.jl) for example:

```julia
plot(view(sdata, 1:1000), ms=0.1, size=(500,500))

```

 ![Screenshot%20from%202019-05-27%2021-26-47](https://global.discourse-cdn.com/julialang/original/3X/4/d/4dffb6395895feda6f2853731cf9359a5fcd9aea.png)

In the example above I am plotting the first `1000` points in the satellite trajectory. You can use `view` to take any subset of points in the range `1:npoints(sdata)`.

Now we can start defining our estimation problem. Say for example we want to estimate values in a regular grid covering the data. We first define the grid with:

```julia
# collect coordinates extrema
xmin, xmax = extrema(X)
ymin, ymax = extrema(Y)

# spatial domain
sdomain = RegularGrid((xmin,ymin), (xmax,ymax), dims=(50,50))

plot(sdomain, ms=0.1, size=(500,500)
plot!(sdata, ms=0.1)

```

 ![Screenshot%20from%202019-05-27%2021-33-29](https://global.discourse-cdn.com/julialang/original/3X/1/c/1ca1b313e62c7b3ea37a187396750569c873cc05.jpeg)

After the estimation domain is defined, you can pick any solver from the framework that is compatible with the domain type to solve the estimation problem:

```julia
problem = EstimationProblem(sdata, sdomain, :precipitation)

```

Please let me know if something is not clear. The codebase is under heavy development.

[Previous page](https://discourse.julialang.org/t/grid-interpolation-of-data-from-polar-orbiting-satellites/10080.md?page=1)
