AnsweredAssumed Answered

Coordinates Conversion Based on Criteria Using Python

Question asked by Crossrail.GIS on Oct 15, 2020
Latest reply on Oct 19, 2020 by danretired

I am trying to develop a custom tool to be used as a widget in Web AppBuilder. The tool should be able to return x, y coordinate values using default projection system (e.g. London Survey Grid) based on user’s click on the map. Then the returned x, y coordinate values should generate another set of x, y coordinate of the same location using some criteria (If and else statement).

 

The scenario is as below:

 

1. User clicks on the map and returns X, Y value (default projection system)

Let’s say X = 45670 and Y = 55000

 

2. Re-project or convert the returned X and Y values from step 1 to another set of coordinates of the same location (P2_X, P2_Y2)  using criteria below:

 

Criteria is: (This is just a sample, but I have a long real criteria)

 

If X == 0 and Y == 0:

   return Projection2 (0,0)

elif X >= 44274 and X <= 45799 and Y >= 53927 and Y <= 54889:

   P2_X = (X * 0.999942) – (Y * 0.2519)

   P2_Y = (Y * 0.999942) + (X * 0.2519)

   return Projection2(P2_X , P2_Y)

else:

    P2_X = (X * 0.98888) – (Y * 0.4519)

    P2_Y = (Y * 0.98888) + (X * 0.4519)

    return Projection2(P2_X , P2_Y)

 

3. Then display both X, Y and P2_X, P2_Y

 

I have my python script that returns X,Y based on the user’s click on the map, but I am struggling in returning P2_X and P2_Y based on the criteria as mentioned above. I have a separate python script for the criteria. Please let me know if any one can help me on this, I can share my script if needed.

 

Thanks for your help in advance.

 

-Sushil

Attachments

Outcomes