Author Topic: Altitude from Google Earth API  (Read 14203 times)

0 Members and 1 Guest are viewing this topic.

FELIX

  • Bull Frog
  • Posts: 241
Altitude from Google Earth API
« on: September 08, 2014, 11:21:24 PM »
It is possible to get altitude Google Earth API?
OK.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Altitude from Google Earth API
« Reply #1 on: September 09, 2014, 01:45:04 AM »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

VovKa

  • Water Moccasin
  • Posts: 1631
  • Ukraine
Re: Altitude from Google Earth API
« Reply #2 on: September 09, 2014, 04:45:06 AM »
http://www.theswamp.org/index.php?topic=33065.msg385105#msg385105
Code: [Select]
(defun vk_GetGEarthElevation (lat lon)
  (atof
    (last
      (assoc "elevation"
     (last
       (assoc "result"
      (last
(assoc "ElevationResponse"
       (vk_ReadXML
(strcat "http://maps.googleapis.com/maps/api/elevation/xml?locations="
(rtos lat 2 16)
","
(rtos lon 2 16)
)
       )
)
      )
       )
     )
      )
    )
  )
)
;;;(vk_GetGEarthElevation 50.747778 25.324444)

FELIX

  • Bull Frog
  • Posts: 241
Re: Altitude from Google Earth API
« Reply #3 on: September 09, 2014, 04:39:48 PM »
Very good, perfect, VovKa.

OK.
OK.

BlackBox

  • King Gator
  • Posts: 3770
Re: Altitude from Google Earth API
« Reply #4 on: September 09, 2014, 05:52:48 PM »
Interested to see how this might be used with VERTCON. :angel:

Cheers
"How we think determines what we do, and what we do determines what we get."

danallen

  • Guest
Re: Altitude from Google Earth API
« Reply #5 on: September 09, 2014, 06:00:02 PM »
wow! what is the smallest resolution in feet or meters that can be obtained from database?

VovKa

  • Water Moccasin
  • Posts: 1631
  • Ukraine
Re: Altitude from Google Earth API
« Reply #6 on: September 10, 2014, 03:55:10 PM »
wow! what is the smallest resolution in feet or meters that can be obtained from database?
as far as i know +/- 30м

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Altitude from Google Earth API
« Reply #7 on: September 10, 2014, 07:08:37 PM »
Holy crap. I've been playing with google earth to autocad integration, but I had no idea you could access the api via the internet. That's awesome! Thank you, Vovka.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

snownut2

  • Swamp Rat
  • Posts: 971
  • Bricscad 22 Ultimate
Re: Altitude from Google Earth API
« Reply #8 on: September 11, 2014, 08:43:54 PM »
Holy crap. I've been playing with google earth to autocad integration, but I had no idea you could access the api via the internet. That's awesome! Thank you, Vovka.

http://www.theswamp.org/index.php?topic=45197.msg503894#msg503894

From August 2013...

snownut2

  • Swamp Rat
  • Posts: 971
  • Bricscad 22 Ultimate
Re: Altitude from Google Earth API
« Reply #9 on: September 11, 2014, 08:58:58 PM »
Google API in Action

VovKa

  • Water Moccasin
  • Posts: 1631
  • Ukraine
Re: Altitude from Google Earth API
« Reply #10 on: September 12, 2014, 05:35:41 AM »
what coordinate system do you guys use in surveying and land development?
i could adapt my program for online maps so one can use it in the US

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Altitude from Google Earth API
« Reply #11 on: September 12, 2014, 12:35:35 PM »
what coordinate system do you guys use in surveying and land development?
i could adapt my program for online maps so one can use it in the US
I primarily use NAD83 Florida State Planes, North Zone, US Foot (FL83-NF). I notice the returned data is UTF-8. What decides this?
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

VovKa

  • Water Moccasin
  • Posts: 1631
  • Ukraine
Re: Altitude from Google Earth API
« Reply #12 on: September 12, 2014, 01:24:37 PM »
I primarily use NAD83 Florida State Planes, North Zone, US Foot (FL83-NF).
thank you. i'll have to work on this one
I notice the returned data is UTF-8. What decides this?
google does

VovKa

  • Water Moccasin
  • Posts: 1631
  • Ukraine
Re: Altitude from Google Earth API
« Reply #13 on: September 24, 2014, 09:28:42 AM »
I primarily use NAD83 Florida State Planes, North Zone, US Foot (FL83-NF).
Alan, i couldn't find any drawing in FL83-NF to test
can you please check http://www.theswamp.org/index.php?topic=47908.0 ?

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Altitude from Google Earth API
« Reply #14 on: September 24, 2014, 10:13:14 PM »
I primarily use NAD83 Florida State Planes, North Zone, US Foot (FL83-NF).
Alan, i couldn't find any drawing in FL83-NF to test
can you please check http://www.theswamp.org/index.php?topic=47908.0 ?
No dice. It put me in the middle of the ocean. What are you using to set the coordinate base? I've been playing with the ade_* functions, but I know they are only available with some of the vertical autodesk products.
I played around with the google api and was able to get it to download and load an image, but I'm not 100% on the scaling. What are you using for a scaling factor to bring in the image at the correct size? I suppose I should probably be asking these in the other thread.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

VovKa

  • Water Moccasin
  • Posts: 1631
  • Ukraine
Re: Altitude from Google Earth API
« Reply #15 on: September 25, 2014, 04:39:09 AM »
I played around with the google api
actually my code does not use "google api". it works the same way as any browser. it downloads tiles and coverts their coordinates into you working projected CS
What are you using for a scaling factor to bring in the image at the correct size?
does this mean that images are inserted/scaled/rotated correctly? i'm asking because i had to write some new code to make it work in FL83-NF without any chance to test.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Altitude from Google Earth API
« Reply #16 on: September 25, 2014, 10:52:53 AM »
I played around with the google api
actually my code does not use "google api". it works the same way as any browser. it downloads tiles and coverts their coordinates into you working projected CS
That's pretty cool, but aren't you using google maps to retrieve the data?


does this mean that images are inserted/scaled/rotated correctly? i'm asking because i had to write some new code to make it work in FL83-NF without any chance to test.
Your program recognized FL83-NF when I loaded it on my machine, but it didn't match the coordinates. I had the same problem when using a program to import geotagged images. I think it was using UTM. I abandoned it and started working on my own.

I'm getting them to insert 'close' to where they should be, but it appears to be more of a scale factor. I used a zoom factor of 15, scale of 2, and a size of 500x500. When I brought the image into autocad, I scaled it by multiplying the zoom times the size (* 15 500). It seems to work, but it felt like I was just making something up.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

VovKa

  • Water Moccasin
  • Posts: 1631
  • Ukraine
Re: Altitude from Google Earth API
« Reply #17 on: September 25, 2014, 03:37:13 PM »
That's pretty cool, but aren't you using google maps to retrieve the data?
yes i do
but i do not query http://maps.googleapis.com/maps/api/
i use browser like interface. for example https://mts0.google.com/vt/lyrs=m@275317119&x=70&y=106&z=8&s=Gali (for google) or http://ak.dynamic.t0.tiles.virtualearth.net/comp/ch/12030?it=G,VE,BX,L,LA&shading=hill&og=60&n=z (for bing)

when I loaded it on my machine, but it didn't match the coordinates.
if it's not a problem for you, can you please send me coordinates (FL83-NF) of any object that is clearly visible on google satellite images (building, pole, fence...). if it'd be a dwg file, save it please in acad2000 version.
i've never worked with Lambert projection before. so i could have made a mistake somewhere.

mailmaverick

  • Bull Frog
  • Posts: 493
Re: Altitude from Google Earth API
« Reply #18 on: September 26, 2014, 05:51:55 AM »
http://www.theswamp.org/index.php?topic=33065.msg385105#msg385105
Code: [Select]
(defun vk_GetGEarthElevation (lat lon)
  (atof
    (last
      (assoc "elevation"
     (last
       (assoc "result"
      (last
(assoc "ElevationResponse"
       (vk_ReadXML
(strcat "http://maps.googleapis.com/maps/api/elevation/xml?locations="
(rtos lat 2 16)
","
(rtos lon 2 16)
)
       )
)
      )
       )
     )
      )
    )
  )
)
;;;(vk_GetGEarthElevation 50.747778 25.324444)

Excellent !!!!
« Last Edit: September 26, 2014, 06:11:50 AM by mailmaverick »

mailmaverick

  • Bull Frog
  • Posts: 493
Re: Altitude from Google Earth API
« Reply #19 on: September 14, 2016, 03:46:55 AM »
Hi,

Vovka has given an excellent function to get Elevation of any point on Earth from Latitude and Longitude. My queries are :-

1.) What is the accuracy of these Elevations, is the +/- range specified anywhere by Google ?

2.) I ran this function to get elevation for 10-15 random points, and I got the results. Is this service by Google free even if I want elevations of 5000 points by use of Vovka's function ?

3.) I have an area which I can define in form of 4 coordinates / Latitude+Longitude (in form of a rectangle), can I get google earth image of these coordinates in AutoCAD ?

Thanks.


mailmaverick

  • Bull Frog
  • Posts: 493
Re: Altitude from Google Earth API
« Reply #21 on: September 14, 2016, 06:58:28 AM »
Thanks for your answer Vovka, but in the link provided by you, it says that Resolution is the maximum distance between data points from which the elevation was interpolated.

However, my question is about the accuracy of Elevation provided. Because I have heard (I may be wrong) that Google Earth forcefully creates some error and does not give accurate results due to strategic / defense purposes.


snownut2

  • Swamp Rat
  • Posts: 971
  • Bricscad 22 Ultimate
Re: Altitude from Google Earth API
« Reply #22 on: September 14, 2016, 07:11:38 AM »
Thanks for your answer Vovka, but in the link provided by you, it says that Resolution is the maximum distance between data points from which the elevation was interpolated.

However, my question is about the accuracy of Elevation provided. Because I have heard (I may be wrong) that Google Earth forcefully creates some error and does not give accurate results due to strategic / defense purposes.

Mailmaverick,
If you noticed the usage limits from the Google Map API are 512 points per request and 2,500 request per day for free.  Google also interprets the request per day to be spaced apart by some minimum time, so if they are two close together you will get booted. 

I have noticed that in heavily wooded areas the Google elevation accuracy suffers, I doubt this is a function of some built in mechanism.   

I have also found when comparing elevation data from the Google map api or from the national map query service (=http://nationalmap.gov/epqs/), the national map data is much closer to actual flown topography (at least in my area and must be in the US).

Currently the resolution of the national map service is 1/3 arc second, (or 3 meter pixels), by 2020 they are supposed to be going to 1/9 arc second (1 meter pixel size).  Meaning if you submit data for points closer then 3 meters apart they will return the same elevation. Google fixes this by interpolating from one pixel to the next so the same data is not returned for multiple points, sort of fooling the user to think its better data.  I've found that requesting national points closer than 50' results in a zigzag elevation data when contours are generated.  In a few years though this should be greatly improved with the 1/9 arc second mapping.
« Last Edit: September 14, 2016, 07:20:54 AM by snownut2 »

mailmaverick

  • Bull Frog
  • Posts: 493
Re: Altitude from Google Earth API
« Reply #23 on: September 14, 2016, 07:54:21 AM »
Thanks snownut, Vovka's function requests elevation of a single point. How to get elevation of 512 points in a single request ?


VovKa

  • Water Moccasin
  • Posts: 1631
  • Ukraine
Re: Altitude from Google Earth API
« Reply #24 on: September 14, 2016, 08:00:52 AM »
Code: [Select]
(defun vk_MAssoc (Key InList)
  (vl-remove-if-not
    (function (lambda (e) (equal Key (car e))))
    InList
  )
)
(defun vk_ConcatList (StrList Delimiter)
  (or Delimiter (setq Delimiter ""))
  (substr (apply 'strcat
(mapcar (function (lambda (s) (strcat Delimiter (vl-princ-to-string s))))
StrList
)
  )
  (1+ (strlen Delimiter))
  )
)
(defun vk_GE-GetElevations (lst / url)
;;;  https://developers.google.com/maps/documentation/elevation/intro
;;;  https://developers.google.com/maps/documentation/elevation/usage-limits
;;;  2,500 free requests per day, calculated as the sum of client-side and server-side queries.
;;;  512 locations per request.
;;;  50 requests per second, calculated as the sum of client-side and server-side queries.
  (setq url "http://maps.googleapis.com/maps/api/elevation/xml?locations=")
  (mapcar (function (lambda (e)
      (list (cons 'E (atof (last (assoc "elevation" (last e)))))
    (cons 'R (atof (last (assoc "resolution" (last e)))))
      )
    )
  )
  (vk_MAssoc "result"
     (last
       (assoc "ElevationResponse"
      (vk_ReadXML
(strcat url
(vk_ConcatList (mapcar (function (lambda (e) (strcat (rtos (car e) 2 8) "," (rtos (cadr e) 2 8))))
       lst
       )
       "|"
)
)
      )
       )
     )
  )
  )
)

mailmaverick

  • Bull Frog
  • Posts: 493
Re: Altitude from Google Earth API
« Reply #25 on: October 17, 2018, 11:03:26 AM »
Has anyone noticed that this routine no longer works to get Google Earth Elevations.
Any reason known so far ?

ronjonp

  • Needs a day job
  • Posts: 7528

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

VovKa

  • Water Moccasin
  • Posts: 1631
  • Ukraine
Re: Altitude from Google Earth API
« Reply #27 on: October 17, 2018, 11:38:04 AM »
Has anyone noticed that this routine no longer works to get Google Earth Elevations.
Any reason known so far ?
https://developers.google.com/maps/documentation/elevation/usage-and-billing

kirby

  • Newt
  • Posts: 127
Re: Altitude from Google Earth API
« Reply #28 on: October 17, 2018, 01:54:43 PM »
The Bing Maps API still offers free services, but you need to register for an access key (no keyless requests anymore).

How to get a key
https://msdn.microsoft.com/en-us/library/ff428642.aspx

Elevation API
https://msdn.microsoft.com/en-us/library/jj158961.aspx

kirby

  • Newt
  • Posts: 127
Re: Altitude from Google Earth API
« Reply #29 on: October 17, 2018, 02:02:29 PM »
Or you can grab NASA's SRTM data (Shuttle Radar Topography Mission) through USGS site

Newly available in 1 arc-second resolution for USA (approx. 30m grid at equator),
but only available in 1 arc-second resolution for the rest of the world  :-(

Read about it:
https://www2.jpl.nasa.gov/srtm/index.html

Get the data (STRM1 is 1 arc-second, STRM 3 is 3 arc-second):
https://dds.cr.usgs.gov/srtm/version2_1/

Better than nothing (but no good for small areas)

mailmaverick

  • Bull Frog
  • Posts: 493
Re: Altitude from Google Earth API
« Reply #30 on: October 18, 2018, 04:55:00 AM »
Hi

Thanks for your replies.  Can anyone change the function to get the Elevations from Bing API instead of Google Earth.
Also, as Kirby suggested, we download Geotiff from USGS website but how to get elevations of various points from Geotiff within AutoCAD / Civil 3D, using Autolisp ?

snownut2

  • Swamp Rat
  • Posts: 971
  • Bricscad 22 Ultimate
Re: Altitude from Google Earth API
« Reply #31 on: October 18, 2018, 04:00:05 PM »
Elevation data from the National Map project for US is available and more accurate then Google, see link https://nationalmap.gov/epqs/


VovKa

  • Water Moccasin
  • Posts: 1631
  • Ukraine
Re: Altitude from Google Earth API
« Reply #32 on: October 19, 2018, 05:49:45 AM »
Can anyone change the function to get the Elevations from Bing API instead of Google Earth.
i'd try but i don't have a bing key
i tried to register but microsoft demands my phone number which i'm not going to share with them...

mailmaverick

  • Bull Frog
  • Posts: 493
Re: Altitude from Google Earth API
« Reply #33 on: October 22, 2018, 06:07:25 AM »
Hi Vovka

Can you modify the function without the key. The Key can be an input variable to the function.

Thanks.

VovKa

  • Water Moccasin
  • Posts: 1631
  • Ukraine
Re: Altitude from Google Earth API
« Reply #34 on: October 22, 2018, 06:46:45 AM »
Can you modify the function without the key. The Key can be an input variable to the function.
ok
without tesing
Code: [Select]
(defun vk_MAssoc (Key InList)
  (vl-remove-if-not
    (function (lambda (e) (equal Key (car e))))
    InList
  )
)
(defun vk_ConcatList (StrList Delimiter)
  (or Delimiter (setq Delimiter ""))
  (substr (apply 'strcat
(mapcar (function (lambda (s) (strcat Delimiter (vl-princ-to-string s))))
StrList
)
  )
  (1+ (strlen Delimiter))
  )
)
(defun vk_GE-GetElevations (lst key / url)
;;;  https://developers.google.com/maps/documentation/elevation/usage-and-billing
  (setq url (strcat "https://maps.googleapis.com/maps/api/elevation/xml?key=" key "&locations="))
  (mapcar (function (lambda (e)
      (list (cons 'E (atof (last (assoc "elevation" (last e)))))
    (cons 'R (atof (last (assoc "resolution" (last e)))))
      )
    )
  )
  (vk_MAssoc "result"
     (last
       (assoc "ElevationResponse"
      (vk_ReadXML
(strcat url
(vk_ConcatList (mapcar (function (lambda (e) (strcat (rtos (car e) 2 8) "," (rtos (cadr e) 2 8))))
       lst
       )
       "|"
)
)
      )
       )
     )
  )
  )
)
Edit: changed URL to use SSL
« Last Edit: October 22, 2018, 07:26:20 AM by VovKa »

mailmaverick

  • Bull Frog
  • Posts: 493
Re: Altitude from Google Earth API
« Reply #35 on: October 22, 2018, 01:55:39 PM »
Dear Vovka

The function still calls google earth instead of bing. Please check.

VovKa

  • Water Moccasin
  • Posts: 1631
  • Ukraine
Re: Altitude from Google Earth API
« Reply #36 on: October 22, 2018, 05:28:40 PM »
The function still calls google earth instead of bing. Please check.
sorry i thought you were asking about google's api key

VovKa

  • Water Moccasin
  • Posts: 1631
  • Ukraine
Re: Altitude from Google Earth API
« Reply #37 on: October 22, 2018, 06:23:12 PM »
Code: [Select]
(defun vk_AssocXmlPath (keys data)
  (vl-every (function (lambda (e) (setq data (last (assoc e data))))) keys)
  data
)
(defun vk_VE-GetElevations (lst key / url)
  (setq url (strcat "http://dev.virtualearth.net/REST/v1/Elevation/List?heights=sealevel&output=xml&key="
    key
    "&points="
    )
  )
  (mapcar (function (lambda (e) (atof (last e))))
  (vk_AssocXmlPath
    (list "Response" "ResourceSets" "ResourceSet" "Resources" "ElevationData" "Elevations")
    (vk_ReadXML
      (strcat url
      (vk_ConcatList
(mapcar (function (lambda (e) (strcat (rtos (car e) 2 8) "," (rtos (cadr e) 2 8)))) lst)
","
      )
      )
    )
  )
  )
)

mailmaverick

  • Bull Frog
  • Posts: 493
Re: Altitude from Google Earth API
« Reply #38 on: October 23, 2018, 10:09:27 AM »
Hi Vovka

Thanks for your inputs.
I have generated a Key (without them asking for my phone number, I only created a new email address and thats the only thing they ask) and I'm able to get elevations. But the elevations are rounded to nearest integer.

Can we increase the precision of the elevations to maybe 2 to 3 digits ?


Elevation data from the National Map project for US is available and more accurate then Google, see link https://nationalmap.gov/epqs/

Also, can we also create a LISP to get multiple elevations using above link, as suggested by snownut.

VovKa

  • Water Moccasin
  • Posts: 1631
  • Ukraine
Re: Altitude from Google Earth API
« Reply #39 on: October 23, 2018, 11:21:44 AM »
Can we increase the precision of the elevations to maybe 2 to 3 digits ?
no
bing returns elevations this way
and that's why i've not added bing's elevations to my IRT app

Also, can we also create a LISP to get multiple elevations using above link, as suggested by snownut.
i've already tried it maybe a year ago
with no success
i couldn't get a response from their site
i think it's somehow connected with security protocols