Author Topic: How do I convert a single x,y point from lat, lon with autolisp?  (Read 10293 times)

0 Members and 1 Guest are viewing this topic.

dubb

  • Swamp Rat
  • Posts: 1105
How do I convert a single x,y point from lat, lon with autolisp?
« on: November 15, 2018, 03:25:45 PM »
I tried this and it does not work for me.
Code: [Select]
x = R * cos(lat) * cos(lon)
y = R * cos(lat) * sin(lon)
« Last Edit: November 15, 2018, 03:29:04 PM by dubb »

dubb

  • Swamp Rat
  • Posts: 1105
Re: How do I convert a single x,y point from lat, lon with autolisp?
« Reply #1 on: November 15, 2018, 04:21:35 PM »
I did some searching. It is a rather complex question.

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2120
  • class keyThumper<T>:ILazy<T>
Re: How do I convert a single x,y point from lat, lon with autolisp?
« Reply #2 on: November 15, 2018, 04:26:46 PM »

I'm not a very civil guy, so :

What does the R represent ? at equator or at your point ?

Are X and Y on the surface ?

OR :
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2120
  • class keyThumper<T>:ILazy<T>
Re: How do I convert a single x,y point from lat, lon with autolisp?
« Reply #3 on: November 15, 2018, 04:41:04 PM »
This looks interesting

https://rechneronline.de/earth-radius/


added
The equator is better characterized as an ellipse rather than a circle
and
The earth is slightly oblate ( flattened at the poles)

So yes, I can see that it may get complicated :)
« Last Edit: November 15, 2018, 04:54:34 PM by kdub »
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: How do I convert a single x,y point from lat, lon with autolisp?
« Reply #4 on: November 15, 2018, 04:42:28 PM »
This looks to me that you are searching for cartezian coords and you have spherical parameters :
(setvar 'lastpoint '(0.0 0.0 0.0))
pt (x y z) = @R<lat<lon
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

dubb

  • Swamp Rat
  • Posts: 1105
Re: How do I convert a single x,y point from lat, lon with autolisp?
« Reply #5 on: November 15, 2018, 04:53:30 PM »
R represents the radius of the earth.
Taken from stackexchange. https://gis.stackexchange.com/questions/221882/formula-to-convert-xy-to-long-lat-coordinates-given-a-point



I'm not a very civil guy, so :

What does the R represent ? at equator or at your point ?

Are X and Y on the surface ?

OR :

dubb

  • Swamp Rat
  • Posts: 1105
Re: How do I convert a single x,y point from lat, lon with autolisp?
« Reply #6 on: November 15, 2018, 04:56:36 PM »
I skipped physics in college.  :uglystupid2:
My local coordinate system is in state plane nad83. That might have something to do with the conversion from cartesian to wgs84.

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: How do I convert a single x,y point from lat, lon with autolisp?
« Reply #7 on: November 15, 2018, 06:26:43 PM »
export you point in state plane

import it into QGIS using new layer from delimited text option

export that layer in lat lon, or KML, or what ever...

tell me what you have (post the point file), and tell me what you want...and I can transform and give you a tutorial for same
Be your Best


Michael Farrell
http://primeservicesglobal.com/

dubb

  • Swamp Rat
  • Posts: 1105
Re: How do I convert a single x,y point from lat, lon with autolisp?
« Reply #8 on: November 15, 2018, 06:52:36 PM »
I'm definitely capable of using qgis, googlearth to convert the coordinates. I was looking to create a function that will take the x,y of a point in AutoCAD, then convert into lat & longs, then apply it to a direct url string to launch in google maps.

export you point in state plane

import it into QGIS using new layer from delimited text option

export that layer in lat lon, or KML, or what ever...

tell me what you have (post the point file), and tell me what you want...and I can transform and give you a tutorial for same

BIGAL

  • Swamp Rat
  • Posts: 1396
  • 40 + years of using Autocad
Re: How do I convert a single x,y point from lat, lon with autolisp?
« Reply #9 on: November 15, 2018, 08:52:19 PM »
Thats a CIV3D function>

Like the others its a complicated formula and depends totally where you are in the world and what zone you are within. CIV3D has a function to import lat long directly and like I said pretty sure it can export also.  For me we just did tricky stuff like take your phone photo with the gps mode on and place it on a dwg at that location, we found around +- 5-10m accuracy not bad for a phone photo.

You would be best googling for the actual formula then it could be rewritten into lisp. You will find it under land surveying.
A man who never made a mistake never made anything

Rod

  • Newt
  • Posts: 185
Re: How do I convert a single x,y point from lat, lon with autolisp?
« Reply #10 on: November 15, 2018, 10:29:24 PM »
It can be easily done with lisp using the in built functions if you are using Autocad Civil or Autocad Map.

You would just need to know the code for the coordinate system.

My coorindate system is called "SGC" to convert from WG84 to SGC i use

Code - Auto/Visual Lisp: [Select]
  1.  
  2. (ade_projsetsrc "LL84")
  3. (ade_projsetdest "SGC")
  4. (ade_projptforward pt)
  5.  

"All models are wrong, some models are useful" - George Box

wizman

  • Bull Frog
  • Posts: 290
Re: How do I convert a single x,y point from lat, lon with autolisp?
« Reply #11 on: November 16, 2018, 07:59:00 AM »
Just adding an input.

The coordinate conversion you are trying to.do is involving a math to unproject a projected point to a global coordnate system GCS (actual position in an ellipsoid/spheroid) which are measured in degrees.

Assuming the xy coordinates given are Projected in UTM.  Then you would need to tell which one of the 60 zones is the location of the coordinates.  Each of the zones has the same easting and northing but different locations.

You would also need to tell which datum you are converting to.  This can be WGS84 or any other.  There is a long list of datums.  lat longs are not only WGS84.

It looks like the equations you are trying are rotational transformations but not relating to geodetics.

dubb

  • Swamp Rat
  • Posts: 1105
Re: How do I convert a single x,y point from lat, lon with autolisp?
« Reply #12 on: November 16, 2018, 12:45:55 PM »
Thanks for all the input. I have alot to learn about GIS.
Just adding an input.

The coordinate conversion you are trying to.do is involving a math to unproject a projected point to a global coordnate system GCS (actual position in an ellipsoid/spheroid) which are measured in degrees.

Assuming the xy coordinates given are Projected in UTM.  Then you would need to tell which one of the 60 zones is the location of the coordinates.  Each of the zones has the same easting and northing but different locations.

You would also need to tell which datum you are converting to.  This can be WGS84 or any other.  There is a long list of datums.  lat longs are not only WGS84.

It looks like the equations you are trying are rotational transformations but not relating to geodetics.

snownut2

  • Swamp Rat
  • Posts: 971
  • Bricscad 22 Ultimate
Re: How do I convert a single x,y point from lat, lon with autolisp?
« Reply #13 on: April 10, 2019, 11:51:33 PM »
Little late, but have a look at NOAA's Vertical Datum transformation program, can be run via command line, you can input any point in any coordinate system and transform to any other coordinate system. Works perfectly, may take a bit of coding.