Skip to content

Commit e4acf13

Browse files
authored
Merge pull request #6 from JuliaGeo/fixes
Fixes
2 parents 8b65dae + f91b238 commit e4acf13

16 files changed

Lines changed: 1186 additions & 164 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags: ['*']
8+
pull_request:
9+
10+
jobs:
11+
build:
12+
permissions:
13+
contents: write
14+
statuses: write
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v6
18+
- uses: julia-actions/setup-julia@v2
19+
with:
20+
version: '1'
21+
- name: Install dependencies
22+
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
23+
- name: Build and deploy
24+
env:
25+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
run: julia --project=docs/ docs/make.jl

Project.toml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
name = "CFCoordinateReferenceSystems"
22
uuid = "fed75b75-709c-453e-a27b-7a1357b6667b"
3-
authors = ["Rafael Schouten <rafaelschouten@gmail.com>", "Anshul Singhvi <anshulsinghvi@gmail.com>", "and contributors"]
43
version = "0.1.0"
4+
authors = ["Rafael Schouten <rafaelschouten@gmail.com>", "Anshul Singhvi <anshulsinghvi@gmail.com>", "and contributors"]
55

66
[deps]
77
GeoFormatTypes = "68eda718-8dee-11e9-39e7-89f7f65f511f"
8-
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
98
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
9+
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
1010

1111
[weakdeps]
1212
Proj = "c94c279d-25a6-4763-9509-64d165bea63e"
@@ -16,22 +16,18 @@ CFCoordinateReferenceSystemsProjExt = "Proj"
1616

1717
[compat]
1818
Aqua = "0.8"
19-
ArchGDAL = "0.9, 0.10"
2019
GeoFormatTypes = "0.4"
21-
JET = "0.9"
2220
JSON3 = "1"
2321
OrderedCollections = "1.8"
2422
Proj = "1.8"
2523
SafeTestsets = "0.1"
2624
Test = "1"
27-
julia = "1.9"
25+
julia = "1.10"
2826

2927
[extras]
3028
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
31-
ArchGDAL = "c9ce4bd3-c3d5-55b8-8973-c0e20141b8c3"
32-
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
3329
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
3430
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
3531

3632
[targets]
37-
test = ["Aqua", "ArchGDAL", "JET", "Proj", "SafeTestsets", "Test"]
33+
test = ["Aqua", "Proj", "SafeTestsets", "Test"]

README.md

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,42 @@
11
# CFCoordinateReferenceSystems
22

3-
[![Build Status](https://github.com/rafaqz/CFCoordinateReferenceSystems.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/rafaqz/CFCoordinateReferenceSystems.jl/actions/workflows/CI.yml?query=branch%3Amain)
4-
[![Coverage](https://codecov.io/gh/rafaqz/CFCoordinateReferenceSystems.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/rafaqz/CFCoordinateReferenceSystems.jl)
3+
[![Build Status](https://github.com/JuliaGeo/CFCoordinateReferenceSystems.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/JuliaGeo/CFCoordinateReferenceSystems.jl/actions/workflows/CI.yml?query=branch%3Amain)
4+
[![Coverage](https://codecov.io/gh/JuliaGeo/CFCoordinateReferenceSystems.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/JuliaGeo/CFCoordinateReferenceSystems.jl)
5+
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://JuliaGeo.github.io/CFCoordinateReferenceSystems.jl/stable/)
6+
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://JuliaGeo.github.io/CFCoordinateReferenceSystems.jl/dev/)
57
[![Aqua](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)
68

7-
A library to parse CF coordinate reference systems (as `Dict`s) to ProjJSON conversions, and utilities to take
8-
that to other coordinate systems via ArchGDAL.jl (or Proj.jl in future).
9+
A library to convert between CF (Climate and Forecast) convention grid mappings and other coordinate reference system formats via [Proj.jl](https://github.com/JuliaGeo/Proj.jl).
10+
11+
## Features
12+
13+
- Convert CF grid mapping attributes to ProjJSON, WKT, ProjString, and other CRS formats
14+
- Convert from other CRS formats back to CF grid mappings
15+
- Supports 15+ projection types including Transverse Mercator, Lambert Conformal Conic, Polar Stereographic, and more
916

1017
## Quick start
1118

12-
Let's say you have an `NCDataset` and your variable's `grid_mapping_name` is `mapping`. Then,
19+
Convert CF grid mapping attributes from a NetCDF file to ProjJSON:
1320
```julia
14-
NCDatasets.attr(dataset["mapping"]) |> CFProjection |> ProjJSON
21+
using CFCoordinateReferenceSystems, NCDatasets, GeoFormatTypes
22+
23+
# Read grid mapping attributes from NetCDF
24+
attrs = NCDatasets.attribs(dataset["crs"])
25+
cf = CFProjection(attrs)
26+
27+
# Convert to ProjJSON
28+
projjson = convert(ProjJSON, cf)
29+
30+
# Or convert to other formats via Proj.jl
31+
wkt = convert(WellKnownText, cf)
32+
projstring = convert(ProjString, cf)
1533
```
16-
will get you ProjJSON, from where you can convert to anything.
1734

18-
Going the other way is not yet supported but will be soon. All the functionality is in place - we just
19-
need the ability to match arbitrary CRS'es with the CF compatible ones.
35+
Convert from other CRS formats to CF:
36+
```julia
37+
using Proj
38+
39+
# From an existing CRS
40+
crs = Proj.CRS("EPSG:32615")
41+
cf = convert(CFProjection, WellKnownText(crs))
42+
```

docs/Project.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[deps]
2+
CFCoordinateReferenceSystems = "fed75b75-709c-453e-a27b-7a1357b6667b"
3+
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
4+
GeoFormatTypes = "68eda718-8dee-11e9-39e7-89f7f65f511f"
5+
Proj = "c94c279d-25a6-4763-9509-64d165bea63e"
6+
7+
[compat]
8+
Documenter = "1"
9+
GeoFormatTypes = "0.4"
10+
Proj = "1.8"

docs/make.jl

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Documenter
2+
using CFCoordinateReferenceSystems
3+
4+
# Load extension for docstrings
5+
using Proj
6+
7+
makedocs(;
8+
modules=[CFCoordinateReferenceSystems],
9+
authors="Rafael Schouten, Anshul Singhvi, and contributors",
10+
sitename="CFCoordinateReferenceSystems.jl",
11+
format=Documenter.HTML(;
12+
canonical="https://JuliaGeo.github.io/CFCoordinateReferenceSystems.jl",
13+
edit_link="main",
14+
assets=String[],
15+
),
16+
pages=[
17+
"Home" => "index.md",
18+
"API Reference" => "api.md",
19+
],
20+
warnonly=[:missing_docs],
21+
)
22+
23+
deploydocs(;
24+
repo="github.com/JuliaGeo/CFCoordinateReferenceSystems.jl",
25+
devbranch="main",
26+
)

docs/src/api.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# API Reference
2+
3+
## Types
4+
5+
```@docs
6+
CFProjection
7+
```
8+
9+
## Conversion Methods
10+
11+
When Proj.jl is loaded, the following conversion methods become available:
12+
13+
### CF to Other Formats
14+
15+
```julia
16+
convert(::Type{ProjJSON}, cf::CFProjection) -> ProjJSON
17+
convert(::Type{WellKnownText}, cf::CFProjection) -> WellKnownText
18+
convert(::Type{ProjString}, cf::CFProjection) -> ProjString
19+
```
20+
21+
Convert a `CFProjection` to various CRS formats. The conversion first produces ProjJSON, then uses Proj.jl to convert to other formats as needed.
22+
23+
### Other Formats to CF
24+
25+
```julia
26+
convert(::Type{CFProjection}, gf::GeoFormat) -> CFProjection
27+
```
28+
29+
Convert from other CRS formats (WKT, ProjJSON, ProjString, etc.) to a CF grid mapping.
30+
31+
## Index
32+
33+
```@index
34+
```

docs/src/index.md

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# CFCoordinateReferenceSystems.jl
2+
3+
A Julia library to convert between CF (Climate and Forecast) convention grid mappings and other coordinate reference system formats.
4+
5+
## Overview
6+
7+
The CF conventions define a standard way to describe coordinate reference systems in NetCDF files using grid mapping attributes. This package provides bidirectional conversion between CF grid mappings and other CRS formats (ProjJSON, WKT, ProjString, etc.) via [Proj.jl](https://github.com/JuliaGeo/Proj.jl).
8+
9+
## Installation
10+
11+
```julia
12+
using Pkg
13+
Pkg.add("CFCoordinateReferenceSystems")
14+
```
15+
16+
## Quick Start
17+
18+
### CF to Other Formats
19+
20+
Convert CF grid mapping attributes from a NetCDF file to other CRS formats:
21+
22+
```julia
23+
using CFCoordinateReferenceSystems
24+
using GeoFormatTypes
25+
using Proj
26+
27+
# Create a CFProjection from grid mapping parameters
28+
cf = CFProjection(
29+
"grid_mapping_name" => "transverse_mercator",
30+
"latitude_of_projection_origin" => 0.0,
31+
"longitude_of_central_meridian" => 15.0,
32+
"scale_factor_at_central_meridian" => 0.9996,
33+
"false_easting" => 500000.0,
34+
"false_northing" => 0.0,
35+
)
36+
37+
# Convert to ProjJSON
38+
projjson = convert(ProjJSON, cf)
39+
40+
# Convert to WKT
41+
wkt = convert(WellKnownText, cf)
42+
43+
# Convert to ProjString
44+
projstring = convert(ProjString, cf)
45+
```
46+
47+
### Other Formats to CF
48+
49+
Convert from other CRS formats back to CF grid mappings:
50+
51+
```julia
52+
using CFCoordinateReferenceSystems
53+
using GeoFormatTypes
54+
using Proj
55+
56+
# From an EPSG code via Proj
57+
crs = Proj.CRS("EPSG:32615")
58+
cf = convert(CFProjection, WellKnownText(crs))
59+
60+
# Access the grid mapping parameters
61+
cf["grid_mapping_name"] # "transverse_mercator"
62+
```
63+
64+
### With NCDatasets
65+
66+
Read grid mapping from a NetCDF file:
67+
68+
```julia
69+
using CFCoordinateReferenceSystems
70+
using NCDatasets
71+
using GeoFormatTypes
72+
73+
ds = NCDataset("file.nc")
74+
# Get the grid mapping variable (often named "crs" or similar)
75+
attrs = NCDatasets.attribs(ds["crs"])
76+
cf = CFProjection(attrs)
77+
projjson = convert(ProjJSON, cf)
78+
```
79+
80+
## Supported Projections
81+
82+
The following CF grid mapping names are supported:
83+
84+
| CF Grid Mapping Name | Description |
85+
|---------------------|-------------|
86+
| `latitude_longitude` | Geographic CRS |
87+
| `transverse_mercator` | Transverse Mercator |
88+
| `albers_conical_equal_area` | Albers Equal Area |
89+
| `azimuthal_equidistant` | Azimuthal Equidistant |
90+
| `geostationary` | Geostationary Satellite |
91+
| `lambert_azimuthal_equal_area` | Lambert Azimuthal Equal Area |
92+
| `lambert_conformal_conic` | Lambert Conformal Conic (1SP or 2SP) |
93+
| `lambert_cylindrical_equal_area` | Lambert Cylindrical Equal Area |
94+
| `mercator` | Mercator (variant A or B) |
95+
| `oblique_mercator` | Oblique Mercator |
96+
| `orthographic` | Orthographic |
97+
| `polar_stereographic` | Polar Stereographic (variant A or B) |
98+
| `sinusoidal` | Sinusoidal |
99+
| `stereographic` | Stereographic |
100+
| `vertical_perspective` | Vertical Perspective |
101+
| `rotated_latitude_longitude` | Rotated Pole |
102+
103+
## See Also
104+
105+
- [CF Conventions - Grid Mappings](http://cfconventions.org/cf-conventions/cf-conventions.html#appendix-grid-mappings)
106+
- [Proj.jl](https://github.com/JuliaGeo/Proj.jl)
107+
- [GeoFormatTypes.jl](https://github.com/JuliaGeo/GeoFormatTypes.jl)

ext/CFCoordinateReferenceSystemsProjExt/CFCoordinateReferenceSystemsProjExt.jl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
module CFCoordinateReferenceSystemsProjExt
22

3+
# This extension provides conversion between CF grid mappings and other CRS formats.
4+
#
5+
# The conversion logic and parameter mappings are derived from:
6+
# - pyproj (https://github.com/pyproj4/pyproj) - MIT License
7+
# Specifically pyproj/crs/cf1x8.py for CF-1.8 convention support
8+
# - EPSG Geodetic Parameter Registry (https://epsg.org/)
9+
# EPSG codes identify projection methods and parameters
10+
# - CF Conventions (http://cfconventions.org/cf-conventions/cf-conventions.html)
11+
# Appendix F: Grid Mappings defines the CF parameter names
12+
313
import Proj
414
import JSON3
515
import GeoFormatTypes as GFT
616

717
using OrderedCollections: LittleDict
818
using CFCoordinateReferenceSystems: CFProjection, InnerDict
919

10-
# This extension does most of the work
11-
1220
include("convert.jl")
1321
include("conversions.jl")
1422
include("cf.jl")

0 commit comments

Comments
 (0)