Mercator Layout#
Geographic layout using Mercator projection for latitude/longitude coordinates.
Note
This layout is optional for Graphistry visualization. Graphistry automatically performs server-side
geographic layout when latitude/longitude bindings are detected. Use mercator_layout() only when
you need projected coordinates locally for analysis or exporting to other tools.
Mercator layout: Convert latitude/longitude coordinates to Mercator projection.
This module provides the mercator_layout method for Plotter objects.
- graphistry.layout.mercator.mercator_layout(self, scale_for_graphistry=True)#
Convert latitude/longitude coordinates to Mercator projection.
Uses point_latitude and point_longitude bindings if set, otherwise defaults to ‘latitude’ and ‘longitude’ columns. Uses existing point_x and point_y bindings if available, otherwise defaults to ‘x’ and ‘y’. Uses GPU acceleration via CuPy if available, falls back to CPU/pandas otherwise.
Note: Graphistry automatically performs server-side geographic layout when latitude/longitude columns are detected. Use mercator_layout() when you need projected coordinates locally for analysis or need to export coordinates for use with other tools.
- Parameters:
scale_for_graphistry (bool) – If True (default), use scaled Earth radius (~637) for manageable coordinate values in Graphistry visualizations. If False, use standard Earth radius (~6,378,137 meters) for accurate geographic coordinates.
self (Plottable)
- Returns:
Plottable with Mercator projection coordinates
- Return type:
- Example
import graphistry import pandas as pd # Using default column names 'latitude' and 'longitude' nodes_df = pd.DataFrame({ 'id': ['NYC', 'LA', 'London'], 'latitude': [40.7128, 34.0522, 51.5074], 'longitude': [-74.0060, -118.2437, -0.1278] }) g = graphistry.nodes(nodes_df, 'id').mercator_layout() # Or with custom column names nodes_df2 = pd.DataFrame({ 'id': ['NYC', 'LA', 'London'], 'lat': [40.7128, 34.0522, 51.5074], 'lon': [-74.0060, -118.2437, -0.1278] }) g2 = (graphistry .nodes(nodes_df2, 'id') .bind(point_latitude='lat', point_longitude='lon') .mercator_layout())
See Also#
Maps & Geographic Visualization: Geographic visualization guide
Kepler API Reference: Kepler.gl integration API