跳转到主要内容

JupyterLab的GeoJSON渲染器

项目描述

jupyterlab-geojson

JupyterLab的GeoJSON渲染扩展

demo

需求

  • JupyterLab >= 3.0

安装

pip install jupyterlab-geojson

用法

在IPython中渲染GeoJSON输出

from IPython.display import GeoJSON

GeoJSON({
    "type": "Feature",
    "geometry": {
        "type": "Point",
        "coordinates": [-118.4563712, 34.0163116]
    }
})

使用特定的瓦片集

GeoJSON(
    data={
        "type": "Feature",
        "geometry": {
            "type": "Point",
            "coordinates": [-118.4563712, 34.0163116]
        }
    }, url_template="https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=[MAPBOX_ACCESS_TOKEN]",
    layer_options={
        "id": "mapbox.streets",
        "attribution" : '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>'
    }
)

在火星上渲染GeoJSON

GeoJSON(
  data={
      "type": "Feature",
      "geometry": {
          "type": "Point",
          "coordinates": [11.8, -45.04]
      }
  }, url_template="http://s3-eu-west-1.amazonaws.com/whereonmars.cartodb.net/{basemap_id}/{z}/{x}/{y}.png",
  layer_options={
      "basemap_id": "celestia_mars-shaded-16k_global",
      "attribution" : "Celestia/praesepe",
      "tms": True,
      "minZoom" : 0,
      "maxZoom" : 5
  }
)

要渲染.geojson.geo.json文件,只需打开它。

贡献

开发安装

注意:您需要NodeJS来构建扩展包。

jlpm命令是JupyterLab中预装版本的yarn。您可以使用yarnnpm代替下面的jlpm

# Clone the repo to your local environment
# Change directory to the jupyterlab-geojson directory
# Install package in development mode
pip install -e .
# Link your development version of the extension with JupyterLab
jupyter labextension develop . --overwrite
# Rebuild extension Typescript source after making changes
jlpm run build

您可以在不同的终端中同时监视源目录并运行JupyterLab,以监视扩展源的变化并自动重新构建扩展。

# Watch the source directory in one terminal, automatically rebuilding when needed
jlpm run watch
# Run JupyterLab in another terminal
jupyter lab

在运行监视命令的情况下,每次保存的更改都将立即在本地构建并可供运行的JupyterLab使用。刷新JupyterLab以在浏览器中加载更改(您可能需要等待几秒钟以等待扩展重新构建)。

默认情况下,jlpm run build命令生成此扩展的源映射,以便更容易使用浏览器开发者工具进行调试。要为JupyterLab核心扩展也生成源映射,可以运行以下命令

jupyter lab build --minimize=False

卸载

pip uninstall jupyterlab-geojson

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源分布

jupyterlab_geojson-3.4.0.tar.gz (570.3 kB 查看哈希值)

上传时间

构建分布

jupyterlab_geojson-3.4.0-py3-none-any.whl (83.2 kB 查看哈希值)

上传时间 Python 3

由以下支持