Skip to content

API

GeoDataFrames.read Function
julia
read(driver::GeoParquetDriver, fn::AbstractString; kwargs...)

Read fn using the GeoParquetDriver driver. Any additional keyword arguments are passed to Parquet2.read.

source
julia
read(driver::FlatGeobufDriver, fn::AbstractString; kwargs...)

Read fn using the FlatGeobufDriver driver.

source
julia
read(driver::GeoArrowDriver, fn::AbstractString; kwargs...)

Read fn using the GeoArrowDriver driver. Any additional keyword arguments are passed to Arrow.read.

source
julia
read(driver::GeoJSONDriver, fn::AbstractString; kwargs...)

Read fn using the GeoJSONDriver driver.

source
julia
read(fn::AbstractString; kwargs...)

Read a file into a DataFrame. Any kwargs are passed to the driver, by default set to ArchGDALDriver.

Returns a DataFrame whose geometry column(s) hold GeoInterface.jl compatible geometries, with the coordinate reference system and geometry column names stored as table metadata.

Example

julia
julia> df = DataFrame(geometry = GeoInterface.Point.([(1.0, 2.0), (3.0, 4.0)]), name = ["a", "b"]);

julia> path = GeoDataFrames.write(joinpath(tempdir(), "example.gpkg"), df);

julia> df2 = GeoDataFrames.read(path);

julia> names(df2)
2-element Vector{String}:
 "geometry"
 "name"
source
julia
read(driver::AbstractDriver, fn::AbstractString; kwargs...)

Read a file into a DataFrame using the specified driver. Any kwargs are passed to the driver, by default set to ArchGDALDriver. Returns a DataFrame.

source
julia
read(driver::ArchGDALDriver, fn::AbstractString; layer::Union{Integer,AbstractString}, kwargs...)

Read a file into a DataFrame using the ArchGDAL driver. By default you only get the first layer, unless you specify either the index (0 based) or name (string) of the layer. Other supported kwargs are passed to the ArchGDAL read method. The options keyword argument can be used to pass GDAL open options. Returns a DataFrame.

source
GeoDataFrames.write Function
julia
write(driver::GeoParquetDriver, fn::AbstractString, table; kwargs...)

Write the provided table to fn using the GeoParquetDriver driver. Any additional keyword arguments are passed to Parquet2.write.

source
julia
write(driver::FlatGeobufDriver, fn::AbstractString, table; kwargs...)

Write the provided table to fn using the FlatGeobufDriver driver.

Warning

This backend cannot write files yet; it will fall back to ArchGDAL.

source
julia
write(driver::GeoArrowDriver, fn::AbstractString, table; kwargs...)

Write the provided table to fn using the GeoArrowDriver driver. Any additional keyword arguments are passed to Arrow.write.

source
julia
write(driver::GeoJSONDriver, fn::AbstractString, table; kwargs...)

Write the provided table to fn using the GeoJSONDriver driver.

source
julia
write(fn::AbstractString, table; kwargs...)

Write the provided table to fn. A driver is selected based on the extension of fn.

Returns the path fn that was written.

Example

julia
julia> df = DataFrame(geometry = GeoInterface.Point.([(1.0, 2.0), (3.0, 4.0)]), name = ["a", "b"]);

julia> path = GeoDataFrames.write(joinpath(tempdir(), "example.gpkg"), df);

julia> isfile(path)
true
source
julia
write(driver::AbstractDriver, fn::AbstractString, table; kwargs...)

Write the provided table to fn using the specified driver. Any kwargs are passed to the driver, by default set to ArchGDALDriver. Returns the path fn that was written.

source
julia
write(driver::ArchGDALDriver, fn::AbstractString, table; layer_name="data", crs::Union{GFT.GeoFormat,Nothing}=getcrs(table), driver::Union{Nothing,AbstractString}=nothing, options::Dict{String,String}=Dict(), geom_columns::Tuple{Symbol}=getgeometrycolumns(table), kwargs...)

Write the provided table to fn using the ArchGDAL driver. Returns the path fn that was written.

source

Drivers

The following drivers are provided:

GeoDataFrames.GeoJSONDriver Type
julia
GeoJSONDriver()

Driver for reading and writing GeoJSON files, backed by the GeoJSON package. Load GeoJSON to enable it.

source
GeoDataFrames.ShapefileDriver Type
julia
ShapefileDriver()

Driver for reading and writing ESRI Shapefiles, backed by the Shapefile package. Load Shapefile to enable it.

source
GeoDataFrames.GeoParquetDriver Type
julia
GeoParquetDriver()

Driver for reading and writing (Geo)Parquet files, backed by the GeoParquet package. Load GeoParquet to enable it.

source
GeoDataFrames.FlatGeobufDriver Type
julia
FlatGeobufDriver()

Driver for reading and writing FlatGeobuf files, backed by the FlatGeobuf package. Load FlatGeobuf to enable it.

source
GeoDataFrames.ArchGDALDriver Type
julia
ArchGDALDriver()

Default driver, backed by the ArchGDAL package. Supports a wide range of formats and is always available, requiring no extra package to be loaded.

source
GeoDataFrames.GeoArrowDriver Type
julia
GeoArrowDriver()

Driver for reading and writing (Geo)Arrow files, backed by the GeoArrow package. Load GeoArrow to enable it.

source

These can be passed to the read and write functions as the first argument, but require the corresponding package to be loaded. You can find the corresponding package to load in the Package extensions section.

Utility functions

GeoDataFrames.setgeometrycolumn! Function
julia
setgeometrycolumn!(df::DataFrame, column::Symbol)
setgeometrycolumn!(df::DataFrame, columns::Tuple{Vararg{Symbol}})

Set the geometry column(s) of a GeoDataFrame df. Retrieve them with GeoInterface.geometrycolumns(df).

source
GeoDataFrames.setcrs! Function
julia
setcrs!(df::DataFrame, crs)

Set the coordinate reference system of the geometry column(s) of a GeoDataFrame df. Note that this overrides any existing CRS without transforming the geometries. For transforming geometries, use reproject!(df, target_crs) instead.

crs should be one of GeoFormatTypes wrappers, such as EPSG(code). Retrieve it with GeoInterface.crs(df).

source
GeometryOps.reproject Function
julia
reproject(df::DataFrame, target_crs; [always_xy=true,])

Reproject the geometries in a DataFrame df to a new Coordinate Reference System target_crs, from the current CRS. See also reproject(df, source_crs, target_crs) and the in place version reproject!(df, target_crs). always_xy (true by default) can override the default axis mapping strategy of the CRS. If true, input is assumed to be in the traditional GIS order (longitude, latitude). Returns a new DataFrame; the input df is left unchanged.

source
julia
reproject(df::DataFrame, source_crs, target_crs; [always_xy=true])

Reproject the geometries in a DataFrame df from the crs source_crs to a new crs target_crs. This overrides any current CRS of the Dataframe. Returns a new DataFrame; the input df is left unchanged.

source
GeoDataFrames.reproject! Function
julia
reproject!(df::DataFrame, target_crs; [always_xy=true])

Reproject the geometries in a DataFrame df to a new Coordinate Reference System target_crs, from the current CRS, in place. Returns the modified df.

source
julia
reproject!(df::DataFrame, source_crs, target_crs; [always_xy=true])

Reproject the geometries in a DataFrame df from the crs source_crs to a new crs target_crs in place. This overrides any current CRS of the Dataframe. Returns the modified df.

source

GeometryVector

GeoDataFrames.GeometryVector Type
julia
GeometryVector(A::Vector)

A thin wrapper around a Vector of geometries, used as the geometry column type in GeoDataFrames. It behaves like a regular AbstractVector (indexing, mutation, similar), and exists as a distinct type so geometry-specific behaviour (such as a future spatial index) can be attached. Geometry columns returned by read are wrapped in a GeometryVector.

Example

julia
julia> gv = GeoDataFrames.GeometryVector([GeoInterface.Point(1.0, 2.0), GeoInterface.Point(3.0, 4.0)]);

julia> length(gv)
2
source