Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide Interactive Datasets for REPL usage #76

Merged
merged 173 commits into from
Dec 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
173 commits
Select commit Hold shift + click to select a range
df4ff11
initial commit
yeesian Jan 23, 2019
a412f15
getgeomfield returns an internal reference
yeesian Jan 23, 2019
f80509f
bugfix
yeesian Jan 23, 2019
10e7aea
getspatialref returns an internal reference
yeesian Jan 23, 2019
e86f075
remove type-parametric version of unsafe_getspatialref
yeesian Jan 23, 2019
f78077f
bugfix
yeesian Jan 23, 2019
50e6dc8
introduce unsafe_clone method for SpatialRef
yeesian Jan 23, 2019
e81af7c
interactive types should not clone in the constructor
yeesian Jan 23, 2019
d831626
strings will be cast into vectors inside fromWKT
yeesian Jan 23, 2019
10eeeb4
remove unneeded call to GDAL.__init__()
yeesian Jan 23, 2019
acd5612
re-enable tests
yeesian Jan 23, 2019
91ecc69
deprecate registerdrivers() and introduce environment()
yeesian Jan 23, 2019
92d4e7c
update tests
yeesian Jan 23, 2019
54e4b8a
update docs
yeesian Jan 23, 2019
52ad376
typo
yeesian Jan 23, 2019
b0055af
add do-block version of getspatialref
yeesian Jan 23, 2019
bf8253b
add interactive versions of read and createcopy
yeesian Jan 29, 2019
85ced77
add interactive version of create()
yeesian Jan 29, 2019
a62845f
bugfix of executesql for IDataset
yeesian Jan 29, 2019
a1e7010
featurelayers now maintain a reference to their datasets
yeesian Jan 29, 2019
9ce5276
RasterBands now maintain a reference to their datasets
yeesian Jan 29, 2019
cd07836
update test
yeesian Feb 2, 2019
3179fbb
add docstrings
yeesian Feb 5, 2019
fc187b3
misc updates
yeesian Feb 5, 2019
04457bb
80 character line limit
yeesian Feb 5, 2019
6fe5d4b
update to dataset API
yeesian Mar 6, 2019
de55eaa
add documentation job
yeesian Mar 6, 2019
9594792
move Pkg.add("Documenter") into documentation job
yeesian Mar 6, 2019
76d66df
remove parametric methods for spatialref
yeesian Mar 6, 2019
7bbe789
define the docstrings on the safe methods
yeesian Mar 6, 2019
2a99604
consistent whitespacing for all the handle types
yeesian Jul 30, 2019
c5cbba8
consistent whitespacing
yeesian Jul 30, 2019
c73daae
bugfix for releaseresultset(dataset, layer)
yeesian Jul 30, 2019
0bce1bf
[breaking change] create*field! -> write*field!
yeesian Jul 31, 2019
87f0257
add ownedbylayer attribute
yeesian Jul 31, 2019
02c09b9
add reference to rasterband in colortable
yeesian Jul 31, 2019
770ccc2
remove reference to layer in Geometry
yeesian Jul 31, 2019
b7f30d8
[breaking change] disable "setgeomdirectly!(feature, geom)"
yeesian Jul 31, 2019
6e18b8f
setgeomdirectly! -> setgeom!
yeesian Jul 31, 2019
8bf63db
[breaking change] disable setgeomfielddirectly!
yeesian Jul 31, 2019
bf19425
remove unnecessary references
yeesian Jul 31, 2019
088f536
switch to keyword arguments
yeesian Jul 31, 2019
d48dee0
whitespacing
yeesian Jul 31, 2019
6958e92
clone a copy of getcolortable()
yeesian Jul 31, 2019
ff9c11b
[breaking change] remove unsafe feature methods
yeesian Jul 31, 2019
1eeb2a9
make a clone in getspatialref
yeesian Jul 31, 2019
b282449
whitespacing
yeesian Jul 31, 2019
f7a9ed9
remove unsafe parametric methods
yeesian Jul 31, 2019
34df157
whitespacing
yeesian Jul 31, 2019
536a0f5
remove all unsafe behavior
yeesian Jul 31, 2019
0df0c51
add spatialref to IGeometry
yeesian Jul 31, 2019
8199143
[breaking change] disable setspatialref!(geom, spatialref)
yeesian Jul 31, 2019
2eca9d4
[breaking change] remove transform!(geom, spatialref)
yeesian Jul 31, 2019
214f44c
[breaking change] make spatialref an optional (and not keyword) argum…
yeesian Jul 31, 2019
b853a51
[docstring] be more suggestive of in-memory driver names
yeesian Aug 1, 2019
f7ed2b7
[tests] add tests for methods of GDAL vector datasets
yeesian Aug 1, 2019
0fdd385
[breaking] disable getfeaturesread(layer)
yeesian Aug 1, 2019
82ddb57
[bugfix] layer should be invalidated by synctodisk!
yeesian Aug 1, 2019
9d9f164
[breaking] layer will now be reset at the start
yeesian Aug 1, 2019
6ed8469
[breaking] setfeature!(layer, feature) -> writefeature!(layer, feature)
yeesian Aug 1, 2019
0657def
remove unused function
yeesian Aug 1, 2019
ec0f970
[breaking] setattr! -> setattrvalue!
yeesian Aug 1, 2019
cc47392
list untested methods
yeesian Aug 1, 2019
7459ef4
[bugfix] handle cloning of null SRS
yeesian Aug 1, 2019
9e44114
make a clone of the spatialref in getspatialref(gfd::GeomFieldDefn)
yeesian Aug 1, 2019
1d70257
add test for getspatialref(geomfielddefn)
yeesian Aug 1, 2019
2413a6e
whitespacing
yeesian Aug 1, 2019
a4f0173
[bugfix] handle null SRS inside getspatialref(obj)
yeesian Aug 1, 2019
ecdb5f7
[bugfix] handle null geometries in getgeom()
yeesian Aug 1, 2019
4b84de3
[breaking] geomfield -> geom
yeesian Aug 1, 2019
cdfb56c
update docstring
yeesian Aug 1, 2019
2f70b28
[bugfix] handle null pointers in clone(geom)
yeesian Aug 1, 2019
4bb11dc
add tests
yeesian Aug 1, 2019
c5c3e57
[test] list untested methods
yeesian Aug 1, 2019
74888cc
update license to 2019
yeesian Aug 1, 2019
2717d21
[test] add tests for null cases in getspatialref(layer)
yeesian Aug 5, 2019
8b61f9d
[breaking] writefeature!, writefield!, writegeom! -> write!
yeesian Aug 5, 2019
ee888b6
whitespacing
yeesian Aug 5, 2019
3782bfe
createfeature(layer) -> writefeature(layer); add writefielddefn(layer…
yeesian Aug 5, 2019
10b8a6c
add writefielddefn!(layer, ...) method
yeesian Aug 5, 2019
d59cf1d
bugfix
yeesian Aug 5, 2019
c893097
remove repeated calls to the same dataset
yeesian Aug 5, 2019
ce9e65b
[test] add display tests for FeatureDefn, GeomFieldDefn and SpatialRef
yeesian Aug 5, 2019
fd7b496
[breaking] disable layer transaction methods for now
yeesian Aug 5, 2019
31b6ca4
[docs] update docstring
yeesian Aug 5, 2019
5e9cc94
implement writegeomdefn!(layer, ...)
yeesian Aug 5, 2019
6e933b6
bugfix
yeesian Aug 5, 2019
0bf3544
fix docstrings
yeesian Aug 5, 2019
6da592b
[test] add tests for writing and deleting features and geomdefns
yeesian Aug 5, 2019
47ea264
[test] flatten tests
yeesian Aug 5, 2019
14439fa
[test] indentation
yeesian Aug 5, 2019
bcc4b8c
resolve ambiguity between writing and pushing features to layers
yeesian Aug 5, 2019
a2fbbb0
[test] add tests for geometries
yeesian Aug 5, 2019
2c863b6
[docs] add docstrings
yeesian Aug 5, 2019
37d93ab
fix error message strings
yeesian Aug 5, 2019
7bb82ac
[test] add tests for spatialref
yeesian Aug 5, 2019
fea9717
[test] avoid error on appveyor for now
yeesian Aug 5, 2019
4cbf9ce
[test] add tests for displays
yeesian Aug 5, 2019
5b1d4eb
[test] update tests
yeesian Aug 5, 2019
1e076cc
[test] add tests for spatialref
yeesian Aug 5, 2019
1816e37
[test] remove unsafe test
yeesian Aug 5, 2019
3eb1376
[test] add tests for getting and setting SRS attribute values
yeesian Aug 5, 2019
5b51fbe
[breaking] flip the order of the arguments in transform!
yeesian Aug 5, 2019
563eb1e
[test] add tests for transform!()
yeesian Aug 5, 2019
89021bd
[bugfix] add an additional null check
yeesian Aug 5, 2019
fd6a01e
[test] add tests for getspatialref(geom)
yeesian Aug 5, 2019
9e70c28
[breaking] polygonfromedges(lines, besteffort, autoclose, tol) -> pol…
yeesian Aug 5, 2019
e6f7a3d
[test] add test for polygonfromedges
yeesian Aug 5, 2019
d7b4f11
[test] fix test
yeesian Aug 5, 2019
fb2d89b
add spatialref to FeatureLayer
yeesian Aug 5, 2019
0ca0ffe
[breaking] give layers first class treatment
yeesian Aug 6, 2019
d1ecb11
[breaking] releaseresultset(dataset, layer) -> releaseresultset(layer)
yeesian Aug 6, 2019
dd8c768
* addfielddefn!(...), addgeomdefn!(...) -> push!(...)
yeesian Aug 6, 2019
7ada925
push!(featuredefn, ...) -> write!(featuredefn, ...)
yeesian Aug 6, 2019
d1c5347
[breaking] addgeom!(g1, g2) -> push!(g1, g2)
yeesian Aug 6, 2019
1b57b97
[breaking] createcopy(dataset, ...) -> copy(dataset, ...)
yeesian Aug 6, 2019
b6e7f38
bugfix
yeesian Aug 6, 2019
921c35b
whitespacing
yeesian Aug 6, 2019
09609d8
introduce IFeatureLayer and IRasterBand
yeesian Aug 6, 2019
cf6dafd
whitespacing
yeesian Aug 6, 2019
3ce07cc
[breaking] disable synctodisk!(layer) and flushcache!(band)
yeesian Aug 6, 2019
4ebec9a
[breaking] disable untested methods for now
yeesian Aug 6, 2019
c8ef793
[docs] update docstrings
yeesian Aug 6, 2019
85d5b2c
[breaking] getblocksize(band) -> blocksize(band)
yeesian Aug 6, 2019
2fe88ca
[breaking] getdatatype(band) -> pixeltype(band), getaccess(band) -> a…
yeesian Aug 6, 2019
bc5521b
[docs] update docstring
yeesian Aug 6, 2019
4e13270
[breaking] getnumber(band) -> indexofband(band)
yeesian Aug 6, 2019
a142262
[breaking] getrowindex(rat, pxvalue) -> findrowindex(rat, pxvalue)
yeesian Aug 6, 2019
d8558d9
[breaking] getcolumnindex -> findcolumnindex
yeesian Aug 6, 2019
945d3ba
[docs] update docstring
yeesian Aug 6, 2019
47159db
[breaking] getfieldindex -> findfieldindex
yeesian Aug 6, 2019
2fcc801
[breaking] getgeomindex -> findgeomindex
yeesian Aug 6, 2019
8ca170e
[breaking] indexofband -> indexof, find -> findstylestring
yeesian Aug 6, 2019
94ed6c9
update principles in README
yeesian Aug 6, 2019
f77009d
update documentation for new principles
yeesian Aug 6, 2019
37be454
[new] Introduce FeatureDefnView <: AbstractFeatureDefn
yeesian Aug 6, 2019
f0f4e74
code linting
yeesian Aug 6, 2019
106889d
code linting
yeesian Aug 6, 2019
835893e
Introduce IGeomFieldDefnView <: AbstractGeomFieldDefn, and rename Fea…
yeesian Aug 6, 2019
7553074
return objects after they are destroyed
yeesian Aug 6, 2019
605392a
[new] Introduce IFieldDefnView <: AbstractFieldDefn
yeesian Aug 6, 2019
40997c1
update docstring
yeesian Aug 7, 2019
2536f9e
code linting
yeesian Aug 7, 2019
fdfb73e
update documentation
yeesian Aug 7, 2019
3a4d929
bugfix
yeesian Aug 7, 2019
aedb567
standardize on addfielddefn! and addgeomdefn!
yeesian Aug 7, 2019
a866c3e
[breaking] getcolumnname -> columnname, getcolumnusage -> columnusage…
yeesian Aug 7, 2019
3f836f1
[breaking] getcurvegeom -> curvegeom, getlineargeom -> lineargeom
yeesian Aug 7, 2019
a2f5c2e
[breaking] getdim(geom) -> geomdim(geom)
yeesian Aug 7, 2019
0ab711d
[breaking] getenvelope -> envelope, getenvelope3d -> envelope3d
yeesian Aug 7, 2019
4c5e322
[breaking] getextent(...) -> envelope(...)
yeesian Aug 7, 2019
95147c7
[breaking] move back from push to add, and from write to create/set
yeesian Aug 7, 2019
febf9d1
[breaking] getfidcolname(layer) -> fidcolumnname(layer)
yeesian Aug 7, 2019
cb34354
[breaking] getgeomcolname(layer) -> geomcolumnname(layer)
yeesian Aug 7, 2019
9e27005
[breaking] getgeomname(geom) -> geomname(geom)
yeesian Aug 7, 2019
786b95c
[breaking] getlayerdefn(layer) -> layerdefn(layer)
yeesian Aug 7, 2019
3894c0f
[breaking] getmaskflags/getmaximum/getminimum(band) -> maskflags/maxi…
yeesian Aug 7, 2019
e6743bf
[breaking] getpaletteinterp(colortable) -> paletteinterp(colortable)
yeesian Aug 7, 2019
6491c52
[breaking] getrgba(...) -> toRGBA(...)
yeesian Aug 7, 2019
c75f0af
[breaking] getsampleoverview(...) -> sampleoverview(...)
yeesian Aug 7, 2019
6da1bf6
[test] update for GDAL 3.0.0
visr Jun 1, 2019
3082ac1
[bugfix] handle null geometries
yeesian Aug 7, 2019
89f4c5a
[test] fix more tests for GDAL 3.0
yeesian Aug 7, 2019
f82c53a
Update to new GDAL.jl API (#85)
yeesian Aug 21, 2019
ebcd7c8
aftercare, update for GDAL.jl#75 (#87)
visr Aug 24, 2019
56de2b7
update CI, docs and pkg tomls
visr Sep 20, 2019
4e4d4ca
don't finish CI too fast
visr Sep 20, 2019
9aacc86
Update Project.toml
evetion Dec 25, 2019
0926272
Migrated Array interface to idataset.
evetion Dec 25, 2019
14e32f2
Incorporated PR #102 adding an Array constructor
evetion Dec 25, 2019
6c9af60
Incorporated PR #102 adding an Array constructor
evetion Dec 25, 2019
93e4423
move array constructor to separate testset
visr Dec 27, 2019
36107dc
allow future minor GDAL releases
visr Dec 27, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@ os:
- osx
julia:
- 1.0
- 1
- nightly
# matrix:
# allow_failures:
# - julia: nightly
# fast_finish: true
matrix:
allow_failures:
- julia: nightly
notifications:
email: false
# uncomment the following lines to override the default test script
# script:
# - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
# - julia -e 'using Pkg; Pkg.clone(pwd()); Pkg.build("ArchGDAL"); Pkg.test("ArchGDAL"; coverage=true)'
after_success:
- julia -e 'using Pkg; Pkg.add(["Documenter", "Coverage"])'
- julia -e 'using ArchGDAL; cd(dirname(dirname(pathof(ArchGDAL)))); include(joinpath("docs", "make.jl"))'
- julia -e 'using ArchGDAL, Coverage; cd(dirname(dirname(pathof(ArchGDAL)))); Coveralls.submit(process_folder())'
coveralls: true
jobs:
include:
- stage: "Documentation"
julia: 1
os: linux
script:
- julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd()));
Pkg.instantiate()'
- julia --project=docs/ docs/make.jl
after_success: skip
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The ArchGDAL.jl package is licensed under the MIT "Expat" License:

> Copyright (c) 2016: yeesian.
> Copyright (c) 2019: Yeesian Ng, Maarten Pronk, Martijn Visser, and contributors
>
> Permission is hereby granted, free of charge, to any person obtaining
> a copy of this software and associated documentation files (the
Expand Down
9 changes: 6 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name = "ArchGDAL"
uuid = "c9ce4bd3-c3d5-55b8-8973-c0e20141b8c3"
version = "0.2.2"
keywords = ["GDAL", "IO"]
license = "MIT"
desc = "A high level API for GDAL - Geospatial Data Abstraction Library"
version = "0.3.0"

[deps]
DataStreams = "9a8bc11e-79be-5b39-94d7-1ccc349a1a85"
Expand All @@ -10,9 +13,9 @@ GeoInterface = "cf35fbd7-0cd7-5166-be24-54bfbe79505f"

[compat]
DataStreams = "0.4.2"
GDAL = "0.2"
GDAL = "1.0.2"
GeoInterface = "0.4"
julia = "0.7, 1.0"
julia = "1"

[extras]
BinaryProvider = "b99e7846-7c00-51b0-8f62-c81ae34c0232"
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ This package aims to be a complete solution for working with GDAL in Julia, simi
## Principles (The Arch Way)
(adapted from: https://wiki.archlinux.org/index.php/Arch_Linux#Principles)

- **simplicity**: without unnecessary additions or modifications.
(i) Preserves GDAL Data Model, and makes available GDAL/OGR methods without trying to mask them from the user.
(ii) minimal dependencies
- **simplicity**: ArchGDAL tries to avoid unnecessary additions or modifications. It preserves the GDAL Data Model and requires minimal dependencies.
- **modernity**: ArchGDAL strives to maintain the latest stable release versions of GDAL as long as systemic package breakage can be reasonably avoided.
- **pragmatism**: The principles here are only useful guidelines. Ultimately, design decisions are made on a case-by-case basis through developer consensus. Evidence-based technical analysis and debate are what matter, not politics or popular opinion.
- **user-centrality**: Whereas other libraries attempt to be more user-friendly, ArchGDAL shall be user-centric. It is intended to fill the needs of those contributing to it, rather than trying to appeal to as many users as possible.
Expand Down
9 changes: 4 additions & 5 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
environment:
matrix:
- julia_version: 1.0
- julia_version: 1
- julia_version: nightly

platform:
- x86 # 32-bit
- x64 # 64-bit

# # Uncomment the following lines to allow failures on nightly julia
# # (tests will run but not make your overall status red)
# matrix:
# allow_failures:
# - julia_version: nightly
matrix:
allow_failures:
- julia_version: nightly

branches:
only:
Expand Down
6 changes: 6 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[deps]
ArchGDAL = "c9ce4bd3-c3d5-55b8-8973-c0e20141b8c3"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"

[compat]
Documenter = "0.23"
7 changes: 3 additions & 4 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ using Documenter, ArchGDAL

makedocs(
modules = [ArchGDAL],
format = :html,
format = Documenter.HTML(),
sitename = "ArchGDAL.jl",
pages = [
"index.md",
Expand All @@ -11,8 +11,8 @@ makedocs(
"Raster Data" => "rasters.md",
"Geometric Operations" => "geometries.md",
"Spatial Projections" => "projections.md",
"Memory Management" => "memory.md",
"Working with Spatialite" => "spatialite.md"
"Interactive versus Scoped Objects" => "memory.md"
# "Working with Spatialite" => "spatialite.md"
# "Naming Conventions" => "conventions.md", # table between GDAL, GDAL.jl, and ArchGDAL.jl
]

Expand All @@ -23,5 +23,4 @@ deploydocs(
make = nothing,
target = "build",
repo = "github.com/yeesian/ArchGDAL.jl.git",
julia = "1.0"
)
8 changes: 1 addition & 7 deletions docs/src/considerations.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# Design Considerations

## Data Serialization

As modern [builds](https://trac.osgeo.org/gdal/wiki/BuildHints) of GDAL (e.g. by [Homebrew](https://github.com/OSGeo/homebrew-osgeo4mac) and [Conda-Forge](https://github.com/conda-forge/gdal-feedstock)) comes pre-compiled with support for PROJ.4 and GEOS, one of the goals of `ArchGDAL.jl` is for it to enjoy the full spectrum of GIS functionality, while avoiding the price of data serialization in [duck-typing proposals](https://gist.github.com/sgillies/2217756).

In the long term, this decouples (i) the development and maintenance of a high-level interface for GDAL from (ii) the development and maintenance of other projects relying on customized builds of GDAL. `ArchGDAL.jl` and [`GDAL.jl`](https://github.com/visr/GDAL.jl) are only concerned with (i), and will only be developed and tagged in accordance with [release changes](https://trac.osgeo.org/gdal/wiki/NewsAndStatus) in GDAL's C API.

## Code Defensiveness

Although GDAL provides a unified data model for different data formats, there are still significant differences between their implementations such that each driver is effectively its own application. This has the following implications:
Expand All @@ -14,7 +8,7 @@ Although GDAL provides a unified data model for different data formats, there ar
- Not all capabilities are available for all drivers.
- Performance characteristics may vary significantly depending on the driver.

`ArchGDAL.jl` provides mechanisms similar to those of mapbox/rasterio for setting GDAL's configuration options, and does not maintain its own list of *sanctioned* options for each driver. Although [ongoing work is underway](https://github.com/yeesian/GDALUtils.jl/issues/1) to make this an easier experience for the user, it remains the responsibility of the user to check that a particular configuration exists and works for their choice of driver.
`ArchGDAL.jl` provides mechanisms for setting GDAL's configuration options, and does not maintain its own list of sanctioned options for each driver. Although work is underway to make this an easier experience for the user, it remains the responsibility of the user to check that a particular configuration exists and works for their choice of drivers.

Here's a collection of references for developers who are interested:
- https://trac.osgeo.org/gdal/wiki/ConfigOptions
Expand Down
157 changes: 65 additions & 92 deletions docs/src/datasets.md
Original file line number Diff line number Diff line change
@@ -1,140 +1,113 @@
# GDAL Datasets
# Data Model

## GDAL Datasets

The following code demonstrates the general workflow for reading in a dataset:

```julia
ArchGDAL.registerdrivers() do
ArchGDAL.read(filename) do dataset
# work with dataset
end
ArchGDAL.read(filename) do dataset
# work with dataset
end
```

We defer the discussions on `ArchGDAL.registerdrivers()` and `ArchGDAL.read(filename)` to the sections on [Driver Management](@ref) and [Working with Files](@ref) respectively.

!!! note

In this case, a handle to the dataset is obtained, and no further data was requested. It is only when we run `print(dataset)` that calls will be made through GDAL's C API to obtain information about `dataset` for display.
We defer the discussion on `ArchGDAL.read(filename)` to the section on [Working with Files](@ref).

## Vector Datasets
```@setup vector_example
import ArchGDAL
filepath = download("https://github.com/raw/yeesian/ArchGDALDatasets/307f8f0e584a39a050c042849004e6a2bd674f99/data/point.geojson", "point.geojson")
```
In this section, we work with the [`data/point.geojson`](https://github.com/yeesian/ArchGDALDatasets/blob/307f8f0e584a39a050c042849004e6a2bd674f99/data/point.geojson) dataset via
```@example vector_example
ArchGDAL.registerdrivers() do
ArchGDAL.read(filepath) do dataset
print(dataset)
end
end
In this section, we work with the [`data/point.geojson`](https://github.com/yeesian/ArchGDALDatasets/blob/307f8f0e584a39a050c042849004e6a2bd674f99/data/point.geojson) dataset:
```julia
julia> dataset = ArchGDAL.read("data/point.geojson")
GDAL Dataset (Driver: GeoJSON/GeoJSON)
File(s):
data/point.geojson

Number of feature layers: 1
Layer 0: point (wkbPoint)
```

The display indicates
* the **type** of the object (`GDAL Dataset`)
* the **driver** used to open it (shortname/longname: `GeoJSON/GeoJSON`)
* the **files** that it corresponds to (`point.geojson`)
* the **number of layers** in the dataset, and their brief summary.
* the **files** that it corresponds to (`data/point.geojson`)
* the **number of layers** in the dataset (`1`), and a brief summary of each.

You can also programmatically retrieve them using
* `typeof(dataset)`: the **type** of the object
* `ArchGDAL.filelist(dataset)`: the **files** that it corresponds to
* `ArchGDAL.nlayer(dataset)`: the **number of layers** in the dataset
* `drv = ArchGDAL.getdriver(dataset)`: the **driver** used to open it
* `ArchGDAL.shortname(drv)`: the short name of a driver
* `ArchGDAL.longname(drv)`: the long name of a driver
* `layer = ArchGDAL.getlayer(dataset, i)`: the `i`-th layer in `dataset`.
* `ArchGDAL.getgeomtype(layer)`: the geometry type for `layer` (i.e. `wkbPoint`)
* `ArchGDAL.getname(layer)`: the name of `layer` (i.e. `OGRGeoJSON`)
* `ArchGDAL.nfeature(layer)`: the number of features in `layer` (i.e. `4`)

For more on working with features and vector data, see the Section on `Feature Data`.
* `typeof(dataset)`: the **type** of the object (`GDAL Dataset`)
* `ArchGDAL.filelist(dataset)`: the **files** that it corresponds to (`["data/point.geojson"]`)
* `ArchGDAL.nlayer(dataset)`: the **number of layers** in the dataset (`1`)
* `driver = ArchGDAL.getdriver(dataset)`: the **driver** used to open it
* `ArchGDAL.shortname(driver)`: the **short name** of a driver (`"GeoJSON"`)
* `ArchGDAL.longname(driver)`: the **long name** of a driver (`"GeoJSON"`)
* `layer = ArchGDAL.getlayer(dataset, i)`: the `i`-th layer in the dataset.
* `ArchGDAL.getgeomtype(layer)`: the **geometry type** for `layer` (i.e. `wkbPoint`)
* `ArchGDAL.getname(layer)`: the **name** of `layer` (i.e. `point`)
* `ArchGDAL.nfeature(layer)`: the **number of features** in the `layer` (i.e. `4`)

For more on working with features and vector data, see the Section on [Feature Data](@ref).

## Raster Datasets
```@setup raster_example
import ArchGDAL
filepath = download("https://github.com/yeesian/ArchGDALDatasets/blob/307f8f0e584a39a050c042849004e6a2bd674f99/gdalworkshop/world.tif?raw=true", "world.tif")
```
In this section, we work with the [`gdalworkshop/world.tif`](https://github.com/yeesian/ArchGDALDatasets/blob/307f8f0e584a39a050c042849004e6a2bd674f99/gdalworkshop/world.tif) dataset:
```@example raster_example
ArchGDAL.registerdrivers() do
ArchGDAL.read(filepath) do dataset
print(dataset)
end
end
```julia
julia> dataset = AG.read("gdalworkshop/world.tif")
GDAL Dataset (Driver: GTiff/GeoTIFF)
File(s):
gdalworkshop/world.tif

Dataset (width x height): 2048 x 1024 (pixels)
Number of raster bands: 3
[GA_ReadOnly] Band 1 (Red): 2048 x 1024 (UInt8)
[GA_ReadOnly] Band 2 (Green): 2048 x 1024 (UInt8)
[GA_ReadOnly] Band 3 (Blue): 2048 x 1024 (UInt8)
```

The display indicates
* the **type** of the object (`GDAL Dataset`)
* the **driver** used to open it (shortname/longname: `GTiff/GeoTIFF`)
* the **files** that it corresponds to (`world.tif`)
* the **number of raster bands** in the dataset, and their brief summary.
* the **files** that it corresponds to (`gdalworkshop/world.tif`)
* the **number of raster bands** in the dataset (`3`), and a brief summary of each.

You can also programmatically retrieve them using
* `typeof(dataset)`: the type of the object
* `ArchGDAL.filelist(dataset)`: the files that it corresponds to
* `ArchGDAL.nraster(dataset)`: the number of rasters
* `typeof(dataset)`: the **type** of the object (`GDAL Dataset`)
* `ArchGDAL.filelist(dataset)`: the **files** that it corresponds to (`["gdalworkshop/world.tif"]`)
* `ArchGDAL.nraster(dataset)`: the **number of rasters** (`3`)
* `ArchGDAL.width(dataset)` the width (`2048` pixels)
* `ArchGDAL.height(dataset)` the height (`1024` pixels)
* `drv = ArchGDAL.getdriver(dataset)`: the driver used to open it
* `ArchGDAL.shortname(drv)`: the short name of a driver
* `ArchGDAL.longname(drv)`: the long name of a driver
* `driver = ArchGDAL.getdriver(dataset)`: the **driver** used to open it
* `ArchGDAL.shortname(driver)`: the **short name** of a driver (`"GTiff"`)
* `ArchGDAL.longname(driver)`: the **long name** of a driver (`"GeoTIFF"`)
* `band = ArchGDAL.getband(dataset, i)`: the `i`-th raster band
* `i = ArchGDAL.getnumber(band)`: the index of `band`.
* `ArchGDAL.getaccess(band)`: the access flag (i.e. `GA_ReadOnly`)
* `ArchGDAL.getname(ArchGDAL.getcolorinterp(rasterband))`: the color channel (e.g. `Red`)
* `ArchGDAL.width(band)` the width (`2048` pixels) of the band
* `ArchGDAL.height(band)` the height (`1024` pixels) of the band
* `ArchGDAL.getdatatype(band)`: the pixel type (i.e. `UInt8`)

For more on working with raster data, see the Section on `Raster Data`.

## Driver Management
Before opening a GDAL supported datastore it is necessary to register drivers. Normally this is accomplished with the `GDAL.allregister()` function which registers all known drivers. However, the user will then need to remember to de-register the drivers using `GDAL.destroydrivermanager()` when they're done.
* `i = ArchGDAL.indexof(band)`: the **index** of the raster band.
* `ArchGDAL.accessflag(band)`: the **access flag** (i.e. `GA_ReadOnly`)
* `ArchGDAL.getname(ArchGDAL.getcolorinterp(band))`: the **color channel** (e.g. `Red`)
* `ArchGDAL.width(band)` the **width** of the raster band (`2048` pixels)
* `ArchGDAL.height(band)` the **height** of the raster band (`1024` pixels)
* `ArchGDAL.pixeltype(band)`: the **pixel type** of the raster band (i.e. `UInt8`)

In ArchGDAL, we provide a `registerdrivers()` block, such that

```julia
ArchGDAL.registerdrivers() do
# your code here
end
```
is equivalent to

```julia
GDAL.allregister()
# your code here
GDAL.destroydrivermanager()
```
For more on working with raster data, see the Section on [Raster Data](@ref).

## Working with Files
We provide the following methods for working with files:

* `ArchGDAL.createcopy()`: create a copy of a raster dataset. This is often used with a virtual source dataset allowing configuration of band types, and other information without actually duplicating raster data.
* `ArchGDAL.create()`: creates a new dataset Note: many sequential write-once formats (such as JPEG and PNG) don't implement the `Create()` method but do implement the `CreateCopy()` method. If the driver doesn't implement `CreateCopy()`, but does implement `Create()` then the default `CreateCopy()` mechanism built on calling `Create()` will be used.
* `ArchGDAL.read()`: opens a dataset in read-only mode. The returned dataset should only be accessed by one thread at a time. To use it from different threads, you must add all necessary code (mutexes, etc.) to avoid concurrent use of the object. (Some drivers, such as GeoTIFF, maintain internal state variables that are updated each time a new block is read, preventing concurrent use.)
* `ArchGDAL.copy()`: creates a copy of a dataset. This is often used with a virtual source dataset allowing configuration of band types, and other information without actually duplicating raster data.
* `ArchGDAL.create()`: creates a new dataset.
* `ArchGDAL.read()`: opens a dataset in read-only mode.
* `ArchGDAL.update()`: opens a dataset with the possibility of updating it. If you open a dataset object with update access, it is not recommended to open a new dataset on the same underlying file.

For each one of them, we will call `ArchGDAL.destroy` at the end of the `do`-block which will dispatch to the corresponding GDAL method. For example,
In GDAL, datasets are closed by calling `GDAL.close()`. This will result in proper cleanup, and flushing of any pending writes. Forgetting to call `GDAL.close()` on a dataset opened in update mode in a popular format like `GTiff` will likely result in being unable to open it afterwards.

In ArchGDAL, the closing of datasets is handled by the API and not by the user. ArchGDAL provides two methods for working with datasets.

The first is to use a do-block:
```julia
ArchGDAL.read(filename) do dataset
ArchGDAL.<copy/create/read/update>(...) do dataset
# work with dataset
end
```

will correspond to

The second is to call the method directly:
```julia
dataset = ArchGDAL.unsafe_read(filename)
dataset = ArchGDAL.<copy/create/read/update>(...)
# work with dataset
ArchGDAL.destroy(dataset) # the equivalent of GDAL.close(dataset.ptr)
```

!!! note

In GDAL, datasets are closed by calling `GDAL.close()`. This will result in proper cleanup, and flushing of any pending writes. Forgetting to call `GDAL.close()` on a dataset opened in update mode in a popular format like `GTiff` will likely result in being unable to open it afterwards.

!!! note

This pattern of using `do`-blocks to manage context plays a big way into the way we handle memory in this package. For details, see the section on Memory Management.
Loading