GeoJSON Parser

 

In this article

Overview

You can use this Snap to parse geospatial data from a GML file or from a ZIP file that contains shapefiles.

Overview of settings with default values

Snap Type

This Snap is a Parse-type Snap that parses geospatial files. This Snap reads a file binary input stream from its input view and then parses and writes the contents as a GeoJSON document to its output view.

Support for Ultra Pipelines

Limitations

This Snap requires an upstream File Reader Snap or Multi File Reader Snap that reads the input files from a GML file or from a ZIP file that contains shapefiles (.shp). The File Reader Snap or Multi File Reader Snap must appear immediately before this Snap in the pipeline. Currently, only GML v3 is supported. Also, GeoJSON output is not supported as downstream output for any database Snaps.

Known Issues

This Snap accepts only application/zip or application/gml+xml; charset=utf-8 as a file input stream. However, the output content type from the File Reader Snap is binary/octet when the input file is read from SLDB.

Workaround: To read an input file (ZIP or GML) from SLDB, use the Mapper Snap to change the content type from binary/octet to one of the following:

  • ZIP file: Change the content type to application/zip .

  • GML file: Change the content type to application/gml+xml; charset=utf-8.

Snap Views

Type

Format

Number of Views

Examples of Upstream and Downstream Snaps

Description

Type

Format

Number of Views

Examples of Upstream and Downstream Snaps

Description

Input 

Binary

  • Min: 1

  • Max: 1

  • File Reader Snap

  • Multi File Reader Snap

This Snap requires an upstream File Reader Snap or Multi File Reader Snap (immediately preceding it in the pipeline) that reads the input files from a ZIP file that contains shapefiles (.shp).or a single GML file.

Output

Document

  • Min: 1

  • Max: 1

  • Mapper

  • File Writer

  • Snowflake

  • PostgreSQL

Output is GeoJSON, which can then be used for any geospatial analytics or map applications.

The output can also be loaded to a database outside of the SnapLogic platform.

 

 

Error

Error handling is a generic way to handle errors without losing data or failing the Snap execution. You can handle the errors that the Snap might encounter when running the Pipeline by choosing one of the following options from the When errors occur list under the Views tab:

  • Stop Pipeline Execution: Stops the current Pipeline execution if the Snap encounters an error.

  • Discard Error Data and Continue: Ignores the error, discards that record, and continues with the remaining records.

  • Route Error Data to Error View: Routes the error data to an error view without stopping the Snap execution.

Learn more about Error handling in Pipelines.

Snap Settings

  • Asterisk ( * ): Indicates a mandatory field.

  • Suggestion icon (): Indicates a list that is dynamically populated based on the configuration.

  • Expression icon ( ): Indicates the value is an expression (if enabled) or a static value (if disabled). Learn more about Using Expressions in SnapLogic.

  • Add icon ( ): Indicates that you can add fields in the field set.

  • Remove icon ( ): Indicates that you can remove fields from the field set.

  • Upload icon ( ): Indicates that you can upload files.

Field Name

Field Type

Field Dependency

Description

Field Name

Field Type

Field Dependency

Description

Label*

 

Default Value: GeoJSON Parser
Example: myGeoJSON Parser

String

None.

Specify a unique name, especially if you have more than one of the same Snap in your pipeline.

 

Input format

 

 

Default Value: Shapefiles
Example: GML file

Dropdown list

None.

Select the format of the file used in the upstream file reader.

Read all files

Checkbox

Appears when you select Shapefiles as the Input format.

 

Read all the files in the zip file.

Shapefiles

List all the shapefiles to be parsed. Click the plus icon ( ) to add a new shapefile.

Shapefile path

 

Default value: None.
Examplelimit

String/Expression

None.

Specify the path to the shapefile you want to parse. The path should include all folders to the file from the root directory.

This property is a URL path to the directory where files will be searched. The expected syntax is: 

  root/folder1/subfolder1/line.shp

Snap Execution

Default ValueExecute only
Example: Validate & Execute

Dropdown list

N/A

Select one of the following three modes in which the Snap executes:

  • Validate & Execute: Performs limited execution of the Snap, and generates a data preview during pipeline validation. Subsequently, performs full execution of the Snap (unlimited records) during pipeline runtime.

  • Execute only: Performs full execution of the Snap during pipeline execution without generating preview data.

  • Disabled: Disables the Snap and all Snaps that are downstream from it.

Troubleshooting

Error

Reason

Resolution

Error

Reason

Resolution

Unsupported file format.

File format is not supported.

Check if the file provided is a zip file containing a .shp file.

Shapefile not found.

No shape file found at the root of the zip file.

Check if the shape file is at the root of the zip file. If not, provide the path of the shapefile in the zip file.

Examples

Read a GML file and parse the input as GeoJSON output

This example pipeline demonstrates how to read a GML file from the File Reader Snap, map the content type, and then parse the input as GeoJSON output.

First, we configure the File Reader Snap to read the GML file.

Next, we add a Mapper Snap to map the content type because the input file resides in SLDB. This step is only needed for input files that reside in SLDB.

In this example, we’ve mapped the content type to application/gml+xml; charset=utf-8 because our input is a GML file.
(If your input is a ZIP file of shapefiles, you must update the content type as application/zip.)

Upon validation, the output from the Mapper Snap is sent to the GeoJSON Parser Snap, which parses the GML file.

We configured the GeoJSON Parser Snap to read a GML file as input.

Upon validation, the GeoJSON Parser Snap parses the GML file and writes the contents as a GeoJSON document to its output view.

The GeoJSON output can be used to create visual data in analytics or map applications.

You can write this file as a GeoJSON file to use with online analytics tools.

 

Downloads

  1. Download and import the pipeline into SnapLogic.

  2. Configure Snap accounts, as applicable.

  3. Provide pipeline parameters, as applicable.