1

I wants to convert lat long to indian grid reference (GR) for India Zone 1A and Zone 0.

Example: For India Zone 1A
lat = 77.79669 and
long = 31.53081
I know the gr will be X=3671296 , Y=08497759

same another example: For India Zone 1A
lat = 78.60744 and
long = 32.06581
and for this gr will be X=3741976 , Y=0916068

but I don't know the formula and what parameter will used so I can get this GR.

this following code I have used but the answer doesn't matched.

double Lts = Convert.ToDouble(lat);
double Los = Convert.ToDouble(long);
double inverse_flattening = 300.8017255;
double num5 = 6377276.345;
double scale_factor = 1.0;
double central_meridian = 68.0;
double latt_of_origin = 32.50;
double num10 = 2743285.8;//False Easting
double num11 = 914395.5;//False northing
double flattening = 1 / inverse_flattening;
double num8 = 0.40648718;//1st st. parallel
double num9 = 0.50073496;//2nd st. parallel
double num7 = central_meridian * Math.PI / 180.0;
double a2 = latt_of_origin * Math.PI / 180.0;
double num6 = Math.Sqrt((2.0 * flattening) - (flattening * flattening));

double a1 = Lts * Math.PI / 180.0;
double num4 = Los * Math.PI / 180.0;
double a3 = Math.Cos(num8) / Math.Sqrt(1.0 - num6 * num6 * Math.Sin(num8) * Math.Sin(num8));
double a4 = Math.Cos(num9) / Math.Sqrt(1.0 - num6 * num6 * Math.Sin(num9) * Math.Sin(num9));
double num12 = Math.Tan(Math.PI / 4.0 - num8 / 2.0) / Math.Pow((1.0 - num6 * Math.Sin(num8)) / (1.0 + num6 * Math.Sin(num8)), num6 / 2.0);
double a5 = Math.Tan(Math.PI / 4.0 - num9 / 2.0) / Math.Pow((1.0 - num6 * Math.Sin(num9)) / (1.0 + num6 * Math.Sin(num9)), num6 / 2.0);
double x1 = Math.Tan(Math.PI / 4.0 - a1 / 2.0) / Math.Pow((1.0 - num6 * Math.Sin(a1)) / (1.0 + num6 * Math.Sin(a1)), num6 / 2.0);
double x2 = Math.Tan(Math.PI / 4.0 - a2 / 2.0) / Math.Pow((1.0 - num6 * Math.Sin(a2)) / (1.0 + num6 * Math.Sin(a2)), num6 / 2.0);
double y = (Math.Log(a3) - Math.Log(a4)) / (Math.Log(num12) - Math.Log(a5));
double num13 = a3 / (y * Math.Pow(num12, y));
double num14 = num5 * num13 * Math.Pow(x1, y);
double num15 = num5 * num13 * Math.Pow(x2, y);
double num16 = y * (num4 - num7);
Int64 temp_gr_x = Convert.ToInt64(num10 + (num14 * Math.Sin(num16)));
Int64 temp_gr_y = Convert.ToInt64(num11 + num15 - (num14 * Math.Cos(num16)));
temp_gr_x = Convert.ToInt64(temp_gr_x * scale_factor);
temp_gr_y = Convert.ToInt64(temp_gr_y * scale_factor);
FCin
  • 3,804
  • 4
  • 20
  • 49
  • Why would India use X any Y. There must be a correlation between number I guess – Maytham Fahmi Dec 13 '18 at 10:03
  • Possible duplicate of [convert from latitude, longitude to x,y](https://stackoverflow.com/questions/16266809/convert-from-latitude-longitude-to-x-y) – Derviş Kayımbaşıoğlu Dec 13 '18 at 13:23
  • @Simonare pretty certain that question is about 'how do i convert', as opposed to this question 'why does this particular conversion not work'. – Rook Dec 13 '18 at 13:29
  • there is no direct conversion. that's why it does not work as it is stated in the referenced post. regards – Derviş Kayımbaşıoğlu Dec 13 '18 at 13:32
  • @Simonare what do you mean by "no direct conversion"? Map projections and coordinate grids exist, and are rigorously defined. There's no exact _global_ solution, but that's irrelevant here because the Indian map grid is only defined over a portion of the earth's surface, and the example coordinates in the question are within that portion. There's a clear correct conversion. – Rook Dec 13 '18 at 13:37
  • Ok. If that is the case, then I will watch the topic. I don't want to mislead anyone. It seems that your knowledge is beyond mine on this topic – Derviş Kayımbaşıoğlu Dec 13 '18 at 13:46
  • Please let us know where you got your code and parameter values from. This will make it much easier to diagnose your issues. – Rook Dec 18 '18 at 10:43

1 Answers1

0

I have spotted a number of issues with your code.

Firstly, you have your latitude and longitude the wrong way around. Using the calculator at https://deeppradhan.heliohost.org/gis/indian-grid/conversion.htm I can see that if you use your supplied latitude of 31.53081 and a longitude of 77.79669 you'll get the grid reference you've supplied as an example in your question. With those parameters, your code gives results which are much closer to Deep Pradhan's, but there are still some surprisingly large differences (especially in the Y value).

I don't know where you got your example code from, but it looks like it hasn't quite got the correct set of parameters for the projection you want to do. They're close to the values that I've found online for the Indian Grid I region, but not the same; where did you find them?

The published data I've found for the Indian Grid says that it uses a Lambert Conical Conformal projection with one standard parallel, but your code appears to have two standard parallels. I'm reasonably certain that the code used by Deep Pradhan's calculator that I used above is using the single standard parallel projection (and I'm fairly certain the georepository calculator does too), so the results will never be quite comparable.

Finally, you should be cautious about the datum in which your coordinates are expressed. Deep Pradhan's calculator takes WGS84 coordinates, but the projection formulae I've found for the Indian grid system expect coordinates using the Everest 1830 (1975 Definition) ellipsoid. There's a straightforward conversion between the two ellipsoids, but I don't believe that your code does it. This may be one source of the differences between your results and those returned by other calculators. There's a coordinate converter in the kalianpur datum here that might be useful to you.

I had a stab at writing a conversion algorithm myself from the parameters available in georepository and the projection algorithm described in EPSG Geomatics Guidance Note 7, part 2 (section 1.3.1.2 on page 22) and didn't quite get results that matched georepository's own calculator, but if you like I can share my code and you can feel free to debug it yourself ;-)

NOTE: There was a comment on the original question (apparently now deleted) suggesting that the OP use ProjNet4GeoApi. That library currently only provides a lambert conical conformal projection with two standard parallels, whereas the available data online for the Indian map grid only uses the one standard parallel version of the projection. This won't be a problem if the OP has a legitimate source for the projection parameters (though they have not shared this as yet).

Rook
  • 5,734
  • 3
  • 34
  • 43
  • Yes i want the correct parameter value of 1st st. parallel and 2nd st. parallel variable. – shailendra14_vyas Dec 15 '18 at 07:08
  • when i changed these parameter by hit and try, it reflect my final temp_gr_x and temp_gr_y value and for 1 lat long it will be correct, but for other lat long again failed. so i want a correct value for both parameter which will applicable on all entered lat long. – shailendra14_vyas Dec 15 '18 at 07:15
  • @shailendra14_vyas I can't give you the correct value for both parallels, as they don't seem to be publically available. That's why I was interested in where you got your values and code from. – Rook Dec 18 '18 at 10:36
  • @shailendra14_vyas When I run your second grid reference (long 78.60744 lat 32.06581) through the fixed version of your code, I get the output (x 3743615 y 905716) which is fairly close to the expected values you supplied above. You need to fix _every single other issue_ that I mentioned above if you want it to be more accurate though. – Rook Dec 18 '18 at 10:42