gis-tools-ts - v0.6.0
    Preparing search index...

    Class ShapeFileReader<M, D, P>

    The Shapefile Reader

    Reads data from a shapefile implementing the FeatureIterator interface

    NOTE: It's recommended to not parse the shapefile directly but instead:

    • import { shapefileFromURL } from 'gis-tools-ts';
    • import { shapefileFromPath } from 'gis-tools-ts/file';

    This ensures the other files paired with the shapefile are loaded to properly handle the projection and properties data.

    import { ShapeFileReader, DataBaseFile, Transformer } from 'gis-tools-ts';
    import { FileReader } from 'gis-tools-ts/file';
    // or use the MMapReader if using Bun:
    // import { MMapReader } from 'gis-tools-ts/mmap';

    const transform = new Transformer();
    const dbf = new DataBaseFile(new FileReader('./data.dbf'), 'utf-8');
    const reader = new ShapeFileReader(new FileReader('./data.shp'), dbf, transform);

    // read all the features
    for await (const feature of reader) {
    console.log(feature);
    }

    Type Parameters

    • M = Record<string, unknown>
    • D extends MValue = MValue
    • P extends Properties = Properties

    Implements

    Index

    Constructors

    • Type Parameters

      • M = Record<string, unknown>
      • D extends Properties = Properties
      • P extends Properties = Properties

      Parameters

      Returns ShapeFileReader<M, D, P>

    Properties

    the dbf file

    transform?: Transformer

    transform mechanics if they exist

    Methods

    • Iterate over all features in the shapefile

      Returns AsyncGenerator<VectorFeature<M, D, P>>

    • Return all the features in the shapefile

      Returns Promise<VectorFeatureCollection<M, D, P>>

      • a collection of VectorFeatures
    • Return a shallow copy of the header data

      Returns SHPHeader

      • a shallow copy of the header data