UNPKG

gis-tools-ts

Version:

A collection of geospatial tools primarily designed for WGS84, Web Mercator, and S2.

79 lines 3.02 kB
import { ShapeFileReader } from './shp.js'; import type { ProjectionTransformDefinition } from '../../proj4/index.js'; export * from './dbf.js'; export * from './shp.js'; /** A description of what relevant files exist and where */ export interface Definition { /** The path to the .shp file */ shp: string; /** The path to the .dbf file. dbf is optional, but needed if you want attributes */ dbf?: string; /** * The path to the .prj file. prj is optional, but needed if your file is in some * projection you don't want it in */ prj?: string; /** * The path to the .cpg file. cpg is optional, but needed if your dbf is in some * weird (non utf8) encoding. */ cpg?: string; } /** * # Build a Shapefile from an input path * * ## Description * Given a path to where all the shapefile relevant files exist, build a Shapefile * * Assumes the input is pointing to a shapefile or name without the extension. * The algorithm will find the rest of the paths if they exist. May also be a gzipped folder. * * ## Usage * ```ts * import { LambertConformalConic, EPSG_9974 } from 'gis-tools-ts'; * import { shapefileFromPath } from 'gis-tools-ts/file'; // or 'gis-tools-ts/mmap' if you are using Bun * * const reader = await shapefileFromPath('path/to/files', [LambertConformalConic], { EPSG_9974 }); * * for await (const feature of reader) { * console.log(feature); * } * ``` * @param input - the path to the .shp file or name without the extension * @param defs - optional array of ProjectionTransformDefinitions to insert * @param epsgCodes - a record of EPSG codes to use for the transformer if needed * @returns - a Shapefile */ export declare function shapefileFromPath(input: string, defs?: ProjectionTransformDefinition[], epsgCodes?: Record<string, string>): Promise<ShapeFileReader>; /** * # Build a Shapefile from a Definition * * ## Description * Given a collection of files, build a Shapefile * * ## Usage * ```ts * import { LambertConformalConic, EPSG_9974 } from 'gis-tools-ts'; * import { shapefileFromDefinition } from 'gis-tools-ts/file'; // Or 'gis-tools-ts/mmap' if you are using Bun * import type { Definition } from 'gis-tools-ts'; * * const def: Definition = { * shp: 'path/to/file.shp', * dbf: 'path/to/file.dbf', * prj: 'path/to/file.prj', * cpg: 'path/to/file.cpg' * }; * * const reader = await shapefileFromDefinition(def, [LambertConformalConic], { EPSG_9974 }); * * for await (const feature of reader) { * console.log(feature); * } * ``` * @param def - a description of the data to parse * @param defs - optional array of ProjectionTransformDefinitions to insert * @param epsgCodes - a record of EPSG codes to use for the transformer if needed * @returns - a Shapefile */ export declare function shapefileFromDefinition(def: Definition, defs?: ProjectionTransformDefinition[], epsgCodes?: Record<string, string>): Promise<ShapeFileReader>; //# sourceMappingURL=file.d.ts.map