# TheSwamp

## CAD Forums => Vertically Challenged => Land Lubber / Geographically Positioned => Topic started by: dubb on November 15, 2018, 03:25:45 PM

Title: How do I convert a single x,y point from lat, lon with autolisp?
Post by: dubb 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)`
Title: Re: How do I convert a single x,y point from lat, lon with autolisp?
Post by: dubb on November 15, 2018, 04:21:35 PM
I did some searching. It is a rather complex question.
Title: Re: How do I convert a single x,y point from lat, lon with autolisp?
Post by: kdub 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 :
Title: Re: How do I convert a single x,y point from lat, lon with autolisp?
Post by: kdub 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 :)
Title: Re: How do I convert a single x,y point from lat, lon with autolisp?
Post by: ribarm 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
Title: Re: How do I convert a single x,y point from lat, lon with autolisp?
Post by: dubb 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 :
Title: Re: How do I convert a single x,y point from lat, lon with autolisp?
Post by: dubb 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.
Title: Re: How do I convert a single x,y point from lat, lon with autolisp?
Post by: mjfarrell 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
Title: Re: How do I convert a single x,y point from lat, lon with autolisp?
Post by: dubb 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
Title: Re: How do I convert a single x,y point from lat, lon with autolisp?
Post by: BIGAL 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.
Title: Re: How do I convert a single x,y point from lat, lon with autolisp?
Post by: Rod 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.

Title: Re: How do I convert a single x,y point from lat, lon with autolisp?
Post by: wizman 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.
Title: Re: How do I convert a single x,y point from lat, lon with autolisp?
Post by: dubb 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.
Title: Re: How do I convert a single x,y point from lat, lon with autolisp?
Post by: snownut2 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.