Skip to content
Huidae Cho edited this page Apr 29, 2021 · 26 revisions

Welcome to the projpicker wiki!

Listing all projections

https://gis.stackexchange.com/a/330283

sqlite3 /usr/share/proj/proj.db "SELECT name,auth_name,code FROM projected_crs WHERE auth_name = 'EPSG';"

Notice that names are not unique. For example,

sqlite3 /usr/share/proj/proj.db "select name,auth_name,code from projected_crs where name='WGS84 UTM Sud Fuseau 1'"
WGS84 UTM Sud Fuseau 1|IGNF|WGS84UTM1S
WGS84 UTM Sud Fuseau 1|IGNF|UTM01SW84

auth_name || code is unique.

sqlite3 /usr/share/proj/proj.db "select auth_name||code from projected_crs" | wc
   7401    7401   73596
sqlite3 /usr/share/proj/proj.db "select distinct (auth_name||code) from projected_crs" | wc
   7401    7401   73596

Retrieving projection information

projinfo -o projjson epsg:4326

outputs

PROJJSON:
{
  "$schema": "https://proj.org/schemas/v0.2/projjson.schema.json",
  "type": "GeographicCRS",
  "name": "WGS 84",
  "datum": {
    "type": "GeodeticReferenceFrame",
    "name": "World Geodetic System 1984",
    "ellipsoid": {
      "name": "WGS 84",
      "semi_major_axis": 6378137,
      "inverse_flattening": 298.257223563
    }
  },
  "coordinate_system": {
    "subtype": "ellipsoidal",
    "axis": [
      {
        "name": "Geodetic latitude",
        "abbreviation": "Lat",
        "direction": "north",
        "unit": "degree"
      },
      {
        "name": "Geodetic longitude",
        "abbreviation": "Lon",
        "direction": "east",
        "unit": "degree"
      }
    ]
  },
  "scope": "Horizontal component of 3D system.",
  "area": "World.",
  "bbox": {
    "south_latitude": -90,
    "west_longitude": -180,
    "north_latitude": 90,
    "east_longitude": 180
  },
  "id": {
    "authority": "EPSG",
    "code": 4326
  }
}

Input/output format

We will use JSON and GeoJSON for non-geospatial and geospatial data input and output, respectively.

API

Read latitude and longitude, and return a tuple of

{
  'epsg': epsg_code,
  'proj': proj_code,
  'extent': [[ulx, uly], [urx, ury], [lrx, lry], [llx, lly]]
}

Just four corners may not be enough to correctly represent the boundary of a certain projection on an EPSG:4326 map. Extent will be in coordinates in EPSG:4326.

Spatial indexing

Split the world into a 1-degree grid, and assign indices to rectangles in the grid. Establish a relational table between the grid and projection bounding boxes.

Database schemas

create table projbbox (
  auth_code varchar(100) primary key,
  name varchar(100) not null,
  south_latitude real not null,
  west_longitude real not null,
  north_latitude real not null,
  east_longitude real not null,
)

create table projbbox_to_products (
  id int primary key,
  auth_code varchar(100) not null,
  product varchar(100),
  agency varchar(100)
)

create table grid (
  index int primary key,
  row int not null,
  column int not null
)

create table grid_to_projbbox (
  id int primary key,
  index int not null,
  auth_code varchar(100) not null
)

Discussions

https://github.com/OSGeo/grass/issues/1253#issuecomment-776849517

WKT2 has a optional EXTENT::BBOX attribute -- "the geographic bounding box is an approximate description of location". For a given CRS, it shouldn't be too complicated to implement a qgis-like solution. The other way around, all CRS' for a given coordinate, is more complicated as you need some kind of searchable database for this. There is a SE post on this topic, see the section "EPSG.io" for possible database solution.

Clone this wiki locally