[GIS] Converting EPSG to D3.js

coordinate systemd3epsgextentsmercator

Given an EPSG projection (say, this Alabama one: http://spatialreference.org/ref/epsg/26729/)

How can you take the given WGS84 projection bounds in such a way that you can use them in a D3.js projection.

For example, how would you know what projection, degree of rotation or bounding box to use to show the map?

Best Answer

I'll try, but I've never used D3. I do know projections and the state plane system very well. Let's look at a full definition of EPSG::26729.

PROJCS["NAD27 / Alabama East",
    GEOGCS["NAD27",
        DATUM["North_American_Datum_1927",
            SPHEROID["Clarke 1866",6378206.4,294.9786982138982,
                AUTHORITY["EPSG","7008"]],
            AUTHORITY["EPSG","6267"]],
        PRIMEM["Greenwich",0,
            AUTHORITY["EPSG","8901"]],
        UNIT["degree",0.01745329251994328,
            AUTHORITY["EPSG","9122"]],
        AUTHORITY["EPSG","4267"]],
    UNIT["US survey foot",0.3048006096012192,
        AUTHORITY["EPSG","9003"]],
    PROJECTION["Transverse_Mercator"],
    PARAMETER["latitude_of_origin",30.5],
    PARAMETER["central_meridian",-85.83333333333333],
    PARAMETER["scale_factor",0.99996],
    PARAMETER["false_easting",500000],
    PARAMETER["false_northing",0],
    AUTHORITY["EPSG","26729"],
    AXIS["X",EAST],
    AXIS["Y",NORTH]]

There's a lot of information here.

So this repo says that scaling and translating are not done, so you have to handle those separately.

Translating are the false easting/false northing parameters. They 'reset' the origin of the projection from 0,0 to new values generally to make sure that all coordinates within the typical area of use are positive. In the state plane system, the zones that are more north-south use transverse Mercator and have a scale factor that reduces the overall distortion.

For the NAD83 version of Alabama East, the repo has:

var projection = d3.geoTransverseMercator()
  .rotate([85 + 50 / 60, -30 - 30 / 60]);

The rotation is moving the center of the projection, at latitude: 30.5 deg, longitude: -85.83333333333333 deg, to 0,0 of the display. To do that we need to rotate to the right by 85.83333333333333 or (85 + 50/60) (the projection's central meridian is actually defined as -85 degrees 50 minutes).

We also need to rotation down by -30.5, or (-30 - 30/60) as the latitude of origin is at 30 degrees 30 minutes North. You could instead use a latitude that's centered in the area of use, as the latitude of origin usually near the bottom of the area of use--also in order to make all the coordinates have positive values.

The Lambert conformal conic AKA conicConformal also has standard parallels so there's an extra option to define those.

var projection = d3.geoConicConformal() // Tennessee
  .parallels([35 + 15 / 60, 36 + 25 / 60])
  .rotate([86, -34 - 20 / 60]);

I looked at the gka repo which also includes bounds:

 "bounds": [[-0.039122,-0.079084],[0.013939,0.004511]] 

but I'm not seeing how they're converted from the values on the spatialreference .org site. They have been rotated but that's as much as I can tell.

Last but not least, I should mention that you picked a NAD27 zone. The repo examples are NAD83. These two geographic CRS / datums use different ellipsoids (Clarke 1866 versus GRS80). They also can have different units and thus different offset/translation values. Zone parameters often changed between NAD27 and NAD83 as well but often it was just the false easting/northing parameters.