Calculate gradient and azimuth of a profile.
Maintainers usually reply within 1 day
@Esteban82 is already working on this.
Since Aug 12, 2024.
Assessment
This issue has not been assessed yet.
Description
For the work I am going to present at the AGU I made a small software (in C) that from a profile (with XYZ data) calculates the intermediate position between two successive data (Xm, Ym), and gradient and azimuth (Xm, Ym, Az, Grad). This way I can use it as input for greenspline (-A+f2). I think it would be nice to add it as a feature for GMT.
What do you think? My idea is to do it but I probably need help.
I think it should be added as a new argument for mapproject? Do you agree? What letter should I use?
This is the code:
#include <math.h>
#include <stdio.h>
int main() {
// Definir los nombres de los archivos de entrada y salida
const char* trackFileName = "Bad_Track";
const char* outFileName = "Track_Gradient.txt";
// Abrir los archivos de entrada y salida
FILE *trackFile = fopen(trackFileName, "r");
FILE *outFile = fopen(outFileName, "w");
if (trackFile == NULL || outFile == NULL) {
perror("Error al abrir archivos");
return 1;
}
// Variables para almacenar los puntos medios
double Xm, Ym, DX, DY, DZ, Distance, Gradient, Azimuth, Radianes;
// Variables para leer las coordenadas de cada línea
double x1, y1, z1, x2, y2, z2;
// Leer las coordenadas de la primera línea
if (fscanf(trackFile, "%lf %lf %lf", &x1, &y1, &z1 ) != 3) {
perror("Error al leer el archivo de entrada");
return 1;
}
// Loop para procesar cada línea
while (fscanf(trackFile, "%lf %lf %lf" , &x2, &y2, &z2) == 3) {
// 1. Calcular el punto medio
Xm = (x1 + x2) / 2.0;
Ym = (y1 + y2) / 2.0;
// 2. Gradiente
DX= (x2-x1);
DY= (y2-y1);
Distance= sqrt(pow(DX, 2) + pow(DY, 2));
DZ = (z2-z1);
Gradient= (DZ / Distance);
// 3. Azimuth
Radianes = atan2 (DX, DY);
Azimuth = fmod ((Radianes * (180/M_PI)+360),360);
//Azimuth = fmod (Azimuth * (180 / M_PI) + 180, 360);
// Escribir el punto medio en el archivo de salida
fprintf(outFile, "%.2f %.2f %.5f %.4f\n", Xm, Ym, Gradient, Azimuth);
// Actualizar las coordenadas anteriores
x1 = x2;
y1 = y2;
z1 = z2;
}
// Cerrar los archivos
fclose(trackFile);
fclose(outFile);
printf("Proceso completado con éxito.\n");
return 0;
}
- Dominant language
- C
- Stars
- 997
- Forks
- 420
- Avg merge
- 13h 27m
- Merged PRs (30d)
- 47
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from GenericMappingTools/gmt
-
Add support for SCM 9.0.0 to GMTPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
GenericMappingTools/gmt#9316 · 10 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
GenericMappingTools/gmt#5767 · 15 comments ·
Maintainers usually reply within 1 day
-
discussion
Difficulty 5/5 Over a week Newbie friendliness 35/100
GenericMappingTools/gmt#9343 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 45/100
GenericMappingTools/gmt#9331 · 1 reaction ·
Maintainers usually reply within 1 day
-
histogram: the min/max setting in -T is ignored when -R is setPossibly taken @seisman claimed this 1 day ago. Openbug
Difficulty 3/5 1-2 days Newbie friendliness 55/100
GenericMappingTools/gmt#9330 · 1 reaction ·
Maintainers usually reply within 1 day
All issues in GenericMappingTools/gmt
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Broken links in reference manualPossibly taken @farisbasha claimed this 14 days ago. Opencore:meson
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
mpv-player/mpv#18934 · 3 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
libsndfile/libsndfile#1239 ·