兰伯特等角圆锥地图

兰伯特等角圆锥地图

我想用 TikZ 绘制一张地图,作为起点,这张地图应该在兰伯特等角圆锥投影。但为了方便起见,我想加入一些测地线计算,这样用户就可以简单透明地了解自己在做什么,而无需使用外部工具进行转换和计算。我以前这样做过,效果很好,但我想将其提升到一个新的水平并寻求您的意见。

带有注释解释的输入代码可能如下所示:

\begin{tikz}
\begin{projection}[type=Lambert conformal conic,stdlat1=2,stdlat2=-2,lon0=0,k=1]

\coordinate(point1) at (1.0,0.5); %1 degree North, 0.5 degree East
\coordinate(point2) at (-1.0,-0.5); %1 degree South, 0.5 degree West

\draw (point1) -- ++ (relative cs:100m,50m); %draw line from point1 to a coordinate 100 meters (in reality) to the east and 50 meters (in reality) to the north relative of point1
\draw (point1) -- (point2); %draw line from point1 to point2 (can be straight, does not have to be a geodesic)
\draw ($(point2) + (relative cs: 45:2nm)$) -- (point1); %draw a line from a point on a 45 degree bearing with a distance of 2 nautical miles from point1 to point2
\draw (point1) arc (relative cs: 60:90:3nm); %draw a circle segment from point1 with starting heading of 060 and end heading of 090 with a 3 nautical mile radius

\end{projection}
\end{tikz}

输入参数的命名法取自测地线库

任何想法,甚至是起点都非常感谢,因为我甚至找不到与此相近的东西。欢迎使用 LuaTeX 或类似工具实现!

答案1

感谢@Schrödinger's cat 在评论中提供的精彩意见。通过应用它们,我能够提出我所需要的基本结构。您可以看到我如何将其应用于一个工作示例中,该示例绘制了美国的 4 个城市、亚利桑那州和一个网格: 在此处输入图片描述 其代码(不包括亚利桑那州的边界,因为这会使文件太大)如下所示:

\documentclass{article}
\usepackage[a4paper, landscape, margin=0cm]{geometry}

\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
    Arizona in Lambert Conical projection and the airports PHX, AUS, DTW and JFK
    
\directlua{lambert = require("lambert")}

\newcommand\addLUADEDplot[8]{%
\directlua{lambert.LambertConicalForward(#1,#2,#3,#4,#5,#6,#7,#8)}%
}

    \newenvironment{ellipsoid}[1][a=6378137,f=0.0033528106647475]{
    \setkeys{ellipsoid}{#1}}

    \newenvironment{lambertconical}[1][stdlat1=33,stdlat2=45,lon0=-112,k=1]{\setkeys{lambertconicalkeys}{#1}}
    
    \makeatletter
    \define@key{latlonkeys}{lat}{\def\mylat{#1}}
    \define@key{latlonkeys}{lon}{\def\mylon{#1}}
    \define@key{ellipsoid}{a}{\def\ellipsoidA{#1}}
    \define@key{ellipsoid}{f}{\def\ellipsoidF{#1}}
    \define@key{lambertconicalkeys}{stdlat1}{\def\lambertconicalStdLatONE{#1}}
    \define@key{lambertconicalkeys}{stdlat2}{\def\lambertconicalStdLatTWO{#1}}
    \define@key{lambertconicalkeys}{lon0}{\def\lambertconicalLonZERO{#1}}
    \define@key{lambertconicalkeys}{k}{\def\lambertconicalK{#1}}
    \makeatother
    \tikzdeclarecoordinatesystem{latlon}%
    {%
        \setkeys{latlonkeys}{#1}%
        \addLUADEDplot{\ellipsoidA}{\ellipsoidF}{\lambertconicalStdLatONE}{\lambertconicalStdLatTWO}{\lambertconicalK}{\lambertconicalLonZERO}{\mylat}{\mylon}%
    }

    \begin{tikzpicture}[scale=0.45]
    \begin{ellipsoid}[a=6378137,f=0.0033528106647475]
    \begin{lambertconical}[stdlat1=33,stdlat2=45,lon0=-112,k=0.00001]
        %\draw [->] (0,0,0) -- (0,0,350);
        \node at (latlon cs:lat=33.434167,lon=-112.011667){PHX};
        \node at (latlon cs:lat=30.194444,lon=-97.67){AUS};
        \node at (latlon cs:lat=42.2125,lon=-83.353333){DTW};
        \node at (latlon cs:lat=40.639722,lon=-73.778889){JFK};
        
        \foreach \lon in {-124,-123, ..., -66}
        {
            \foreach \lat in {25,26, ..., 49}
            {
                \draw (latlon cs:lat=\lat,lon=\lon) -- (latlon cs:lat=\lat,lon={\lon+1});
                \draw (latlon cs:lat=\lat,lon=\lon) -- (latlon cs:lat={\lat+1},lon=\lon);
            }
        }

    \end{lambertconical}
    \end{ellipsoid}
    \end{tikzpicture}
\end{document}

兰伯特共形圆锥曲线的 Lua 实现(仅适用于球体,后面会讲到更多复杂情况)如下所示:

local function print_LambertConformalConicForward(a,f,stdlat1,stdlat2,k1,lon0,lat,lon)
lat0 = 40;
n = math.log(math.cos(math.rad(stdlat1))/math.cos(math.rad(stdlat2))) / math.log( math.tan((math.pi/4)+math.rad(stdlat2/2)) / math.tan((math.pi/4)+math.rad(stdlat1/2)))
F = (math.cos(math.rad(stdlat1)) * math.pow(math.tan((math.pi/4)+math.rad(stdlat1/2)), n)) / n
rho = (a * F) / math.pow(math.tan((math.pi/4)+(math.rad(lat)/2)), n)
rho_0 = (a * F) / math.pow(math.tan((math.pi/4)+(math.rad(lat0)/2)), n)
theta = n * (math.rad(lon-lon0))

x = (rho * math.sin(theta)) * k1
y = (rho_0 - (rho * math.cos(theta))) * k1

tex.sprint("\\pgfpointxyz{"..x.."}{"..y.."}{0}%")
end

return { LambertConicalForward = print_LambertConformalConicForward }

2021-12-10 编辑:我正在制作另一张地图,似乎我并不是唯一一个想用 TikZ 绘制地图的人。现在有一个基于地图图块构建的用于此目的的包,但它也可以在没有基本地图的情况下使用:mercatormap可以在以下位置找到https://ctan.org/pkg/mercatormap

相关内容