Saturday 20 February 2016

qgis - Get correct measurements for fantasy world map


I read lots of questions about fantasy maps and custom crs but none of the answers could solve my problems.



Here is what I have:



  • A planet with an equatorial circumference of 38 211 km (radius: 6081.5 km)

  • A bunch of shape files for the continents and some islands as well as country borders and so on

  • A raster graphic in the background, already georeferenced

  • Shape files and graphics coordinates in longitude latitude degrees.


Here is what I want to get:



  • a world map in a cylindrical projection


  • a custom crs to get metric measurements from the degree coordinates of my layers.


Here is what I tried: - define custom crs:


+proj=eqc +lat_ts=0 +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +R=6081500 +a=6.08146953 +b=6.08146953 +units=m +no_defs

(+a=r[km]/(2π*1000) and +b the same thing)



  • Then I clicked on project --> properties --> "CRS" and selected the new crs

  • Under "General" --> "Measurements" --> "Ellipsoid" I chose "Custom" and entered the radius of my planet in meters for both semi-major and semi-minor values.

  • I right-clicked the layers and chose the same crs for them as for the project.


  • I selected the "measure line"-tool and measured a line on the equator that should be around 38211 km or 360°. It never was. I measured a line on the poles that should be around 0 km, never got close to 0.


I changed the +a and +b values in the crs, I made sure for my shape files to have the right coordinates, but I can't find any errors.


So the final question is: How would a crs look like, that achieves the following parameters for my custom planet map:



  • Cylindrical projection

  • Poles at +90° (Northpole) and -90° (Southpole), 9,552.798 km (quarter circumference of the sphere) away from the Equator

  • expanding -180° and +180° (119,105.596 km, half circumference) from west to east?



Answer




About the projection


You defined an equidistant cylindrical projection. That's not bad, although it is a projection that has not been seen in the maps for a long time. In that projection (unlike the Mercator projection, which is also cylindrical), the deformation occurs in the longitudes, provided they are seen as straight lines.


Coordinates in that projection are defined as follow:


x = R * lambda * cos(phi)
y = R * phi


Where R = 6081500, the spherical world radius. And lambda are the longitudes and phi are the latitudes (in radians).


The projection units are meters. So you need to go to y = 19105600 to find the North pole.




About the PROJ string


+a and +b parameters are the major and minor semiaxis of the ellipsoid (the sphere is an ellpsoid where a = b), measured in meters. They are not necessary when the +R or +ellps parameters are set. But if you want to define the sphere with their semiaxis lenghts, you need to set them as +a=6081500 and +b=6081500.



+no_defs parameter is a best practice. It means that custom default parameters will not be read.


The other parameters are not over, they are simply optional because you are defining the same parameters that come by default.


So that:


+proj=eqc +R=6081500 +units=m +no_defs


Produces the same result as:


+proj=eqc +lat_ts=0 +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +a=6081500 +b=6081500 +units=m +no_defs




The +proj=longlat meaning


In QGIS you can define a custom CRS with the +proj=longlat string, to define that the data is supposed to be in geographical coordinates. But that string is not a projection. However, as QGIS can render the canvas of a project taking the geographical coordinates as flat, we say that it is a "kind" of equirectangular projection, and we call it affectionately "flat longlat".


But not understanding that the geographic coordinates are not flat, although they can be rendered as such, is the main source of errors when someone begins to work in GIS.



If you move, rotate or scale a polygon on these coordinates using the formulas of the planimetry, you are completely deforming it on the spherical surface of your world.




The Layer CRS, and the project CRS



  • In QGIS you can define a CRS for a layer. The meaning of doing that is to ask the program to please interpret the coordinates of the geometries of that layer as belonging to that coordinate system.


Changing the CRS definition of the layer does not change the coordinates of its geometries, but the way in which they should be interpreted.


Therefore, since your geometries have their coordinates defined as geographical coordinates, that is, they are defined by their longitude and latitude, you must assign your layer a geographic CRS and not a CRS projection. Even so, it is necessary that you specify the radius of your world: the radius is the third spherical coordinate necessary to define three dimensions, which the coordinates of the geometries do not store.


So, there is no doubt that your layers can be assigned with the following custom CRS:


+proj=longlat +R=6081500 +no_defs



If you would like to establish a layer whose geometries are located in the same place in the world, but their coordinates are related to another system (for example to one projected on the plane), then you must export them and assign the new system at the time of export . This procedure (called reproject), modifies the coordinates of the geometries, but at the same time it establishes what is their new reference system, so both layers represent the same location in the world.



  • The CRS of the project, on the other hand, is the CRS on which the canvas is rendered. It allows several layers with geometries defined in different CRS to be consistently displayed in the map.


If you want the North pole to be seen on your map in the y = 90 coordinate, which is done many times for convenience, and to be able to approximate the geographic coordinates of an object by just passing the mouse over it, then you can set the same system for the project that you had established for the layers.


To render your map you can try other custom systems. All the projections of a sphere on a plane produce some deformation. The only thing you need to keep in mind is what kind of deformation and where it is occurring.


For the rest, you already saw that there are tools that return the spatial information planimetrically and other ellipsoidal. The measurement tool returns ellipsoidal information, so it is necessary to define your ellipsoid in the properties of the project. This affects the behavior of the tools, and not the coordinates of the geometries or the rendering.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...