vincentsarago / TileMatrixSets

3 stars 1 forks source link

is EuropeanETRS89_LAEAQuad wrong ? #1

Open vincentsarago opened 4 years ago

vincentsarago commented 4 years ago

The EuropeanETRS89_LAEAQuad seems off.

from pyproj.crs import CRS                                                                                                                                                                                                                                                          

CRS.from_epsg(3035)

<Projected CRS: EPSG:3035>
Name: ETRS89 / LAEA Europe
Axis Info [cartesian]:
- Y[north]: Northing (metre)
- X[east]: Easting (metre)
Area of Use:
- name: Europe - ETRS89
- bounds: (-16.1, 32.88, 40.18, 84.17)
Coordinate Operation:
- name: Europe Equal Area 2001
- method: Lambert Azimuthal Equal Area
Datum: European Terrestrial Reference System 1989
- Ellipsoid: GRS 1980
- Prime Meridian: Greenwich
import osr

def invert_axis(crs):
    return crs.EPSGTreatsAsLatLong() or crs.EPSGTreatsAsNorthingEasting()

srs = osr.SpatialReference()
srs.ImportFromEPSGA(3035) 

invert_axis(srs)                                                                                                                                                                                                                                                                   
1

EPSG:3035 seems to use lat,lon order (instead of lon,lat) and thus invert_axis ☝️ return True. While this is ok, we then expect the coordinates in the TMS document to be stored as Y,X and not X,Y as it is right now.

Using morecantile we can create a correct JSON document

$ morecantile custom --epsg 3035 --extent 2000000.0 1000000 6500000 5500000 --minzoom 0 --maxzoom 15 --tile-width 256 --tile-height 256 --identifier EuropeanETRS89_LAEAQuad --title "Lambert Azimuthal Equal Area ETRS89 for Europe"
{
    "type": "TileMatrixSetType",
    "title": "Lambert Azimuthal Equal Area ETRS89 for Europe",
    "identifier": "EuropeanETRS89_LAEAQuad",
    "boundingBox": {
        "type": "BoundingBoxType",
        "crs": "http://www.opengis.net/def/crs/EPSG/0/3035",
        "lowerCorner": [
            1000000.0,
            2000000.0
        ],
        "upperCorner": [
            6500000.0,
            5500000.0
        ]
    },
    "supportedCRS": "http://www.opengis.net/def/crs/EPSG/0/3035",
    "tileMatrix": [
        {
            "type": "TileMatrixType",
            "identifier": "0",
            "scaleDenominator": 62779017.857142866,
            "topLeftCorner": [
                5500000.0,
                2000000.0
            ],
            "tileWidth": 256,
            "tileHeight": 256,
            "matrixWidth": 1,
            "matrixHeight": 1
        },
        {
            "type": "TileMatrixType",
            "identifier": "1",
            "scaleDenominator": 31389508.928571433,
            "topLeftCorner": [
                5500000.0,
                2000000.0
            ],
            "tileWidth": 256,
            "tileHeight": 256,
            "matrixWidth": 2,
            "matrixHeight": 2
        },
        {
            "type": "TileMatrixType",
            "identifier": "2",
            "scaleDenominator": 15694754.464285716,
            "topLeftCorner": [
                5500000.0,
                2000000.0
            ],
            "tileWidth": 256,
            "tileHeight": 256,
            "matrixWidth": 4,
            "matrixHeight": 4
        },
        {
            "type": "TileMatrixType",
            "identifier": "3",
            "scaleDenominator": 7847377.232142858,
            "topLeftCorner": [
                5500000.0,
                2000000.0
            ],
            "tileWidth": 256,
            "tileHeight": 256,
            "matrixWidth": 8,
            "matrixHeight": 8
        },
        {
            "type": "TileMatrixType",
            "identifier": "4",
            "scaleDenominator": 3923688.616071429,
            "topLeftCorner": [
                5500000.0,
                2000000.0
            ],
            "tileWidth": 256,
            "tileHeight": 256,
            "matrixWidth": 16,
            "matrixHeight": 16
        },
        {
            "type": "TileMatrixType",
            "identifier": "5",
            "scaleDenominator": 1961844.3080357146,
            "topLeftCorner": [
                5500000.0,
                2000000.0
            ],
            "tileWidth": 256,
            "tileHeight": 256,
            "matrixWidth": 32,
            "matrixHeight": 32
        },
        {
            "type": "TileMatrixType",
            "identifier": "6",
            "scaleDenominator": 980922.1540178573,
            "topLeftCorner": [
                5500000.0,
                2000000.0
            ],
            "tileWidth": 256,
            "tileHeight": 256,
            "matrixWidth": 64,
            "matrixHeight": 64
        },
        {
            "type": "TileMatrixType",
            "identifier": "7",
            "scaleDenominator": 490461.07700892864,
            "topLeftCorner": [
                5500000.0,
                2000000.0
            ],
            "tileWidth": 256,
            "tileHeight": 256,
            "matrixWidth": 128,
            "matrixHeight": 128
        },
        {
            "type": "TileMatrixType",
            "identifier": "8",
            "scaleDenominator": 245230.53850446432,
            "topLeftCorner": [
                5500000.0,
                2000000.0
            ],
            "tileWidth": 256,
            "tileHeight": 256,
            "matrixWidth": 256,
            "matrixHeight": 256
        },
        {
            "type": "TileMatrixType",
            "identifier": "9",
            "scaleDenominator": 122615.26925223216,
            "topLeftCorner": [
                5500000.0,
                2000000.0
            ],
            "tileWidth": 256,
            "tileHeight": 256,
            "matrixWidth": 512,
            "matrixHeight": 512
        },
        {
            "type": "TileMatrixType",
            "identifier": "10",
            "scaleDenominator": 61307.63462611608,
            "topLeftCorner": [
                5500000.0,
                2000000.0
            ],
            "tileWidth": 256,
            "tileHeight": 256,
            "matrixWidth": 1024,
            "matrixHeight": 1024
        },
        {
            "type": "TileMatrixType",
            "identifier": "11",
            "scaleDenominator": 30653.81731305804,
            "topLeftCorner": [
                5500000.0,
                2000000.0
            ],
            "tileWidth": 256,
            "tileHeight": 256,
            "matrixWidth": 2048,
            "matrixHeight": 2048
        },
        {
            "type": "TileMatrixType",
            "identifier": "12",
            "scaleDenominator": 15326.90865652902,
            "topLeftCorner": [
                5500000.0,
                2000000.0
            ],
            "tileWidth": 256,
            "tileHeight": 256,
            "matrixWidth": 4096,
            "matrixHeight": 4096
        },
        {
            "type": "TileMatrixType",
            "identifier": "13",
            "scaleDenominator": 7663.45432826451,
            "topLeftCorner": [
                5500000.0,
                2000000.0
            ],
            "tileWidth": 256,
            "tileHeight": 256,
            "matrixWidth": 8192,
            "matrixHeight": 8192
        },
        {
            "type": "TileMatrixType",
            "identifier": "14",
            "scaleDenominator": 3831.727164132255,
            "topLeftCorner": [
                5500000.0,
                2000000.0
            ],
            "tileWidth": 256,
            "tileHeight": 256,
            "matrixWidth": 16384,
            "matrixHeight": 16384
        },
        {
            "type": "TileMatrixType",
            "identifier": "15",
            "scaleDenominator": 1915.8635820661275,
            "topLeftCorner": [
                5500000.0,
                2000000.0
            ],
            "tileWidth": 256,
            "tileHeight": 256,
            "matrixWidth": 32768,
            "matrixHeight": 32768
        }
    ]
}

ref: https://github.com/developmentseed/morecantile/pull/27#issuecomment-638620428

vincentsarago commented 4 years ago

Notes: The problem here is that it seems the coordinates of the topLeftCorner is in X,Y order while the CRS

Names Definition Data type and values Multiplicity and use
TopLeft‌Corner Position in CRS coordinates of the top-left corner of this tile matrix Ordered sequence of double values (*b) One (mandatory)

with b:

CRS will be inherited from the supportedCRS parameter of the parent TileMatrixSet. The order of these axes shall be as specified by the supportedCRS. These are the precise coordinates of the top left corner of top left pixel of the 0,0 tile. See Figure 1.

The TMS specs is clear that topLeftCorner coordinates order should be inherited from the CRS so IMO the example TMS for EuropeanETRS89_LAEAQuad is wrong!