|
| 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) |
0 commit comments