API Reference#

The API Reference provides an overview of all public objects, functions and methods implemented in GeofileOps.

Geometry tools#

apply(input_path, output_path, func[, ...])

Apply a python function on the geometry column of the input file.

apply_vectorized(input_path, output_path, func)

Apply a vectorized python function on the geometry column of the input file.

buffer(input_path, output_path, distance[, ...])

Applies a buffer operation on geometry column of the input file.

clip_by_geometry(input_path, output_path, ...)

Clip all geometries in the input file by the geometry provided.

convexhull(input_path, output_path[, ...])

Applies a convexhull operation on the input file.

delete_duplicate_geometries(input_path, ...)

Copy all rows to the output file, except for duplicate geometries.

dissolve(input_path, output_path, ...[, ...])

Applies a dissolve operation on the input file.

dissolve_within_distance(input_path, ...[, ...])

Dissolve geometries that are within the distance specified.

export_by_bounds(input_path, output_path, bounds)

Export the rows that intersect with the bounds specified.

isvalid(input_path[, output_path, ...])

Checks for all geometries in the geofile if they are valid.

makevalid(input_path, output_path[, ...])

Makes all geometries in the input file valid.

select(input_path, output_path, sql_stmt[, ...])

Execute a SELECT SQL statement on the input file.

simplify(input_path, output_path, tolerance)

Applies a simplify operation on geometry column of the input file.

warp(input_path, output_path, gcps[, ...])

Warp all input features to the output file according to the gcps specified.

Spatial overlays and joins#

clip(input_path, clip_path, output_path[, ...])

Clip the input layer with the clip layer.

difference(input1_path, input2_path, output_path)

Calculate the difference of the input1 layer and input2 layer.

export_by_distance(...[, input1_layer, ...])

Exports all features within the distance specified.

export_by_location(...[, ...])

Exports all features filtered by the specified spatial query.

intersection(input1_path, input2_path, ...)

Calculates the pairwise intersection of the two input layers.

join(input1_path, input2_path, output_path, ...)

Joins two layers based on attribute values.

join_by_location(input1_path, input2_path, ...)

Join two layers based on the spatial relationship between the geometries.

join_nearest(input1_path, input2_path, ...)

Joins features of input1 with the nb_nearest ones in input2.

select_two_layers(input1_path, input2_path, ...)

Execute a SELECT SQL statement on the input files.

identity(input1_path, input2_path, output_path)

Calculates the pairwise identity of the two input layers.

symmetric_difference(input1_path, ...[, ...])

Calculates the pairwise symmetric difference of the two input layers.

union(input1_path, input2_path, output_path)

Calculates the pairwise union of the two input layers.

union_full_self(input_path, output_path, *, ...)

Calculates the "full" union of the features in a layer.

General layer operations#

add_column(*args, **kwargs)

add_columns(*args, **kwargs)

add_layerstyle(path, layer, name, qml[, ...])

Add the layer style to the geofile.

concat(input_paths, output_path[, ...])

Concatenate multiple geofiles into one output geofile.

copy_layer(src, dst[, src_layer, dst_layer, ...])

Copy a layer from a source to a destination dataset.

create_spatial_index(*args, **kwargs)

drop_column(*args, **kwargs)

execute_sql(*args, **kwargs)

get_crs(path[, layer, min_confidence])

Get the CRS (projection) of the file.

get_default_layer(path)

Get the default layer name to be used for a layer in this file.

get_layer_geometrytypes(path[, layer])

Get the geometry types in the layer by examining each geometry in the layer.

get_layerinfo(path[, layer, ...])

Get information about a layer in a geofile.

get_layerstyles(path[, layer, name])

Get the layer styles saved in the geofile.

get_only_layer(path)

Get the layername for a file that only contains one layer.

has_spatial_index(path[, layer, no_geom_ok, ...])

Check if the layer/column has a spatial index.

read_file(path[, layer, columns, bbox, ...])

Reads a file to a geopandas GeoDataframe.

remove_layerstyle(path, id)

Remove a layer style.

remove_spatial_index(*args, **kwargs)

rename_column(*args, **kwargs)

rename_layer(*args, **kwargs)

update_column(*args, **kwargs)

to_file(gdf, path[, layer, ...])

Writes a pandas dataframe to file.

General file operations#

cmp(path1, path2)

Compare if two geofiles are identical.

copy(src, dst[, keep_permissions])

Copies the geofile from src to dst.

get_driver(path)

Get the gdal driver name for the file specified.

listlayers(path[, only_spatial_layers])

Get the list of layers in a geofile.

move(src, dst)

Moves the geofile from src to dst.

unzip_geofile(input_path, output_path)

Unzip a zipped geofile and return the path to the unzipped geofile.

remove(path[, missing_ok])

Removes the geofile.

zip_geofile(input_path, output_path)

Zip a geofile to a seek-optimized zip file.

Classes#

BufferEndCapStyle(*values)

Enumeration of the possible end point buffer styles.

BufferJoinStyle(*values)

Enumeration of the available buffer styles for intermediate points.

DataType(*values)

This enum defines the standard data types that can be used for columns.

LayerInfo(name, featurecount, total_bounds, ...)

A data object containing meta-information about a layer.

PrimitiveType(*values)

Enumeration of the different existing primitive types of a geometry.

SimplifyAlgorithm(*values)

Enumeration of the supported simplification algorythms.

TempEnv(envs)

Context manager to temporarily set/change environment variables.

Runtime Options#

Geofileps has several runtime options that can be used to tune its behavior. These can be set using the helper functions below. The runtime options are saved to and read from environment variables, so setting the environment variables directly is also possible.

All helper functions below can be used in two ways:
  1. Permanently set the option by calling the function directly.

  2. Temporarily set the option by using the function as a context manager.

options.set_copy_layer_sqlite_direct(enable)

Enable option to copy data directly in SQLite in copy_layer when possible.

options.set_io_engine(engine)

Set the IO engine to use for reading and writing files to/from GeoDataFrames.

options.set_on_data_error(action)

Set the preferred action to take when a data error occurs.

options.set_remove_temp_files(enable)

Enable or disable removal of temporary files created during operations.

options.set_sliver_tolerance(tolerance)

Tolerance to filter out slivers from overlay operations between polygons.

options.set_subdivide_check_parallel_fraction(...)

For a file being checked in parallel, the fraction of features to check.

options.set_subdivide_check_parallel_rows(rows)

For a file being checked in parallel, the number of rows to check.

options.set_tmp_dir(path)

Set the directory to use for temporary files created during processing.

options.set_worker_type(worker_type)

Set the type of worker to use for parallel processing.