Skip to content

evetion/GeoDataFrames.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

98 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GeoDataFrames

Your Logo

Stable Dev CI codecov

GeoDataFrames provides a simple and efficient way to work with geospatial vector data in Julia. By combining the power of DataFrames with ArchGDAL and native Julia packages such as GeometryOps, it offers a familiar interface for handling geographical data while maintaining Julia's performance advantages. The package supports reading and writing various geospatial formats, making it easy to integrate into your data analysis workflows. GeoDataFrames takes its inspiration from Python's GeoPandas.

Basic examples without explanation follow here, for a complete overview, please check the documentation.

Installation

]add GeoDataFrames

Usage

There's no special type here. You just use normal DataFrames with a Vector of ArchGDAL geometries as a column.

Reading

import GeoDataFrames as GDF
df = GDF.read("test_points.shp")
10×2 DataFrame
 Row │ geometry            name
     │ IGeometr           String
─────┼────────────────────────────
   1 │ Geometry: wkbPoint  test
   2 │ Geometry: wkbPoint  test
   3 │ Geometry: wkbPoint  test
   4 │ Geometry: wkbPoint  test
   5 │ Geometry: wkbPoint  test
   6 │ Geometry: wkbPoint  test
   7 │ Geometry: wkbPoint  test
   8 │ Geometry: wkbPoint  test
   9 │ Geometry: wkbPoint  test
  10 │ Geometry: wkbPoint  test

You can also specify the layer index or layer name in opening, useful if there are multiple layers:

GDF.read("test_points.shp", 0)
GDF.read("test_points.shp", "test_points")

Any keywords arguments are passed on to the underlying ArchGDAL read function:

GDF.read("test.csv", options=["GEOM_POSSIBLE_NAMES=point,linestring", "KEEP_GEOM_COLUMNS=NO"])

Writing

Here we create a vector of points (i.e. tuples of x,y coordinates), place them into a DataFrame, and write to a shapefile

using DataFrames

coords = tuple.(rand(10), rand(10))  
df = DataFrame(geometry=coords, name="test");
GDF.write("test_points.shp", df)

You can also set options such as the layer_name, coordinate reference system, the driver and its options:

GDF.write("test_points.shp", df; layer_name="data", crs=EPSG(4326), driver="FlatGeoBuf", options=Dict("SPATIAL_INDEX"=>"YES"))

Note that any Tables.jl compatible table with GeoInterface.jl compatible geometries can be written by GeoDataFrames. You might want to pass which column(s) contain geometries, or by defining GeoInterface.geometrycolumns on your table. Multiple geometry columns, when enabled by the driver, can be provided in this way.

table = [(; geometry=(118.17, 34.20), name="test")]
GDF.write("test_points.shp", table)

Packages

No packages published

Contributors 9

Languages