Vector Data API

Module: mls.vector. This page documents 3 public functions with exact tool IDs, complete parameters, Parameters fields, and examples.

Back to the Script Tool API Reference

Functions

  • vector_import — Import vector data (Shapefile, GeoJSON, KML, DXF, etc.) into the project
  • export — Export vector layer from project to file (Shapefile, GeoJSON, GPKG, DXF, etc.),Input file array A and output file array must be in one-to-one correspondence with equal count.
  • create_layer — Create a new empty vector layer (point, line, polygon, annotation) in the project GPKG database

vector_import

Import vector data (Shapefile, GeoJSON, KML, DXF, etc.) into the project

  • Exact tool ID:vector_import
  • Recommended call:mls.vector.vector_import(...)
  • Required parameters:source_path, gpkg_path

Parameters

Parameter Type Required Default Description
source_path string Yes — Input vector file path
target_path string No — Target layer ID in project, create new layer if not exists
gpkg_path string Yes — Current project gpkg/Lidpkg file path
src_wkt string No — Source coordinate system WKT
dst_wkt string No — Target coordinate system WKT for conversion
layer_type string No 'layer' Layer type, default: layer
add_to_project boolean No True Whether to add to current project
add_xyz boolean No False Whether to add XYZ coordinates
dxf_unit integer No 0 DXF file unit (0=Meters, 1=Centimeters, etc.)
file_list array No — An array containing the input vector paths

Example

from gvscript import mls

result = mls.vector.vector_import(
    source_path='D:/data/input.LiData',
    target_path='D:/data/input.LiData',
    gpkg_path='D:/data/input.LiData',
    src_wkt='example',
    dst_wkt='example',
    layer_type='layer',
    add_to_project=True,
    add_xyz=False,
    dxf_unit=0,
    file_list=['example'],
)
print(result.ok, result.output, result.message)

export

Export vector layer from project to file (Shapefile, GeoJSON, GPKG, DXF, etc.),Input file array A and output file array must be in one-to-one correspondence with equal count.

  • Exact tool ID:vector_export
  • Recommended call:mls.vector.export(...)
  • Required parameters:output_path, file_list, gpkg_path

Parameters

Parameter Type Required Default Description
source_path string No — Source layer ID to export
target_path string No — Output file path
gpkg_path string Yes — GPKG database path
src_wkt string No — Source coordinate system WKT
dst_wkt string No — Target coordinate system WKT for conversion
layer_type string No 'layer' Layer type, default: layer
out_file_suffix string No — Output file suffix, auto-detect from target_path if empty
add_xyz boolean No False Whether to add XYZ coordinates
merge_into_one boolean No False Whether to merge multiple layers into one file
need_fields_filter boolean No False Whether to filter fields
fields array No — List of fields to export
output_path array Yes — Custom output path list for batch export, Custom output path list for batch export (outputPath in struct),For DXF, output_path is a file if merge_into_one=true, otherwise a folder; for XML, output_path must be a file.For other formats, it should be a folder path.\
file_list array Yes — An array containing the input vector paths, Path format should be:D:/data/current_project.lidpkg/layer1

Example

from gvscript import mls

result = mls.vector.export(
    output_path=['D:/data/output'],
    source_path='D:/data/input.LiData',
    target_path='D:/data/input.LiData',
    gpkg_path='D:/data/input.LiData',
    src_wkt='example',
    dst_wkt='example',
    layer_type='layer',
    out_file_suffix='example',
    add_xyz=False,
    merge_into_one=False,
    need_fields_filter=False,
    fields=['example'],
    file_list=['example'],
)
print(result.ok, result.output, result.message)

create_layer

Create a new empty vector layer (point, line, polygon, annotation) in the project GPKG database

  • Exact tool ID:vector_create_layer
  • Recommended call:mls.vector.create_layer(...)
  • Required parameters:gpkg_path, layer_name, geometry_type

Parameters

Parameter Type Required Default Description
gpkg_path string Yes — Path to the GPKG/Lidpkg database file
layer_name string Yes — Name for the new vector layer
geometry_type string Yes — Geometry type: point, line, polygon, or annotation

Example

from gvscript import mls

result = mls.vector.create_layer(
    gpkg_path='D:/data/input.LiData',
    layer_name='example_name',
    geometry_type='example',
)
print(result.ok, result.output, result.message)

results matching ""

    No results matching ""