gis-tools-ts
Version:
A collection of geospatial tools primarily designed for WGS84, Web Mercator, and S2.
74 lines • 2.46 kB
TypeScript
import { ShapeFileReader } from './shp';
export * from './dbf';
export * from './shp';
/** 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/mmap';
*
* 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
* @returns - a Shapefile
*/
export declare function shapefileFromPath(input: string): Promise<ShapeFileReader<Record<string, unknown>, import("s2json-spec").Properties, import("s2json-spec").Properties>>;
/**
* # 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/mmap';
* 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
* @returns - a Shapefile
*/
export declare function shapefileFromDefinition(def: Definition): Promise<ShapeFileReader>;
//# sourceMappingURL=mmap.d.ts.map