Simple geographical vector interaction built on top of ArchGDAL. Inspiration from geopandas.
Some basic examples without explanation follow here, for a complete overview, please check the documentation.
]add GeoDataFrames
There's no special type here. You just use normal DataFrame
s with a Vector
of ArchGDAL geometries as a column.
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"])
using DataFrames
coords = zip(rand(10), rand(10))
df = DataFrame(geometry=createpoint.(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 = [(; geom=AG.createpoint(1.0, 2.0), name="test")]
GDF.write(tfn, table; geom_columns=(:geom,),)