title: Convert latitude, longitude to distance from equator in kilometers and round to nearest kilometer
body: <p>For each coordinate I have, I find the distance from the equator in kilometers giving me two distances:    </p>
  
  <pre><code>from pyproj import Geod
  wgs84_geod = Geod(ellps='WGS84')    
  _,_, lon_dist = wgs84_geod.inv(0, 0,lon, 0)
  _,_, lat_dist = wgs84_geod.inv(0, 0,0, lat)
  </code></pre>
  
  <p>As a sanity check,I can recalculate the original coordinate from these values as follows (assume the direction from the equator coordinate (0,0) is North and West:</p>
  
  <pre><code>_, new_lat, _ = wgs84_geod.fwd(0,0, 0, lat_dist)
  new_lon, _, _ = wgs84_geod.fwd(0, 0, 90, lon_dist)
  </code></pre>
  
  <p>This gives me back the same coordinates I started with.</p>
  
  <p>Now I want to find the closest kilometer point to my coordinate. I round the lon_dist and lat_dist to kilometers from the equator values.</p>
  
  <pre><code>lat_km_dist = round(lat_dist/1000)*1000 #to nearest km and back to meters
  lon_km_dist = round(lon_dist/1000)*1000 
  </code></pre>
  
  <p>I get coordinates using these distances in the same way as before</p>
  
  <pre><code>_, km_lat, _ = wgs84_geod.fwd(0,0, 0, lat_km_dist)
  km_lon, _, _ = wgs84_geod.fwd(0, 0, 90, lon_km_dist)
  </code></pre>
  
  <p>The logic should be that for multiple coordinates in the same area, the closest distance between any km_lat, km_lon pair should be 1km. 
  This is true in the North/South axis, but for longitudes the distance varies depending on which latitude I'm at. 
  I'm attaching two screenshots to visualize the problem where the km_lat, km_lon coordinates are represented by black circles at the center of polygons with an area of 1km.</p>
  
  <p>How can I correct for this?</p>
  
  <p><a href="https://i.stack.imgur.com/Gftek.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Gftek.png" alt="Copenhagen"></a></p>
  
  <p><a href="https://i.stack.imgur.com/kbL99.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kbL99.png" alt="San Francisco"></a></p>