# Plotting data on 3D map issue in perspective view

**URL:** <https://forum.generic-mapping-tools.org/t/plotting-data-on-3d-map-issue-in-perspective-view/3813>\
**Category:** Q&A\
**Created:** [April 4, 2023, 7:46am UTC](https://forum.generic-mapping-tools.org/t/plotting-data-on-3d-map-issue-in-perspective-view/3813 "2023-04-04T07:46:08Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Meyal](https://avatars.discourse-cdn.com/v4/letter/m/258eb7/32.png) [@Meyal](https://forum.generic-mapping-tools.org/u/Meyal)\
**Post date:** [April 4, 2023, 7:46am UTC](https://forum.generic-mapping-tools.org/t/plotting-data-on-3d-map-issue-in-perspective-view/3813/1 "2023-04-04T07:46:09Z")

</div>

Hi,  
I am trying to plot 3D perspective map of an area. I want to add some data points on this map. The following way I used;

```auto
gmt begin
Proj="-JM10c"
Region="-R134/140/25/33"
Region3D="-R134/140/25/33/-6500/1000"		
Perspective="-p130/20"						
Proz="-JZ3c"
gmt figure example_map png
# extract relief data for area
gmt grdcut @earth_relief_01m -R134/140/25/33 -Gexample_relief.grd
# add coast features on map
gmt coast $Proj $Region3D $Perspective/0 $Proz -Na -W0.2p,black -Gyellow
gmt grdview example_relief.grd $Proj $Region3D $Perspective $Proz -Ctopo -I -N-6500+glightgray -Qi300 -Wf0.5,black -Ba2 -Bza1000+l"Height (m)"

# add points on map. using grdtrack to get 3rd column value
gmt grdtrack $Limit -Gexample_relief.grd -sa | gmt plot3d points_data $Proj $Region3D $Perspective $Proz -Sc0.08c -Gred
gmt end

```

Points\_data: [points\_data.dat](https://forum.generic-mapping-tools.org/uploads/short-url/2L7E9Fmt0svK6GgD2ulwHA1ROmd.dat) (11.3 KB)

I used points\_data(long,lat) to add these points on map. To get 3rd column value in addition to (long,lat), I try to use grdtrack.

But I am getting problem in using grdtrack to get 3rd column value. What is the issue in grdtrack command which I used above (gmt grdtrack $Limit -Gexample\_relief.grd -sa) and suggest the correct way to do this using grdtrack. Thanks.

---

<div class="post-metadata">

**Author:** ![PlanetGus](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/planetgus/32/303_2.png) [@PlanetGus](https://forum.generic-mapping-tools.org/u/PlanetGus)\
**Post date:** [April 4, 2023, 9:00am UTC](https://forum.generic-mapping-tools.org/t/plotting-data-on-3d-map-issue-in-perspective-view/3813/3 "2023-04-04T09:00:16Z")

</div>

I assume you followed this example already

> **[(33) Stacking automatically generated cross-profiles — GMT 6.4.0 documentation](https://docs.generic-mapping-tools.org/latest/gallery/ex33.html)**

What ˋ$Limit` is supposed to be ?

---

<div class="post-metadata">

**Author:** ![Meyal](https://avatars.discourse-cdn.com/v4/letter/m/258eb7/32.png) [@Meyal](https://forum.generic-mapping-tools.org/u/Meyal)\
**Post date:** [April 4, 2023, 9:08am UTC](https://forum.generic-mapping-tools.org/t/plotting-data-on-3d-map-issue-in-perspective-view/3813/4 "2023-04-04T09:08:39Z")

</div>

Sorry its typing error, the $Limit —\> Region="-R134/140/25/33"

---

<div class="post-metadata">

**Author:** ![Esteban82](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/esteban82/32/54_2.png) [@Esteban82](https://forum.generic-mapping-tools.org/u/Esteban82)\
**Post date:** [April 4, 2023, 11:59am UTC](https://forum.generic-mapping-tools.org/t/plotting-data-on-3d-map-issue-in-perspective-view/3813/5 "2023-04-04T11:59:31Z")

</div>

Try this line instead ( with `points_data.dat` in `grdtrack`)

`gmt grdtrack points_data.dat $Limit -Gexample_relief.grd -sa | gmt plot3d $Proj $Region3D $Perspective $Proz -Sc0.08c -Gred`

---

<div class="post-metadata">

**Author:** ![Meyal](https://avatars.discourse-cdn.com/v4/letter/m/258eb7/32.png) [@Meyal](https://forum.generic-mapping-tools.org/u/Meyal)\
**Post date:** [April 4, 2023, 3:16pm UTC](https://forum.generic-mapping-tools.org/t/plotting-data-on-3d-map-issue-in-perspective-view/3813/6 "2023-04-04T15:16:34Z")

</div>

@Esteban82

Thanks for your help, it solve the issue. Figure is attached which shows points stick to surface.

 ![Selection_012](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/2/273d73b33c24bdd999ec08bc7cee601aa3bc4ce7.jpeg)

I also used grdtrack command from some other source. Can you explain little bit about the parameter (-sa) in grdtrack command?

Another thing, without getting column 3 values using grdtrack, whether user can use original depths of earthquakes in place of 3rd column values (from grdtrack) for plotting such 3D map?

---

<div class="post-metadata">

**Author:** ![Esteban82](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/esteban82/32/54_2.png) [@Esteban82](https://forum.generic-mapping-tools.org/u/Esteban82)\
**Post date:** [April 4, 2023, 3:19pm UTC](https://forum.generic-mapping-tools.org/t/plotting-data-on-3d-map-issue-in-perspective-view/3813/7 "2023-04-04T15:19:50Z")

</div>

> [@Meyal](#):
>
> Can you explain little bit about the parameter (-sa) in grdtrack command?

I’m affraid I don’t record it now. But I am sure that in the docs it is well explained.

---

<div class="post-metadata">

**Author:** ![Esteban82](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/esteban82/32/54_2.png) [@Esteban82](https://forum.generic-mapping-tools.org/u/Esteban82)\
**Post date:** [April 4, 2023, 3:22pm UTC](https://forum.generic-mapping-tools.org/t/plotting-data-on-3d-map-issue-in-perspective-view/3813/8 "2023-04-04T15:22:21Z")

</div>

> [@Meyal](#):
>
> Another thing, without getting column 3 values using grdtrack, whether user can use original depths of earthquakes in place of 3rd column values (from grdtrack) for plotting such 3D map?

I am not sure if I understand well. You could use the original depth. But be careful with the units. You should convert the depth from km to m (to plot in the above figure where the vertical scale is in meters).

---

<div class="post-metadata">

**Author:** ![pwessel](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pwessel/32/30_2.png) [@pwessel](https://forum.generic-mapping-tools.org/u/pwessel)\
**Post date:** [April 4, 2023, 3:37pm UTC](https://forum.generic-mapping-tools.org/t/plotting-data-on-3d-map-issue-in-perspective-view/3813/9 "2023-04-04T15:37:39Z")

</div>

1. It cannot be that hard to click on the -sa link in the docs and read?
2. If you have a files with lon, lat, depth points then you have no grid so grdtrack is obviously not involved at all.

---

<div class="post-metadata">

**Author:** ![Meyal](https://avatars.discourse-cdn.com/v4/letter/m/258eb7/32.png) [@Meyal](https://forum.generic-mapping-tools.org/u/Meyal)\
**Post date:** [April 5, 2023, 10:59am UTC](https://forum.generic-mapping-tools.org/t/plotting-data-on-3d-map-issue-in-perspective-view/3813/10 "2023-04-05T10:59:15Z")

</div>

Hi,

1. I checked the docs earlier, there is a parameter (-Smethod/modifiers) is available which I tested but gives error. So I asked for (-sa).

[data.dat](https://forum.generic-mapping-tools.org/uploads/short-url/4RTh9VKsnFHxuxo8Kn1lSgS3Mkw.dat) (14.6 KB)

2a. Using earthquakes depth with (long,lat), it gives error in plot. Figure 1 is plotted using data.dat(long,lat,depth) where depth is in km and height is in (m). I think similar way is used where height is in (m) and earthquakes depth in (km) available ([How to plot earthquakes data on a three-dimensional topographic map - Earth Inversion](https://www.earthinversion.com/utilities/how-to-plot-the-earthquake-data-on-three-dimensional-topographic-map/)).

```auto
gmt begin
Proj="-JM10c"
Region="-R134/140/25/33"
Region3D="-R134/140/25/33/-6500/1000"		
Perspective="-p130/20"						
Proz="-JZ3c"
gmt figure example_map png
gmt grdcut @earth_relief_01m -R134/140/25/33 -Gexample_relief.grd
gmt grdview example_relief.grd $Proj $Region3D $Perspective $Proz -Ctopo -I -N-6500+glightgray -Qi300 -Wf0.5,black -Ba2 -Bza1000+l"Height (m)"
gmt plot3d data.dat $Proj $Limit3D $Perspective $Proz -Sc0.2c -Gred     
gmt end

```

Figure 1

 ![Selection_015](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/9/94dfe47e696d0c92e3a6d35678d234d4173b709a.jpeg)

“So if using earthquakes depth in (km) and height in (m) is correct then how to correct Figure 1 where earthqaukes appear as in air not stick to surface?”

2b. Figure 2 is plotted using data.dat(long,lat,depth) where earthquakes depth converted to (m) same unit as height (m).  
Figure 2

 ![Selection_016](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/d/d7204dff5b40a8b13b99953c5082ee5065d9f51f.jpeg)

“Why few data appear in Figure 2 if both earthquakes and height is in same unit of (m). What may be the possible issue?”

---

<div class="post-metadata">

**Author:** ![mkononets](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/mkononets/32/4029_2.png) [@mkononets](https://forum.generic-mapping-tools.org/u/mkononets)\
**Post date:** [April 5, 2023, 5:08pm UTC](https://forum.generic-mapping-tools.org/t/plotting-data-on-3d-map-issue-in-perspective-view/3813/11 "2023-04-05T17:08:26Z")

</div>

> [@Meyal](#):
>
> “So if using earthquakes depth in (km) and height in (m) is correct then how to correct Figure 1 where earthqaukes appear as in air not stick to surface?”

because your depths in `data.dat` are positive while `gmt` expects negative depths? “Positive depths” are altitudes (above the sea level) in this context.

you can `plot3d` your data alone with axes/coordinates and an appropriate Z range (0/1000) to get an overview.

even if you get these depths negative, they’ll “hang” well above the sea floor as far as I can understand by manually checking your `data.dat`, as depths on the `example_relief.grd`are below -1000 m, many close to -3000…-4000…-5000…-6000 m.

---

<div class="post-metadata">

**Author:** ![mkononets](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/mkononets/32/4029_2.png) [@mkononets](https://forum.generic-mapping-tools.org/u/mkononets)\
**Post date:** [April 5, 2023, 5:13pm UTC](https://forum.generic-mapping-tools.org/t/plotting-data-on-3d-map-issue-in-perspective-view/3813/12 "2023-04-05T17:13:30Z")

</div>

> [@Meyal](#):
>
> Using earthquakes depth with (long,lat), it gives error in plot. Figure 1 is plotted using data.dat(long,lat,depth) where depth is in km and height is in (m). I think similar way is used where height is in (m) and earthquakes depth in (km) available

from your `www.earthinversion.com` link:

> Since the depths of the event ranges up to 180 km, we had to constrain it to show it within the range of our chosen maximum depth for the three-dimensional map. We project the depths in the range of 0 to the maximum depth of the displayed topography.

if your event depths in `data.dat` are **positive kilometers** , many can occur way below the sea floor depth of your grid file.

---

<div class="post-metadata">

**Author:** ![Meyal](https://avatars.discourse-cdn.com/v4/letter/m/258eb7/32.png) [@Meyal](https://forum.generic-mapping-tools.org/u/Meyal)\
**Post date:** [April 6, 2023, 7:47am UTC](https://forum.generic-mapping-tools.org/t/plotting-data-on-3d-map-issue-in-perspective-view/3813/13 "2023-04-06T07:47:04Z")

</div>

@mkononets

Thanks for your clarification. I think if user plot map using depths (either + or -), plot have an error in which events appear in air not stick to surface.

If user keep depth and height in same units then depth values become higher \> height range values, so few events displayed on map which have depth values within height range.

So in such case, I think events(long,lat) data with grdtrack (to get z value) is a suitable option instead of using events depth.
