Skip to content
EN

Optimize and render large datasets

Last updated

By the end of this guide, you will be able to load a large GeoJSON dataset efficiently by enabling a performance option. This guide assumes you are familiar with adding a layer (see Add a layer).

A very large GeoJSON file—one with many thousands of coordinates—can slow rendering if loaded normally. Re:Earth Visualizer provides a performance option, useAsResource, that handles large GeoJSON data more efficiently. Use this option for GeoJSON with more than about 6,000 features.

This example adds a large GeoJSON layer representing the boundary of the Tokyo area, with the performance option turned on.

reearth.yml

id: large-dataset-plugin
name: Large Dataset Plugin
version: 1.0.0
extensions:
- id: large-dataset
type: widget
name: Large Dataset

large-dataset.js

reearth.layers.add({
type: "simple",
data: {
type: "geojson",
url: "https://reearth.github.io/visualizer-plugin-sample-data/public/geojson/tokyo-boundary.geojson",
geojson: {
useAsResource: true,
},
},
polygon: {},
});
reearth.camera.flyTo(
{ lat: 35.68, lng: 139.40, height: 176000 },
{ duration: 2 }
);

The GeoJSON boundary data loads and renders across the Tokyo area. Because useAsResource is turned on, the layer is not styled from the Visualizer side, so it appears in the default color. To change its appearance, define styles in the GeoJSON file itself (see below).

A large GeoJSON boundary layer rendered over a Re Visualizer map

Map data from OpenStreetMap.

The performance option is set inside the layer’s data block, under a geojson key:

data: {
type: "geojson",
url: "https://example.com/large-data.geojson",
geojson: {
useAsResource: true,
},
}

Setting useAsResource: true tells Re:Earth Visualizer to render the GeoJSON in a way optimized for large datasets. It is recommended for GeoJSON with more than about 6,000 features.