How to project a point using PROJ?

39 Views Asked by At

I am writing to seek guidance on how to project a point from one ellipsoid to another ellipsoid using the Proj library. I have been working on a geospatial project that requires converting coordinates between different ellipsoids. After some research, I discovered that the Proj library is a widely used and powerful tool for geospatial data transformations. However, I am currently facing some challenges in understanding and implementing the ellipsoid projection functionality. I would greatly appreciate it if you could provide me with some guidance on how to accomplish this task using the Proj library. Specifically, I would like to know:

1.I want to project a 3d point which is in wgs84 to an airy ellipsoid. I did as shown below. But I am getting incorrect values and height of the point is also not changing.

PJ *Src = proj_create(C, "+proj=geocent  +datum=WGS84 +type=crs");
PJ *Targ_Coor = proj_create(C, "+proj=geocent +ellps=airy +type=crs");
auto P2G = proj_create_crs_to_crs_from_pj(C, Src, Targ_Coor, NULL, NULL);
       if (!P2G)
             return result;

c_out_glob = proj_trans(P2G, PJ_FWD, c_in);
  1. Are there any specific parameters or options that I need to consider while performing the projection from 3d to 2d? In the below code, I am performing projection of a point from wgs84 to oblique merctor. But still I am getting incorrect values.
PJ *Src = proj_create(C, "+proj=geocent  +datum=WGS84 +type=crs");
       if (Src == NULL)
             return result;

       PJ *Targ = proj_create(C, "+proj=omerc +lat_0=4 +lonc =115 +k_0=1 +x_0=2000000 +y_0=5000000 +lat_ts=0 +h_0=0 +alpha=53.31581 +gamma=53.130102  +lat_ts=0 +units=m +ellps=WGS84 +type=crs");

       if (Targ == NULL)
             return result;

       auto G2P = proj_create_crs_to_crs_from_pj(C, Src, Targ, NULL, NULL);
       if (!G2P)
       {
             fprintf(stderr, "failed \n");
             return result;
       }
             
       PJ *norm = proj_normalize_for_visualization(C, G2P);
       if (0 == norm) {
             fprintf(stderr, "Failed to normalize transformation object.\n");
             return 1;
       }

       proj_destroy(G2P);
       G2P = norm;

c_out = proj_trans(G2P, PJ_FWD, c_in);

Any code examples, documentation references, or step-by-step instructions you could provide would be immensely helpful in guiding me through this process. I am eager to learn and explore the capabilities of the Proj library, and any assistance you can offer would be invaluable. Thank you very much for your time and support.

0

There are 0 best solutions below