The world has come a long way in mapping. As a consumer, we take all the location data that is readily available for granted, but as a professional, you may be sitting on a treasure trove of GIS data that just needs to be refined. Here are three simple ways to take that first step with your latitude and longitude data.
The Distance Between Two Coordinates
If you’ve been calculating the distance between two coordinates for a long time, you may be familiar with the Haversine formula. While popular, this equation suffers from minor accuracy deficiencies as it makes the assumption the Earth is a sphere.
geopy library, you have access to a more accurate method of calculating distance that is easier to implement.
Notice that each coordinate pair is a tuple and the unit of measure is added as a property at the end of the execution.
Convert to UTM
Universal Transverse Mercator (UTM) is a system of geospatial mapping that separates the globe into 60 zones, each with their own coordinate plane. The origin of each coordinate plane is at the center of the zone and will tell you the number of meters east and north of the origin.
utm library, you can produce a tuple with the easting, northing, zone number, and zone letter. Keep note of the order within the tuple. Since each value is not labeled, the easting and northing can be easily confused.
In case you found your way here as a primary UTM user who wants to go the other direction, the library includes a method to convert a UTM tuple to a latitude/longitude tuple.
Convert to GeoJSON
GeoJSON is an open-source standard format for representing geospatial objects such as points, lines, and polygons. It is used by many GIS applications and is a logical next step if you have static latitude/longitude data from legacy data collection.
geojson package, you can create each of these GIS shapes with a simple function call for the corresponding shape with the necessary information.
Notice that for a point, the coordinate tuple is passed directly, whereas the coordinate tuples are within a list when creating a line.
I hope these quick tips are helpful as you work with traditional coordinate data. Please leave your comments and questions down below!