# Project data into a profile

**URL:** https://forum.generic-mapping-tools.org/t/project-data-into-a-profile/3881
**Category:** Q&A
**Created:** [April 24, 2023, 7:09am UTC](https://forum.generic-mapping-tools.org/t/project-data-into-a-profile/3881 "2023-04-24T07:09:38Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Zhou](https://avatars.discourse-cdn.com/v4/letter/z/3e96dc/32.png) [@Zhou](https://forum.generic-mapping-tools.org/u/Zhou)
#### Post date: [April 24, 2023, 7:09am UTC](https://forum.generic-mapping-tools.org/t/project-data-into-a-profile/3881/1 "2023-04-24T07:09:38Z")

</div>

Hi!  
I made a profile, and now I want to project other dataset in the profile that I have. The data that I intent to project looks like this:

data2project.txt:  
lon[degE] lat[degN] depth[km] dvP[%] vP[km/s] Hit-quality  
65.64546 40.96051 0 0 5.86000 0.000000  
65.66415 40.64678 0 0 5.86000 0.000000  
65.68267 40.33293 0 0 5.86000 0.000000  
65.70103 40.01898 0 0 5.86000 0.000000

My script looks like this:

> awk ‘{print $1,$2,$3,$5}’ data2project.txt: | project -C$initial\_long/$initial\_lati -E$final\_long/$final\_lati -L1/250 -S -Q -fg -Fpz \>\> projections.txt  
> xyz2grd projections.txt -R -I0.2 -Gprojection\_grd.grd  
> grdcontour projection\_grd.grd -C0.2 -R -J -K -O \>\> $ps

I don’t know where the error is. Someone could help me?  
Many thanks in advance!

---

<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 24, 2023, 12:50pm UTC](https://forum.generic-mapping-tools.org/t/project-data-into-a-profile/3881/2 "2023-04-24T12:50:07Z")

</div>

Nothing reproducible here (you parameters are not defined) and what the error might be is not shown. Best to provide a minimal working example if you want help.

---

<div class="post-metadata">

### Author: ![Zhou](https://avatars.discourse-cdn.com/v4/letter/z/3e96dc/32.png) [@Zhou](https://forum.generic-mapping-tools.org/u/Zhou)
#### Post date: [April 24, 2023, 5:35pm UTC](https://forum.generic-mapping-tools.org/t/project-data-into-a-profile/3881/3 "2023-04-24T17:35:48Z")

</div>

Sure @pwessel!!  
I want to project some contours on a profile (like in the first picture)

 ![Screenshot from 2023-04-24 19-18-08](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/4/4607178481a1dd3256931fd8940de17ad2248b0d.png)

I have one file that have longitude ($1), latitude ($2) and the value ($5) that I want to plot in the contours

> awk ‘{print $1,$2, $5}’ contours.txt | project -C$initial\_long/$initial\_lati -E$final\_long/$final\_lati -L0/250 -S -Q -fg -Fpz \>\> projections.txt

-projections.txt is a file with the projected contour curves.  
To see if my projection is good I have plotted it in pink circles:

> awk ‘{print $1,$2,$5}’ contours.txt | project -C$point1[2]/$point1[1] -E$point2[2]/$point2[1] -L0/$dist -S -Q -Fpz -S -fg | psxy -Gpink -Sc2c -R -J -K -O \>\> $ps

 ![Screenshot from 2023-04-24 19-19-46](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/2/2b9e8de9db9cfcee8f50263e9f014a40712488f1.png)

Which is not correct. After, I tried to plot the contours with:

> xyz2grd proj.txt -R$rsm -I2 -V -Gpro\_grd.grd  
> grdcontour pro\_grd.grd -C2 -Wathick,red -R -J -K -O \>\> $ps

But I haven got the expected results yet.  
One of the error that I am getting is:

> xyz2grd: Mismatch between actual (2) and expected (3) fields near line 261717 (skipped)  
> Thanks in advance!

---

<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 25, 2023, 7:19am UTC](https://forum.generic-mapping-tools.org/t/project-data-into-a-profile/3881/4 "2023-04-25T07:19:55Z")

</div>

Still not reproducible since we have no idea what $initial\_long/$initial\_lati might be and contours.txt is missing.

---

<div class="post-metadata">

### Author: ![Zhou](https://avatars.discourse-cdn.com/v4/letter/z/3e96dc/32.png) [@Zhou](https://forum.generic-mapping-tools.org/u/Zhou)
#### Post date: [April 25, 2023, 12:11pm UTC](https://forum.generic-mapping-tools.org/t/project-data-into-a-profile/3881/5 "2023-04-25T12:11:21Z")

</div>

Ok! @pwessel

This is the contour file [contours1.txt](https://forum.generic-mapping-tools.org/uploads/short-url/mXDuxtJJiVajqnjkrtiw1AYvKBr.txt) (809.6 KB)  
This is the one that I want to project on the shown profile. The columns that I intent to plot are the longitude (column 1), the latitude (column 2), depth (column 3) and the value of vP (column 5)

$point1[2] and $point1[1] (-C) are the initial longitude and latitude of my profile. In my case:  
point1[2]= 68.5 and point1[1]=34. Same for the final point pairs (-E): point2[2]=39.0 and point2[1]= 70.0

---

<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 25, 2023, 1:00pm UTC](https://forum.generic-mapping-tools.org/t/project-data-into-a-profile/3881/6 "2023-04-25T13:00:41Z")

</div>

Thanks. So the contour data have the following min/max ranges:

```
gmt info contours1.txt -i0,1,4 -hi1
contours1.txt: N = 18600 <65.64546/74.14299> <32.97036/41.03363> <4.81815/10.87192>

```

You then run project on those three columns (lon, lat, z) and the corresponding projected ranges are now

```
gmt project contours1.txt -i0,1,4 -hi1 -C68.5/34 -E39.0/70.0 -L0/250 -S -Q -fg -Fpz | gmt info
<Standard Input>: N = 5500 <1.3598466741/248.172687081> <5.40786/10.86254>

```

So the x-coordinates looks OK and covers a good portion of your plot above, but the y-coordinate then given to psxy goes from 5.4 to 10.9 and that is why your pink circles are only at the top. From your plot it seems the expected y-range is 0 to 250 or so. Hence, your z-column is just not compatible with that 0-250 range. So there is no error going on here. The z-values are passed along (they are not projected as they are just data values, not coordinates), so I do not understand why you say this is an error when it in fact is an exact duplication of your input data column. Is there a unit issue, i.e., you need to scale your z-values to be compatible with your desired plot range?
