f/open

Opens files selected with HTML input element.

Parameters:
Name Type Description
files FileList | File | Array.<string> | string

Returned by the files property of the HTML input element.

openOptions Array.<string>

Open options passed to candidate drivers.

VFSHandlers Array.<string>

List of Virtual File System handlers, see https://gdal.org/user/virtual_file_systems.html

Returns:
Type:
Promise.<TypeDefs.DatasetList>

"Promise" returns dataset list and error list.

Examples
// Opening file from file input.
// HTML
<input class="input-file" type="file" name="file" id="file" onChange="onFileChange" />
// JS
function onFileChange({ target }) {
  const result = await Gdal.open(target.file);
}
// Opening files from file input. (multiple)
// HTML
<input class="input-file" type="file" name="files[]" id="file" onChange="onFileChange" multiple />
// JS
function onFileChange({ target }) {
  const result = await Gdal.open(target.files);
}
// Opening a file from the network.
const fileData = await fetch('test/polygon.geojson');
const file = new File([await fileData.blob()], "polygon.geojson");
const result = await Gdal.open(file);
// Opening a file using the virtual file system handler, ie. /vsicurl/ or /vsizip/.
// One common scenario is a .zip shapefile
const result = await Gdal.open(file, [], ['vsizip']);
// Opening a file from filesystem on Node.js.
const result = await Gdal.open('test/polygon.geojson');
// Opening a file from filesystem on Node.js with open options.
const result = await Gdal.open('test/points.csv', ['X_POSSIBLE_NAMES=lng', 'Y_POSSIBLE_NAMES=lat']);
// Opening files from filesystem on Node.js.
const result = await Gdal.open(['test/polygon.geojson', 'test/line.geojson']);
// Opening files from virtual gdal3.js path.
// * Opened files are saved in the /input/... virtual path.
// * Converted files are saved in the /output/... virtual path.
const result = await Gdal.open('/output/polygon.geojson');
const result2 = await Gdal.open('/input/polygon.geojson');