Shapely point geometry in geopandas df to lat/lon columns

If you have the latest version of geopandas (0.3.0 as of writing), and the if df is a GeoDataFrame, you can use the x and y attributes on the geometry column: df[‘lon’] = df.point_object.x df[‘lat’] = df.point_object.y In general, if you have a column of shapely objects, you can also use apply to do what … Read more

Moving a CLLocation by x meters

A conversion to Swift, taken from this answer: func locationWithBearing(bearingRadians:Double, distanceMeters:Double, origin:CLLocationCoordinate2D) -> CLLocationCoordinate2D { let distRadians = distanceMeters / (6372797.6) // earth radius in meters let lat1 = origin.latitude * M_PI / 180 let lon1 = origin.longitude * M_PI / 180 let lat2 = asin(sin(lat1) * cos(distRadians) + cos(lat1) * sin(distRadians) * cos(bearingRadians)) let … Read more

Is the Haversine Formula or the Vincenty’s Formula better for calculating distance?

Haversine and Vincenty are two algorithms for solving different problems. Haversine computes the great circle distance on a sphere while Vincenty computes the shortest (geodesic) distance on the surface of an ellipsoid of revolution. So the answer to your question can be broken into 2 parts: Do you want to compute the distance on a … Read more

C# Sunrise/Sunset with latitude/longitude

I know this post is old, but in case anyone is still looking… CoordinateSharp is available as a Nuget package. It’s a standalone packge that can handle sun as well as moon times. Celestial cel = Celestial.CalculateCelestialTimes(85.57682, -70.75678, new DateTime(2017,8,21)); Console.WriteLine(cel.SunRise.Value.ToString()); Note: It assumes DateTimes are always in UTC. Lastly, you may need to reference … Read more

Positive/Negative Latitude and Longitude values vs. Cardinal Directions [closed]

Sometimes lat/long are expressed in degrees/minutes/seconds, and require a N, S, E, or W direction to make sense. Decimal latitude and longitude is expressed as either a positive or negative number and doesn’t require a cardinal direction. So if you’re using decimal values for these, they aren’t described as “latitude north” or anything like that. … Read more

Getting Time Zone from Lat Long Coordinates? [duplicate]

With tzwhere and pytz: import datetime import pytz from tzwhere import tzwhere tzwhere = tzwhere.tzwhere() timezone_str = tzwhere.tzNameAt(37.3880961, -5.9823299) # Seville coordinates timezone_str #> Europe/Madrid timezone = pytz.timezone(timezone_str) dt = datetime.datetime.now() timezone.utcoffset(dt) #> datetime.timedelta(0, 7200)