Wednesday, 23 November 2016

leaflet - great circles in QGIS and export in 3857 webmap



My plan is to visualize great circles in a leaflet webmap.


So coming from this great postgis article and R version I thought it would work like this in QGIS:



  • create line from two points,

  • store polyline in EPSG:4326

  • add many vertexes using the densify algorithm

  • store the densified line as 4326

  • put it into leaflet and you should have nice "curves" on a map


what comes out is this: leaflet map in EPSG 3857



And here a comparison of densified and normal lines in QGIS where you can see some small curvature of lines: QGIS screenshot with straight lines and densified lines


Is it just a problem with the EPSG 3857 or am I interpreting the post from @underdark wrong?



Answer



To create a great circle, you need either a custom azimuthal equidistant (aeqd) projection or a gnomonic (gnom) projection on one of your points.


In those projections, the great circle is a straight line, which you can densify to have a curved line in other projections. If the great circle crosses the 180° E/W line or the poles, it might be useful to cut the line on that line or point to avoid misplaced parts of the line in other projections.




updated workflow



  1. create a text file with your start coordinates




E N


7 51




  1. In QGIS, create a custom aeqd projection around your start point



+proj=aeqd +lat_0=51 +lon_0=7 +x_0=0 +y_0=0 +a=6371000 +b=6371000 +units=m +no_defs






  1. Load the text file as delimited text with WGS84 as CRS




  2. Add the target points from any other backgrounds




  3. switch the project CRS to your custom CRS





  4. Create a new shapefile of type line and your custom CRS




  5. Set snapping to your points layer with 10 pixels tolerance




  6. connect your start point with all targets:





enter image description here




  1. Densify the lines by 99 vertices




  2. Switch the project CRS to EPSG:3857




enter image description here



Note that equidistant conic is a different projection, which does not show the great circles as straight lines:


enter image description here


A visualization of great circles in different projections can be found here:


http://www.progonos.com/furuti/MapProj/Normal/CartProp/Geodesic/geodesic.html


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...