Skip to content

Publish a Space-Time Patterns (VIS-STAMP) Page

This tutorial shows how to publish a Space-Time Patterns (VIS-STAMP) page using the ZillionInfo API.

Prerequisites

  • A ZillionInfo account. If you don’t have one, you can sign up at ZillionInfo.
  • An API key for authentication.
  • Spatial data (unit data) and space-time attribute data uploaded to the platform.

Steps

  1. Set up the data

    First, you need to set up the data for VIS-STAMP analysis by associating your spatial unit data with space-time attribute data.

    Terminal window
    curl -X POST "https://services.zillioninfo.com/zi/visstamp/app/api/setData" \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
    "dataId": 123, // ID of your spatial unit data
    "csvId": 456 // ID of your space-time attribute data
    }'

    Parameters:

    • dataId: The ID of your spatial unit data (spatial data representing geographic units)
    • csvId: The ID of your space-time attribute data (containing time series data for each spatial unit)

    Response:

    {
    "csvContextId": 789,
    "featureIdField": "unit_id",
    "unitFields": ["field1", "field2", "field3"],
    "numericFields": {
    "0": "field4",
    "1": "field5",
    "2": "field6"
    }
    }

    The response provides:

    • csvContextId: A context ID for subsequent API calls
    • featureIdField: The field name that can be used to join the spatial data with attribute data
    • unitFields: Available fields in the unit data
    • numericFields: Numeric fields in the space-time attribute data that can be used for analysis
  2. Set the feature ID field (optional)

    If you need to change the feature ID field used to join the spatial data with the attribute data:

    Terminal window
    curl -X POST "https://services.zillioninfo.com/zi/visstamp/app/api/setFeatureIdField" \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
    "csvContextId": 789,
    "featureIdField": "field2"
    }'

    Parameters:

    • csvContextId: The context ID received from the previous step
    • featureIdField: The field name to use for joining the spatial data with attribute data
  3. Submit the VIS-STAMP request

    Now submit the VIS-STAMP analysis request with your selected variables and parameters:

    Terminal window
    curl -X POST "https://services.zillioninfo.com/zi/visstamp/app/api/classes" \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
    "csvContextId": 789,
    "somSize": 3,
    "variables": {
    "vars": [0, 1, 2],
    "nors": [-1, -1, -1],
    "weights": [1.0, 1.0, 1.0]
    }
    }'

    Parameters:

    • csvContextId: The context ID received from the first step
    • somSize: The size of the Self-Organizing Map (SOM) grid (e.g., 3 creates a 3×3 grid with 9 clusters)
    • variables: Configuration for the variables to use in the analysis:
      • vars: Array of indices for the variables to include (based on the order of fields in the data)
      • nors: Array of normalization variable indices (use -1 for no normalization)
      • weights: Array of weights for each variable (1.0 means equal weighting)

    Response:

    {
    "jobID": "abc123"
    }

    The response provides a jobID that you’ll use to check the status of your analysis.

  4. Check the status of the request

    VIS-STAMP analysis may take some time to complete. You can check the status using the job ID:

    Terminal window
    curl -X GET "https://services.zillioninfo.com/zi/visstamp/app/api/status?jobId=abc123" \
    -H "Authorization: Bearer YOUR_API_KEY"

    Parameters:

    • jobId: The job ID received from the previous step

    Response:

    {
    "status": "running",
    "result": null
    }

    The status can be:

    • waiting: Job is in the queue
    • running: Job is currently processing
    • finished: Job has completed successfully
    • failed: Job has failed
  5. Get the result

    Once the status is finished, the response will include the results:

    {
    "status": "finished",
    "result": {
    // Classification results
    },
    "link": "https://services.zillioninfo.com/zi/visstamp/app/embedFrame?o=xyz123",
    "embedCode": "<div id='jkl'><script async src='https://services.zillioninfo.com/zi/visstamp/app/embed?o=xyz123'></script></div>"
    }

    The response provides:

    • result: The detailed classification results
    • link: A URL to view the results in a web browser
    • embedCode: HTML code to embed the results in your website
  6. Use the results in your application

    <!DOCTYPE html>
    <html>
    <head>
    <title>VIS-STAMP Results</title>
    </head>
    <body>
    <h1>Space-Time Pattern Analysis Results</h1>
    <!-- Embed the VIS-STAMP visualization -->
    <div id='jkl'>
    <script async src='https://services.zillioninfo.com/zi/visstamp/app/embed?o=xyz123'></script>
    </div>
    </body>
    </html>

Next Steps

  • Explore the VIS-STAMP results to identify space-time patterns in your data
  • Share the results with others using the provided link or embed code
  • Create additional visualizations based on the classification results