A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/kylebarron/keplergl_cli below:

kylebarron/keplergl_cli: One-line geospatial data visualization using Kepler.gl

A CLI and Python API for quickly viewing geospatial data in Kepler.gl.

Uber's open-source kepler.gl is a great browser-based platform for interactively visualizing geospatial data. The keplergl Python package's included documentation is almost entirely directed at use within Jupyter, and it took a little bit of work to figure out how to use it from a non-Jupyter Python environment.

This package is a simple wrapper to quickly get your data into kepler.gl. From the command line, it's as simple as:

export MAPBOX_API_KEY=...
keplergl data1.geojson data2.shp data3.gdb
cat data.geojson | keplergl

from Python:

from keplergl_cli import Visualize
Visualize(data)

Mapbox API key: in order to display Mapbox-hosted maps, you need to provide a Mapbox API key. Go to Mapbox.com to get an API key.

Package install:

This package has dependencies on geojson, shapely, and geopandas. If you get errors when installing this package through pip, it may be easier to first install dependencies through Conda, then install this package. I.e.:

conda install geojson shapely geopandas -c conda-forge
pip install keplergl_cli

The CLI is installed under the name kepler:

export MAPBOX_API_KEY=...
kepler --style=outdoors data.geojson
kepler --style=dark data1.geojson shapefile.shp geodatabase.gdb -l layer1 -l layer2
cat data.geojson | kepler

You can add export MAPBOX_API_KEY to your .bashrc or .zshrc to not have to run that step each time.

You can supply filename paths to data in any vector format readable by GeoPandas/GDAL. Alternatively you can supply GeoJSON or newline-delimited GeoJSON on stdin.

Supply --help to see the CLI's help menu:

> kepler --help

Usage: kepler [OPTIONS] FILES...

  Interactively view geospatial data using kepler.gl

Options:
  -l, --layer TEXT  Layer names. If not provided, will display all layers
  --api_key TEXT    Mapbox API Key. Must be provided on the command line or
                    exist in the MAPBOX_API_KEY environment variable.
  --style TEXT      Mapbox style. Accepted values are: streets, outdoors,
                    light, dark, satellite, satellite-streets, or a custom
                    style URL.  [default: streets]
  --help            Show this message and exit.

Simplest usage:

import geopandas as gpd
from keplergl_cli import Visualize

# Create your geospatial objects
gdf = gpd.GeoDataFrame(...)

# Visualize one or multiple objects at a time
Visualize(gdf, api_key=MAPBOX_API_KEY)
Visualize([gdf, shapely_object, geojson_string], api_key=MAPBOX_API_KEY)

More detail over the objects in your map:

from keplergl_cli import Visualize
vis = Visualize(api_key=MAPBOX_API_KEY)
vis.add_data(data=data, names='name of layer')
vis.add_data(data=data2, names='name of layer')
html_path = vis.render(open_browser=True, read_only=False)

Visualize

Visualize(data=None, names=None, read_only=False, api_key=None, style=None)

Visualize.add_data()

Visualize.add_data(data, names=None):

Visualize.render()

Visualize.render(open_browser=True, read_only=False)

The most common reasons why a map is not displayed are:

If your data seems to be "floating" above the map, this is likely because your input data have Z coordinates, so kepler.gl displays them in 3-dimensional space.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4