Results 1 to 6 of 6

Thread: How to define projections in GIS Software

  1. #1
    Software Dev/Rep Hai-Etlik's Avatar
    Join Date
    May 2009
    Location
    48° 28′ N 123° 8′ W
    Posts
    1,333
    Blog Entries
    1

    Tutorial How to define projections in GIS Software

    If you want to use GIS software to work with fictional worlds, you'll need to specify projections appropriate for those worlds. Unfortunately custom projections aren't used too much in GIS so the emphasis is on having an enormous catalog of known projections rather than a convenient way to define new ones. Projections for planets that aren't Earth are even more of a rarity. As such, the way to define projections generally boils down to having to write out a description in an arcane language. The two most common such languages are Proj.4 (used by QuantumGIS and PostGIS) and WKT (Which has several different dialects and is used by GeoServer and ArcGIS) Some software understands both such as GDAL/OGR.

    Since QGIS is one of the most likely GIS tools to be used in the guild, and since the Proj.4 format is much less verbose, I'll start there.

    First off. You're probably used to thinking of projections (if you think about them at all) purely in terms of geometry. In a GIS though they are about numbers, coordinates. You might not care where 0,0 is on your map, what unit is ultimately being used, which directions are positive or negative, or which order the coordinates are in, but these are all ultimately part of the coordinate system we're defining (Although thankfully Proj.4 has reasonable default values so we don't need to specify them). That's why a lot of GIS software will use the term "CRS" (Coordinate Reference System) rather than "projection". CRSes break down into three groups, although we'll only worry about two of them: Geographic Coordinate Systems measure positions on the surface as angles around the centre. Essentially latitude and longitude. Projected Coordinate Systems think of positions on a flat projection surface as linear measurements. This is like measuring positions on an imaginary a life sized map. Geocentric Coordinate Systems use 3D Cartesian coordinates relative to the centre of the planet. Geographic coordinates are in angular units, almost always degrees. Projected and Geocentric coordinates are in linear units, usually metres.

    The first decision you need to make is how big your planet is. Earth is usually approximated as spheroid (flattened sphere) with an equatorial radius of 6,378,137 m and a flattening of 1/298.257223563 (The amount that the polar radius is less than the equatorial radius is 1/298.257223563 of the equatorial radius) This gives a polar radius of 6,356,752.3142 m. This idealized shape of the planet, along with the selection of a prime meridian, and some additional jiggling around makes up a "datum". Since the real Earth is not a perfect spheroid, and our measurements of it are getting better, and it is changing over time, there are many different datums (yes, the plural is "datums" not "data" in this case.) For the purposes of fantasy mapping, we can just assume the planet is a perfect, unchanging spheroid and only ever use one datum. No matter how committed to realism you are, it's not worth dealing with datum shifts so just stick with one.

    Every projection needs to include this information about the shape of the planet. With real life CRSes, this is normally done by referring to one of the known datums. The following defines a geographic coordinate system on the WGS84 datum (a common datum for mapping the whole world)

    Code:
    +proj=longlat +datum=WGS84 +no_defs
    To do the same for our own planet, we specify the equatorial (a) and polar (b) radii instead of referencing the known datum. Here's a geographic CRS for a slightly smaller planet with an equatorial radius of 6,158,903 m and a polar radius of 6,139,716 m

    Code:
    +proj=longlat +a=6158903 +b=6139716 +no_defs
    +proj=longlat says this is a geographic coordinate system.

    +a=6158903 says that the equatorial radius is 6,158,903 m

    +a=6139716 says that the polar radius is 6,139,716 m

    +no_defs disables automatic inclusion of default values. Just add this to the end of every custom projection as boilerplate.

    So that's a custom datum/geographic coordinate system. If you plug it into the CRS editor in QGIS, the CRS table in PostGIS, or give it as the -a_srs parameter of a GDAL command, that software will know about our slightly smaller than Earth planet and will be able to work with it in terms of latitude and longitude.

    But what if we want to make a map? For a map we need a projected coordinate system that uses x and y in metres instead of latitude and longitude in degrees.

    Code:
    +proj=robin +lon_0=0 +x_0=0 +y_0=0 +a=6158903.290 +b=6139716.675 +no_defs
    +a=6158903.290 +b=6139716.675 +no_defs are the same as before. This is still our little planet.

    +proj=robin says that this is the Robinson projection. A projection commonly used for world maps.

    +lon_0=0 says that the central meridian of the projection is at 0°. This it the longitude that runs straight up and down in the middle where the others are curved.

    +x_0=0 +y_0=0 set the false easting and false northing to 0. These are just numbers added on to whatever comes out of the projection. This can be used to eliminate negative numbers if they bother you. If you don't care about negative numbers lurking under the hood, just leave them at 0.

    If you want to zoom in for a regional map, you need a projection that can focus on that area. The simplest projections for that are azimuthal projections: Gnomonic, Stereographic, Azimuthal Equidistant, and Lambert Azimuthal Equal Area. In these projections the map is just flat and touches the globe at one point. Distortion of linear scale and other properties increases as you move away from the centre.

    Gnomonic preserves straight lines (great circles) and is mostly useful for technical maps like those in geology. It might also make sense for mapping magical ley lines.

    Stereographic is conformal which means it preserves angles. You can sort of think of it as preserving shapes although that's not quite right. It's a good choice for reference or navigational maps and is generally the nicest looking.

    Azimuthal Equidistant preserves distances measured through the centre. It's used on the UN flag, and in maps for air routes through a particular hub airport.

    Lambert Azimuthal Equal Area preserves area. It's useful for statistical maps.


    Code:
    +proj=stere +lat_0=45 +lon_0=-100 +k=1 +x_0=0 +y_0=0 +a=6158903.290 +b=6139716.675 +no_defs
    +proj=stere says that the projection is Stereographic

    +lat_0=45 +lon_0=-100 says that the centre is at 45°N and 100°W. By default the datum will have North and East as positive while South and West are negative.

    +k=1 is a scale factor. Setting this to less than 1 effectively pushes the map through the globe so that they touch in a circle around the centre instead of at the centre. This only applies to Streographic.

    +x_0=0 +y_0=0 +a=6158903.290 +b=6139716.675 +no_defs are all the same as before.

    The other azimuthal projections are +proj=gnom for gnomonic, +proj=aeqd for azimuthal equidistant, and +proj=laea for Lambert azimuthal equal area. Apart from k which is specific to Sterographic, they all take the same parameters.

    So how do you know where you want the centre of your azimuthal projection? Generally you want it smack in the middle of wherever you are making a map of. Right at the poles is common +lat_0=90, +lat_0=-90. The common 'two hemispheres' map uses two azimuthal projections at antipodal points on the equator such as +lat_0=0 +lon_0=90 and +lat_0=0 +lon_0=-90

    The G.Projector tool can give you an on the fly idea of what a projection looks like as you adjust its parameters. However, it can't read or write Proj.4 or WKT so you have to convert by hand.

    I'll add more to this as time permits.

  2. #2

    Default

    Finding this article was a real relief. I was starting to think I was the only person interested in making up projections.

    How would I go a stage further and define my own projection for the map? By that I mean not a tweak to Winkle Tripel, Gnomonic nor Peirce Quincuncial, but an equation that I type in to define the form that the map takes?
    Code:
    +proj=custom1
    I would probably start by defining custom1 as an existing projection like Mercator and apply it to an image of Earth to make sure things are working right, then try something from scratch.

    Thank you

  3. #3
    Software Dev/Rep Hai-Etlik's Avatar
    Join Date
    May 2009
    Location
    48° 28′ N 123° 8′ W
    Posts
    1,333
    Blog Entries
    1

    Default

    Quote Originally Posted by mapomatic View Post
    Finding this article was a real relief. I was starting to think I was the only person interested in making up projections.

    How would I go a stage further and define my own projection for the map? By that I mean not a tweak to Winkle Tripel, Gnomonic nor Peirce Quincuncial, but an equation that I type in to define the form that the map takes?
    That requires writing an implementation and including it in Proj4. For instance, this is what the implementation of Lambert Conformal Conic looks like https://github.com/OSGeo/proj.4/blob...r/src/PJ_lcc.c

  4. #4

    Default

    Quote Originally Posted by Hai-Etlik View Post
    That requires writing an implementation and including it in Proj4.
    Oh. Thanks for the quick reply. Proj4 does sound good, but is there any solution that doesn't require re-compiling a computer program every time I change something, such as a program that can open a definitions file and apply it? I see that Proj4 can use .prj definition files which is a step in the right direction, but it seems that these cannot define the fundamental projection mathematics.

    Thank you

  5. #5
    Software Dev/Rep Hai-Etlik's Avatar
    Join Date
    May 2009
    Location
    48° 28′ N 123° 8′ W
    Posts
    1,333
    Blog Entries
    1

    Default

    Quote Originally Posted by mapomatic View Post
    Oh. Thanks for the quick reply. Proj4 does sound good, but is there any solution that doesn't require re-compiling a computer program every time I change something, such as a program that can open a definitions file and apply it? I see that Proj4 can use .prj definition files which is a step in the right direction, but it seems that these cannot define the fundamental projection mathematics.

    Thank you
    I'm not aware of any GIS software that has an integrated CAS type functionality to define projections. I expect such an on the fly custom projection definition would be significantly slower. As it is, defining even a coordinate system based on existing projections is a fairly unusual thing in GIS. That's why it tends to involve writing a Proj4 config string or WKT by hand rather than a discoverable UI with dynamic projection view with Tissots indicatrix or a distortion colour map.

  6. #6
    Administrator waldronate's Avatar
    Join Date
    Mar 2007
    Location
    The High Desert
    Posts
    3,610

    Default

    While it's not exactly a fully-custom analytic projection, http://www.flexprojector.com/ might be of interest.

    http://www.cartography.oregonstate.edu/software.html is fun to visit as well.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •