Skip to content

Commit

Permalink
Pass on keywords arguments in read to ArchGDAL (#16)
Browse files Browse the repository at this point in the history
* Pass on keywords arguments in `read` to ArchGDAL

* Address minor comments.
  • Loading branch information
evetion authored May 17, 2021
1 parent 17a6888 commit a6ec96b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "GeoDataFrames"
uuid = "62cb38b5-d8d2-4862-a48e-6a340996859f"
authors = ["Maarten Pronk <[email protected]> and contributors"]
version = "0.1.2"
version = "0.1.3"

[deps]
ArchGDAL = "c9ce4bd3-c3d5-55b8-8973-c0e20141b8c3"
Expand Down
29 changes: 23 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

Simple geographical vector interaction built on top of [ArchGDAL](https://github.com/yeesian/ArchGDAL.jl/). Inspiration from geopandas.

** this is a draft, it needs polishing **
** this is a beta, it needs polishing **

# Installation
```julia
]add GeoDataFrame
```

# Usage
Writing
## Writing
```julia
using GeoDataFrames; const GDF=GeoDataFrames
using DataFrames
Expand All @@ -24,7 +24,13 @@ df = DataFrame(geom=createpoint.(coords), name="test");
GDF.write("test_points.shp", df)
```

Reading
You can also set options such as the layername or crs.
```julia
using GeoFormatTypes; const GFT = GeoFormatTypes
GDF.write("test_points.shp", df; layer_name="data", geom_column=:geom, crs=GFT.EPSG(4326))
```

## Reading
```julia
df = GDF.read("test_points.shp")
10×2 DataFrame
Expand All @@ -43,7 +49,18 @@ df = GDF.read("test_points.shp")
10 │ test Geometry: POINT (0.1207370929831
```
Geometric operations
You can also specify the layer index or layer name in opening, useful if there are multiple layers:
```julia
GDF.read("test_points.shp", 0)
GDF.read("test_points.shp", "test_points")
```
Any keywords arguments are passed on to the underlying ArchGDAL [`read`](https://yeesian.com/ArchGDAL.jl/dev/reference/#ArchGDAL.read-Tuple%7BAbstractString%7D) function:
```julia
GDF.read("test.csv", options=["GEOM_POSSIBLE_NAMES=point,linestring", "KEEP_GEOM_COLUMNS=NO"])
```
## Geometric operations
```julia
df.geom = buffer(df.geom, 10);
df
Expand All @@ -63,7 +80,7 @@ df
10 │ test Geometry: POLYGON ((20.937183925
```
Reprojection
## Reprojection
```julia
using GeoFormatTypes; const GFT=GeoFormatTypes
df.geom = reproject(df.geom, GFT.EPSG(4326), GFT.EPSG(28992))
Expand All @@ -84,7 +101,7 @@ df
10 │ Geometry: POLYGON ((-435978.6036 test
```
Plotting
## Plotting
```julia
using Plots
plot(df.geom)
Expand Down
4 changes: 2 additions & 2 deletions src/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const fieldmapping = Dict(v => k for (k, v) in AG._FIELDTYPE)



function read(fn::AbstractString, layer::Union{Integer,AbstractString}=0)
ds = AG.read(fn)
function read(fn::AbstractString, layer::Union{Integer,AbstractString}=0; kwargs...)
ds = AG.read(fn; kwargs...)
layer = AG.getlayer(ds, layer)
table = AG.Table(layer)
df = DataFrame(table)
Expand Down

2 comments on commit a6ec96b

@evetion
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/36960

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.3 -m "<description of version>" a6ec96bb0a2f4dc0f86304e1b67582525e7ac48b
git push origin v0.1.3

Please sign in to comment.