Mapshaper file export command - o (output)

Author : admin   2023-03-24 09:55:37 Browse: 1250

Abstract: File output is another of the most basic commands in mapshaper, and it is required for all data operations. Similarly, mapshaper...

File output is another of the most basic commands in mapshaper, and it is required for all data operations. Similarly, mapshaper has done a lot of work on file output, and there are different file settings parameters for different file formats. This article is a compilation, and the version is based on 0.6.x.

- o (output) command

Save the edited content to one or more files. By default, if Mapshaper detects a naming conflict, it automatically appends a suffix to the output file to avoid overwriting the existing file.

Option Parameters

The default - o followed by a file name or directory is used to indicate the name of the output file or directory.

format=shapefile|geojson|topojson|json|dbf|csv|tsv|svg, use format to specify the output format. If the format= option is not set, Mapper attempts to infer the format from the output file name. If no file name is given, Mapper uses the input (- i) file name. When exporting the json format, you export an array of objects that contains the data attributes of each feature.

Target= Specify the layers to export (comma separated). The default target is the output layer of the previous command. Use target=* to specify all layers.

force The output file overwrites the input file (if this option is not set, the input file is not overwritten by default)".

cut table Detaches attribute data from the data and saves it as a JSON file.

drop table Delete attribute data during output.

precision= Rounds all coordinates to the specified precision, such as precision=0.001 Used to reduce the size of a GeoJSON file.

bbox index Export a JSON file that contains the bounding boxes for each output layer.

encoding= (Shapefile/CSV) Sets the encoding (by default, Shapefile encoding is automatically detected, and CSV files default to UTF-8 encoding).

field order='' (Shapefile/CSV) field sorting, such asfield order=ascending``, sorts data fields in alphabetical order (A-Z) of field names.

id field= (Topo/GeoJSON/SVG) Specifies the "id" field (which can be multiple, separated by commas) for GeoJSON, TopoJSON, or SVG functions. When exporting multiple layers, you can transfer a field name list. The first listed name that appears in the layer properties table will be used as the id field for that layer.

bbox (Topo/GeoJSON) Adds the bbox attribute to the top level of the object.

extension= (Topo/GeoJSON) Sets the JSON file extension (the default is ".json").

prettify (Topo/GeoJSON) Formats the output to improve readability.

"singles (TopoJSON) Saves each layer as a separate file. Each output file and the TopoJSON objects it contains are named with the corresponding layer.

Quantization= (TopoJSON) Topology quantization, specifying the maximum topology quantization value. Equivalent to the quantization parameter used by the topoquantize command of TopoJSON. By default, the mapper takes the average segment length *0.02.

no quantization (TopoJSON) Arc coordinates are encoded with full precision, without incremental encoding".

presimplify (TopoJSON) Adds a threshold value for each arc segment vertex at the z position (that is, [x, y, z]), which is used for vertex filtering to dynamically simplify the path. Assuming that W is the width of the map visible in pixels, S is the ratio of the content width to the map visible width, and pz is the pre simplified value of the point, use the following expression to determine whether the point should be excluded from the output path pz>0&&pz<10000/(W * S)

topojson precision= (TopoJSON) Sets the value of topology quantization to 1/average length.

ndjson (GeoJSON/JSON) Outputs a Newline limited record.

ndjson

Gj2008 (GeoJSON) generates output consistent with the pre RFC 7946 GeoJSON specification (dating back to 2008). The polygonal ring is CW and the hole is CCW, which is the opposite of the default RFC 7946 compatible output. Mapshaper's default GeoJSON output is now compatible with the current specification (RFC 7946).

Combine layers (GeoJSON) Merges multiple output layers into a single GeoJSON file.

Geojson type= (GeoJSON) Overrides the default output type. Possible values: "FeatureCollection", "GeometryCollection", "Feature" (for a single feature).

Width= (SVG/TopoJSON) Sets the width of the output dataset in pixels. When used with TopoJSON output, this option switches the output coordinates from geographical units to pixels and flips the Y axis. SVG output is always in pixels (the default SVG width is 800).

Height= (SVG/TopoJSON) is similar to the width option. If both height and width are set, the content is centered within the [0, 0, width, height] bounding box.

Max height= (SVG/TopoJSON) Limits the maximum output height in pixels.

Margin= (SVG/TopoJSON) Sets the margin between coordinate data and viewport edges (the default is 1). To assign different margins to each side, pass a list of values in order(similar to options in bbox=other commands).

Pixels= (SVG/TopoJSON) The output area in pixels (the effect width= the same).

id prefix= Adds a prefix to the namespace layer and feature ID.

svg data= (SVG) Export the data field list as an SVG data -* attribute. The attribute name should match the following regular expression pattern:/^ [a-z_] [a-z0-9_ -] * $/ Unqualified fields were skipped.

svg scale= (SVG) Scales the SVG output using the geographic units of each pixel (the width= option of SVG can be replaced with this option).

point symbol=square (SVG) Use a square to symbolize point data (the default circle).

delimiter= (CSV) Sets the field separator for CSV/delimited text output; For example, delimiter=|.

decimal comma (CSV) uses commas to mark the digit division.

Results

Example

# Convert all shp files in the data directory to geojson files
mapshaper data/*.shp -o geojson/ format=geojson
    Sign in for comments!
Comment list (0)

Powered by TorCMS (https://github.com/bukun/TorCMS).