-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 55c89a6
Showing
59 changed files
with
3,922 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
indent = 2 | ||
margin = 120 | ||
always_for_in = true | ||
always_use_return = false | ||
whitespace_typedefs = false | ||
whitespace_in_kwargs = false | ||
whitespace_ops_in_indices = true | ||
remove_extra_newlines = true | ||
trailing_comma = false | ||
normalize_line_endings = "unix" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# LaTeX Stuff | ||
*.bib linguist-generated | ||
*.tex linguist-generated | ||
*.html linguist-generated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# To get started with Dependabot version updates, you'll need to specify which | ||
# package ecosystems to update and where the package manifests are located. | ||
# Please see the documentation for all configuration options: | ||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" # See documentation for possible values | ||
directory: "/" # Location of package manifests | ||
schedule: | ||
interval: "weekly" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: CI | ||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
push: | ||
branches: | ||
- master | ||
tags: '*' | ||
env: | ||
JULIA_NUM_THREADS: 2 | ||
jobs: | ||
test: | ||
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
version: | ||
- '1.9' | ||
- '1' | ||
os: | ||
- ubuntu-latest | ||
- macos-latest | ||
- windows-latest | ||
arch: | ||
- x64 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: julia-actions/setup-julia@v1 | ||
with: | ||
version: ${{ matrix.version }} | ||
arch: ${{ matrix.arch }} | ||
- uses: actions/cache@v3 | ||
env: | ||
cache-name: cache-artifacts | ||
with: | ||
path: ~/.julia/artifacts | ||
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }} | ||
restore-keys: | | ||
${{ runner.os }}-test-${{ env.cache-name }}- | ||
${{ runner.os }}-test- | ||
${{ runner.os }}- | ||
- uses: julia-actions/julia-buildpkg@v1 | ||
- uses: julia-actions/julia-runtest@v1 | ||
- uses: julia-actions/julia-processcoverage@v1 | ||
- uses: codecov/codecov-action@v3 | ||
with: | ||
file: lcov.info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: CompatHelper | ||
on: | ||
schedule: | ||
- cron: 0 0 * * * | ||
workflow_dispatch: | ||
jobs: | ||
CompatHelper: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Pkg.add("CompatHelper") | ||
run: julia -e 'using Pkg; Pkg.add("CompatHelper")' | ||
- name: CompatHelper.main() | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }} | ||
run: julia -e 'using CompatHelper; CompatHelper.main()' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: FormatPR | ||
on: | ||
push: | ||
branches: | ||
- master | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Install JuliaFormatter and format | ||
run: | | ||
julia -e 'import Pkg; Pkg.add("JuliaFormatter")' | ||
julia -e 'using JuliaFormatter; format(".")' | ||
- name: Create Pull Request | ||
id: cpr | ||
uses: peter-evans/create-pull-request@v5 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
commit-message: ":robot: Format .jl files" | ||
title: '[AUTO] JuliaFormatter.jl run' | ||
branch: auto-juliaformatter-pr | ||
delete-branch: true | ||
labels: formatting, automated pr, no changelog | ||
- name: Check outputs | ||
run: | | ||
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" | ||
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: TagBot | ||
on: | ||
issue_comment: | ||
types: | ||
- created | ||
workflow_dispatch: | ||
inputs: | ||
lookback: | ||
default: 3 | ||
permissions: | ||
contents: write | ||
jobs: | ||
TagBot: | ||
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: JuliaRegistries/TagBot@v1 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
ssh: ${{ secrets.DOCUMENTER_KEY }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Manifest.toml | ||
test/data/path.geojson |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021 Júlio Hoffimann <[email protected]> and contributors | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name = "GeoIO" | ||
uuid = "f5a160d5-e41d-4189-8b61-d57781c419e3" | ||
authors = ["Elias Carvalho <[email protected]> and contributors"] | ||
version = "0.1.0" | ||
|
||
[deps] | ||
ArchGDAL = "c9ce4bd3-c3d5-55b8-8973-c0e20141b8c3" | ||
GADM = "a8dd9ffe-31dc-4cf5-a379-ea69100a8233" | ||
GeoInterface = "cf35fbd7-0cd7-5166-be24-54bfbe79505f" | ||
GeoJSON = "61d90e0f-e114-555e-ac52-39dfb47a3ef9" | ||
Meshes = "eacbb407-ea5a-433e-ab97-5258b1ca43fa" | ||
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a" | ||
Shapefile = "8e980c4a-a4fe-5da2-b3a7-4b4b0353a2f4" | ||
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" | ||
|
||
[compat] | ||
ArchGDAL = "0.10" | ||
GADM = "1.0" | ||
GeoInterface = "1.0" | ||
GeoJSON = "0.7" | ||
Meshes = "0.33, 0.34" | ||
PrecompileTools = "1.2" | ||
Shapefile = "0.10" | ||
Tables = "1.7" | ||
julia = "1.9" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# GeoIO.jl | ||
|
||
[![][build-img]][build-url] [![][codecov-img]][codecov-url] | ||
|
||
Load geospatial tables from known file formats and convert the | ||
geometries to [Meshes.jl](https://github.com/JuliaGeometry/Meshes.jl) | ||
geometries that are compatible with the | ||
[GeoStats.jl](https://github.com/JuliaEarth/GeoStats.jl) ecosystem. | ||
|
||
Geometries are loaded from disk in pure Julia whenever possible | ||
using packages such as [Shapefile.jl](https://github.com/JuliaGeo/Shapefile.jl) | ||
and [GeoJSON.jl](https://github.com/JuliaGeo/GeoJSON.jl), or | ||
(down)loaded from the internet using the | ||
[GADM.jl](https://github.com/JuliaGeo/GADM.jl) package. | ||
|
||
## Usage | ||
|
||
### Loading/saving data from/to disk | ||
|
||
The `load` and `save` functions are self-explanatory: | ||
|
||
```julia | ||
using GeoIO | ||
|
||
table = GeoIO.load("file.shp") | ||
|
||
GeoIO.save("file.geojson", table) | ||
``` | ||
|
||
Additional keyword arguments can be passed to `load` and `save` functions. Valid | ||
arguments are those accepted by `GeoJSON.read`, `GeoJSON.write`, `Shapefile.Table`, | ||
`Shapefile.write` and `ArchGDAL.read`. See below some examples: | ||
|
||
```julia | ||
# read `.geojson` geometries with Float64 precision | ||
table = GeoIO.load("file.geojson", numbertype = Float64) | ||
|
||
# force writing on existing `.shp` file | ||
GeoIO.save("file.shp", table, force = true) | ||
``` | ||
|
||
Please read the docstrings for more details. | ||
|
||
### Loading data from GADM | ||
|
||
The `gadm` function (down)loads data from the GADM dataset: | ||
|
||
```julia | ||
julia> GeoIO.gadm("BRA", depth = 1) | ||
``` | ||
|
||
Please read the docstring for more details. | ||
|
||
## Asking for help | ||
|
||
If you have any questions, please [contact our community](https://juliaearth.github.io/GeoStats.jl/stable/about/community.html). | ||
|
||
[build-img]: https://img.shields.io/github/actions/workflow/status/JuliaEarth/GeoIO.jl/CI.yml?branch=master&style=flat-square | ||
[build-url]: https://github.com/JuliaEarth/GeoIO.jl/actions | ||
|
||
[codecov-img]: https://img.shields.io/codecov/c/github/JuliaEarth/GeoIO.jl?style=flat-square | ||
[codecov-url]: https://codecov.io/gh/JuliaEarth/GeoIO.jl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
# ------------------------------------------------------------------ | ||
# Licensed under the MIT License. See LICENSE in the project root. | ||
# ------------------------------------------------------------------ | ||
|
||
module GeoIO | ||
|
||
using Meshes | ||
|
||
import Tables | ||
import Meshes | ||
|
||
import GADM | ||
import Shapefile as SHP | ||
import GeoJSON as GJS | ||
import ArchGDAL as AG | ||
import GeoInterface as GI | ||
|
||
include("conversion.jl") | ||
include("geotable.jl") | ||
include("agwrite.jl") | ||
|
||
""" | ||
load(fname, layer=0, lazy=false, kwargs...) | ||
Load geospatial table from file `fname` and convert the | ||
`geometry` column to Meshes.jl geometries. | ||
Optionally, specify the `layer` of geometries to read | ||
within the file and keyword arguments `kwargs` accepted | ||
by `Shapefile.Table`, `GeoJSON.read` `GeoParquet.read` and | ||
`ArchGDAL.read`. | ||
The option `lazy` can be used to convert geometries on | ||
the fly instead of converting them immediately. | ||
## Supported formats | ||
- `*.shp` via Shapefile.jl | ||
- `*.geojson` via GeoJSON.jl | ||
- Other formats via ArchGDAL.jl | ||
""" | ||
function load(fname; layer=0, lazy=false, kwargs...) | ||
if endswith(fname, ".shp") | ||
table = SHP.Table(fname; kwargs...) | ||
elseif endswith(fname, ".geojson") | ||
data = Base.read(fname) | ||
table = GJS.read(data; kwargs...) | ||
else # fallback to GDAL | ||
data = AG.read(fname; kwargs...) | ||
table = AG.getlayer(data, layer) | ||
end | ||
gtable = GeoTable(table) | ||
lazy ? gtable : Meshes.MeshData(gtable) | ||
end | ||
|
||
""" | ||
save(fname, geotable; kwargs...) | ||
Save geospatial table to file `fname` using the | ||
appropriate format based on the file extension. | ||
Optionally, specify keyword arguments accepted by | ||
`Shapefile.write` and `GeoJSON.write`. For example, use | ||
`force = true` to force writing on existing `.shp` file. | ||
## Supported formats | ||
- `*.shp` via Shapefile.jl | ||
- `*.geojson` via GeoJSON.jl | ||
- Other formats via ArchGDAL.jl | ||
""" | ||
function save(fname, geotable; kwargs...) | ||
if endswith(fname, ".shp") | ||
SHP.write(fname, geotable; kwargs...) | ||
elseif endswith(fname, ".geojson") | ||
GJS.write(fname, geotable; kwargs...) | ||
else # fallback to GDAL | ||
agwrite(fname, geotable; kwargs...) | ||
end | ||
end | ||
|
||
""" | ||
gadm(country, subregions...; depth=0, ϵ=nothing, | ||
min=3, max=typemax(Int), maxiter=10) | ||
(Down)load GADM table using `GADM.get` and convert | ||
the `geometry` column to Meshes.jl geometries. | ||
The `depth` option can be used to return tables for subregions | ||
at a given depth starting from the given region specification. | ||
The options `ϵ`, `min`, `max` and `maxiter` are forwarded to the | ||
`decimate` function from Meshes.jl to reduce the number of vertices. | ||
""" | ||
function gadm(country, subregions...; depth=0, ϵ=nothing, min=3, max=typemax(Int), maxiter=10, kwargs...) | ||
table = GADM.get(country, subregions...; depth=depth, kwargs...) | ||
gtable = GeoTable(table) | ||
𝒯 = values(gtable) | ||
𝒟 = domain(gtable) | ||
𝒩 = decimate(𝒟, ϵ, min=min, max=max, maxiter=maxiter) | ||
meshdata(𝒩, etable=𝒯) | ||
end | ||
|
||
include("precompile.jl") | ||
|
||
end |
Oops, something went wrong.