MCM
MCM

Reputation: 477

How to determine sunset/sunrise including terrain shadows.

In Google Earth you can use the "Sunlight" layer to view shadows cast by the terrain at any given DateTime: https://i.sstatic.net/YFGMj.png

However, I have not been able to find any way to access the sunlight/luminosity/shadow/etc values from the API.

I'm looking for a way to supply Lat, Long and DateTime to determine if an area is in sunlight (taking terrain shadows in to account, there are countless services that will provide simple Sunrise and Sunset times, but these do not consider terrain). This can be done manually with Google Earth, but I'm looking for a programatic method.

Thanks for any thoughts, ideas, leads...

Upvotes: 2

Views: 3284

Answers (2)

Paul Skeie
Paul Skeie

Reputation: 31

I realise that this is an old question, but it surfaced in a google search I just did, and I liked the focus.

Since you're looking for a programmatic way of determining if a point on earth given by a longitude and latitude tuple is exposed to sun at a given time, I can't help you right now. However, I'm in a position to be able to set up such an API quite easily if we see that this is a feature that many people need. At suncurves.com we calculate sunrise and sunset times accounting for terrain. The solution we've set up so far is a web interface where a user can search for an address or drag and drop the icon on a map to get sunrise and sunset times through the year for that exact spot accounting for terrain. We want to create an API to our data, but we do not have a clear specification of the scope of this API yet. What you ask for requires that we need to:

  1. Calculate the apparent horizon from the viewing point of the longitude and latitude. This means scanning the terrain data in a search radius of 30-50 km around your point.
  2. Calculate the sun's position at the specified time.
  3. Calculate the sun's position at the specified time. Determine if the sun is under or over the horizon as given by the terrain surrounding your point accounting for atmospheric refraction.

Here's an example from Chamonix, France where the common flat terrain versions of sunrise, sunset times are pretty worthless.

http://suncurves.com/v/7/

Upvotes: 3

lifeIsGood
lifeIsGood

Reputation: 1229

I am not sure about determining whether an AOI in in the sun or shade at a certain time, however you can set the SUN to be on or off in the API by using

GESun.setVisibility

Edit:

Using the GE-plugin, create a LookAt with your desired AOI lat/long where the view is directly above looking straight down. Depending on the size of you actual AOI I would keep the view as low to the ground as possible.

Then capture a screenshot/image - I do not think this is possible through GE (if anyone knows a way I would like to find out), so maybe use javascript to take it - I found this Q on SO that provides some insight.

Take a screenshot with GESun.setVisibility set ON and then another with it OFF

Compare the two images for darkness/lightness or something and determine if your AOI is in the shade or not. You might find it better to surround your AOI in a Polygon of some sort in order to help your program distinguish it from the rest of the image - depending on the height the LookAt was taken from etc etc....

I do not have any ideas on how to compare the images, but yet again another search on SO resulted in this (I would presume finding the values of COLOR_BLACK in PHP ImageMagick) and this (Color Buckets idea). Depending on your method of choice, it might help to alter your images to black/white before doing the comparing.

Upvotes: 0

Related Questions