LogoLogo
  • Welcome
  • What's new?
  • Docs
    • User guides
      • Get Started
      • Kepler.gl workflow
        • Add data to layers
          • Adding Data Layers
          • Create a Layer
          • Blend and Rearrange Layers
          • Hide, Edit and Delete Layers
        • Add Data to the Map
      • Layers
        • Point
        • S2 Layer
        • Icon
        • Line
        • Cluster
        • Polygon
        • Hexbin
        • Grid
        • H3
        • Heatmap
        • Arc
        • Trip layer
      • Layer Attributes
      • Color Palettes
      • Filters
      • Map Styles
      • Interactions
      • Map Settings
      • Time Playback
      • Save and Export
      • FAQ
    • API Reference
      • ecosystem
      • Get Started
      • Advanced usages
        • Saving and Loading Maps with Schema Manager
        • Replace UI Component with Component Dependency Injection
        • Forward Dispatch Actions
        • Reducer Plugin
        • Using Updaters
        • Custom reducer initial state
        • custom-mapbox-host
      • Components
      • Reducers
        • reducers
        • map-style
        • map-state
        • combine
        • overview
        • ui-state
        • vis-state
      • Processors
        • All processors
      • Schemas
      • Actions
        • All actions
      • Cloud providers
        • Provider
      • Custom theme
      • Localization
    • Jupyter Notebook
  • Examples
    • Node/Express
    • Demo App
    • Open modal
    • Open modal
    • UMD client
    • Customize kepler.gl Theme
    • Customize kepler.gl Reducer
  • Contributing
    • Developing Kepler.gl
    • Contributor Covenant Code of Conduct
  • Change Log
  • Upgrade Guide
Powered by GitBook
On this page

Was this helpful?

  1. Docs
  2. API Reference
  3. Processors

All processors

  • getFieldsFromData

  • processCsvData

  • processGeojson

  • processKeplerglJSON

  • processRowObject

getFieldsFromData

Analyze field types from data in string format, e.g. uploaded csv. Assign type, tableFieldIndex and format (timestamp only) to each field

Parameters

  • data Array<Object> array of row object

  • fieldOrder Array array of field names as string

Examples

import {getFieldsFromData} from '@kepler.gl/processors';
const data = [{
  time: '2016-09-17 00:09:55',
  value: '4',
  surge: '1.2',
  isTrip: 'true',
  zeroOnes: '0'
}, {
  time: '2016-09-17 00:30:08',
  value: '3',
  surge: null,
  isTrip: 'false',
  zeroOnes: '1'
}, {
  time: null,
  value: '2',
  surge: '1.3',
  isTrip: null,
  zeroOnes: '1'
}];

const fieldOrder = ['time', 'value', 'surge', 'isTrip', 'zeroOnes'];
const fields = getFieldsFromData(data, fieldOrder);
// fields = [
// {name: 'time', format: 'YYYY-M-D H:m:s', tableFieldIndex: 1, type: 'timestamp'},
// {name: 'value', format: '', tableFieldIndex: 4, type: 'integer'},
// {name: 'surge', format: '', tableFieldIndex: 5, type: 'real'},
// {name: 'isTrip', format: '', tableFieldIndex: 6, type: 'boolean'},
// {name: 'zeroOnes', format: '', tableFieldIndex: 7, type: 'integer'}];

Returns Array<Object> formatted fields

processCsvData

Process csv data, output a data object with {fields: [], rows: []}. The data object can be wrapped in a dataset and pass to addDataToMap

Parameters

  • rawData string raw csv string

Examples

import {processCsvData} from '@kepler.gl/processors';

const testData = `gps_data.utc_timestamp,gps_data.lat,gps_data.lng,gps_data.types,epoch,has_result,id,time,begintrip_ts_utc,begintrip_ts_local,date
2016-09-17 00:09:55,29.9900937,31.2590542,driver_analytics,1472688000000,False,1,2016-09-23T00:00:00.000Z,2016-10-01 09:41:39+00:00,2016-10-01 09:41:39+00:00,2016-09-23
2016-09-17 00:10:56,29.9927699,31.2461142,driver_analytics,1472688000000,False,2,2016-09-23T00:00:00.000Z,2016-10-01 09:46:37+00:00,2016-10-01 16:46:37+00:00,2016-09-23
2016-09-17 00:11:56,29.9907261,31.2312742,driver_analytics,1472688000000,False,3,2016-09-23T00:00:00.000Z,,,2016-09-23
2016-09-17 00:12:58,29.9870074,31.2175827,driver_analytics,1472688000000,False,4,2016-09-23T00:00:00.000Z,,,2016-09-23`

const dataset = {
 info: {id: 'test_data', label: 'My Csv'},
 data: processCsvData(testData)
};

dispatch(addDataToMap({
 datasets: [dataset],
 options: {centerMap: true, readOnly: true}
}));

Returns Object data object {fields: [], rows: []}

processGeojson

Process GeoJSON FeatureCollection, output a data object with {fields: [], rows: []}. The data object can be wrapped in a dataset and pass to addDataToMap

Parameters

  • rawData Object raw geojson feature collection

Examples

import {addDataToMap} from '@kepler.gl/actions';
import {processGeojson} from '@kepler.gl/processors';

const geojson = {
	"type" : "FeatureCollection",
	"features" : [{
		"type" : "Feature",
		"properties" : {
			"capacity" : "10",
			"type" : "U-Rack"
		},
		"geometry" : {
			"type" : "Point",
			"coordinates" : [ -71.073283, 42.417500 ]
		}
	}]
};

dispatch(addDataToMap({
 datasets: {
   info: {
     label: 'Sample Taxi Trips in New York City',
     id: 'test_trip_data'
   },
   data: processGeojson(geojson)
 }
}));

Returns Object dataset containing fields and rows

processKeplerglJSON

Process saved kepler.gl json to be pass to addDataToMap. The json object should contain datasets and config.

Parameters

  • rawData Object

    • rawData.datasets Array

    • rawData.config Object

Examples

import {addDataToMap} from '@kepler.gl/actions';
import {processKeplerglJSON} from '@kepler.gl/processors';

dispatch(addDataToMap(processKeplerglJSON(keplerGlJson)));

Returns Object datasets and config {datasets: {}, config: {}}

processRowObject

Process data where each row is an object, output can be passed to addDataToMap

Parameters

  • rawData Array<Object> an array of row object, each object should have the same number of keys

Examples

import {addDataToMap} from '@kepler.gl/actions';
import {processRowObject} from '@kepler.gl/processors';

const data = [
 {lat: 31.27, lng: 127.56, value: 3},
 {lat: 31.22, lng: 126.26, value: 1}
];

dispatch(addDataToMap({
 datasets: {
   info: {label: 'My Data', id: 'my_data'},
   data: processRowObject(data)
 }
}));

Returns Object dataset containing fields and rows

PreviousProcessorsNextSchemas

Last updated 7 months ago

Was this helpful?