ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Convert longitude & latitude to layer coordinates postions

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Nabeel Khalid
Convert longitude & latitude to layer coordinates postions
on Jan 30, 2018 at 2:06:31 pm

Hi,
I don't know where to start with this but i need to convert real longitude & latitude coordinates to map them on a map layer in after effects. The Long and lat coordinates will be changed via a CSV file so they need to dynamic. The canvas is 1920x1080. Is there any easy way of converting coordinates via expressions?

Thanks
Nabeel


Return to posts index

Kevin Camp
Re: Convert longitude & latitude to layer coordinates postions
on Jan 31, 2018 at 12:16:25 am

this would change depending on where you have your international date line... but assuming the date line is on the left edge of the screen and 90 degrees N is at the top edge of the screen and -90 is at the bottom edge, I think this would work:

lat = 47 ; // enter latitude value
lon = -122 ; // enter longitude value
y = linear( lat, -90, 90, 1080, 0 ) ;
x = linear( lon, -180, 180, 0, 1920 ) ;
[ x, y ]

i haven't written an expression to load data from an external file, but it can be done. search this forum for terms like "load data csv", then use that to fill the lat and lon values.

Kevin Camp
Art Director
KCPQ, KZJO & KRCW


Return to posts index

Kevin Camp
Re: Convert longitude & latitude to layer coordinates postions
on Jan 31, 2018 at 12:27:00 am

this would depend on the projection of the map...

Kevin Camp
Art Director
KCPQ, KZJO & KRCW


Return to posts index


Kevin Camp
Re: Convert longitude & latitude to layer coordinates postions
on Jan 31, 2018 at 12:56:33 am

here's a link to a map with the projection that would work for that expression:
https://www.1worldglobes.com/images/custom/inflatable/basic_world_map_lg.jp...

if you take that into a 1080 comp and fit it to the comp (layer>transform>fit to comp). then add a null and copy/paste that expression in the null's position, it should line up pretty well with the map. in my sample expression, the values were for Seattle, and that seems to be pretty accurate, and i tested a few others.

Kevin Camp
Art Director
KCPQ, KZJO & KRCW


Return to posts index

Nabeel Khalid
Re: Convert longitude & latitude to layer coordinates postions
on Jan 31, 2018 at 1:46:10 pm

Thanks Kevin,

I ended up using the expression below. I modified the source.
Thank you for your help

Nabeel

eval("var state=" + footage("map.json").sourceText);

latitude = location[0]. latitude;
longitude = location[0]. longitude;

y = linear( latitude, -90, 90, 1080, 0 ) ;
x = linear( longitude, -180, 180, 0, 1920 ) ;
[ x, y ]


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]