1准备一个DEM地形,打开GlobalMap,如下选择
选择否,生成边界
将边界导出为shp文件,打开QGIS,安装get wkt插件,选择对应坐标系,获取wkt,如图
, 附判断点是否在此坐标范围内代码
/// <summary>
/// 判断点是否在多边形内或多边形上
/// </summary>
/// <param name="ALon">经度</param>
/// <param name="ALat">纬度</param>
/// <param name="Points">多边形边界点集合</param>
/// <returns></returns>
public static bool IsPtInPoly(double ALon, double ALat, string rainfallRange)
{
//rainfallRange转为区域点对象
string[] rainfallArray = rainfallRange.Split(';');
List<Point> Points = new List<Point>(); // 换成自己的
foreach (string strs in rainfallArray)
{
string[] strPoint = strs.Split(',');
Point point = new Point(Convert.ToDouble(strPoint[0]), Convert.ToDouble(strPoint[1])); // 换成自己的
Points.Add(point);
}
int iSum, iCount, iIndex;
double dLon1 = 0, dLon2 = 0, dLat1 = 0, dLat2 = 0, dLon;
if (Points.Count < 3)
{
return false;
}
iSum = 0;
iCount = Points.Count;
for (iIndex = 0; iIndex < iCount; iIndex++)
{
if (ALon == Points[iIndex].getX() && ALat == Points[iIndex].getY()) //A点在多边形上
return true;
if (iIndex == iCount - 1)
{
dLon1 = Points[iIndex].getX();
dLat1 = Points[iIndex].getY();
dLon2 = Points[0].getX();
dLat2 = Points[0].getY();
}
else
{
dLon1 = Points[iIndex].getX();
dLat1 = Points[iIndex].getY();
dLon2 = Points[iIndex + 1].getX();
dLat2 = Points[iIndex + 1].getY();
}
//以下语句判断A点是否在边的两端点的纬度之间,在则可能有交点
if (((ALat > dLat1) && (ALat < dLat2)) || ((ALat > dLat2) && (ALat < dLat1)))
{
if (Math.Abs(dLat1 - dLat2) > 0)
{
//获取A点向左射线与边的交点的x坐标:
dLon = dLon1 - ((dLon1 - dLon2) * (dLat1 - ALat)) / (dLat1 - dLat2);
//如果交点在A点左侧,则射线与边的全部交点数加一:
if (dLon < ALon)
{
iSum++;
}
//如果相等,则说明A点在边上
if (dLon == ALon)
return true;
}
}
}
if ((iSum % 2) != 0)
{
return true;
}
return false;
}
public class Point
{
private Double x;
private Double y;
public Point(Double x, Double y)
{
this.x = x;
this.y = y;
}
public Double getX()
{
return x;
}
public void setX(Double x)
{
this.x = x;
}
public Double getY()
{
return y;
}
public void setY(Double y)
{
this.y = y;
}
}