• 大小: 22KB
    文件类型: .py
    金币: 1
    下载: 0 次
    发布日期: 2021-05-14
  • 语言: Python
  • 标签: python-tin  

资源简介

用PYTHON实现GIS中的TIN生成,对用PYTHON对GIS进行开发有点小用

资源截图

代码片段和文件信息

#coding=utf-8  

# -*- coding: utf-8 -*-

import os
import re
import string
import copy
import math
from Tkinter import *

def coord_c(point_lxmin1xmax1ymin1ymax1mwidthnheight):
    point1_l=[]
    for i in range(len(point_l)):
        mxtemp=((point_l[i][0]-xmin1)*mwidth)/(xmax1-xmin1)
        mytemp=nheight-((point_l[i][1]-ymin1)*nheight)/(ymax1-ymin1)
        point1_l.append((mxtempmytemp))
    return point1_l

def distance(two_point):
    d=(two_point[0][0]-two_point[1][0])**2+(two_point[0][1]-two_point[1][1])**2
    return d

def calculate_insert_p(point_ln0point_Amax_distance):
#该函数主要用来计算插值,四个向限依次判断
#第一向限
    pi=3.1415926535898
    n=0
    k=-1
    temp_p=[]
    temp_z=[]

    for j in range(1n01):
        temp_d=2*max_distance
        up_cos=math.cos((pi*j)/(2*n0))
        down_cos=math.cos((pi*(j-1))/(2*n0))
        for i in range(len(point_l)):
            if point_l[i][0]>=point_A[0] and point_l[i][1]>=point_A[1]:
                p_cos=(point_l[i][0]-point_A[0])/math.sqrt((point_l[i][1]-point_A[1])**2+(point_l[i][0]-point_A[0])**2)
                if p_cos>up_cos and p_cos<=down_cos:
                    two_point=[]
                    two_point.append(point_A)
                    two_point.append((point_l[i][0]point_l[i][1]))
                    d=distance(two_point)
                    if d                        k=i
        if k!=-1:
            temp_p.append(copy.deepcopy(point_l[k]))
            k=-1

#第二向限
    for j in range(1n01):
        temp_d=2*max_distance
        up_cos=math.cos((pi*j)/(2*n0)+pi/2)
        down_cos=math.cos((pi*(j-1))/(2*n0)+pi/2)
        for i in range(len(point_l)):
            if point_l[i][0]<=point_A[0] and point_l[i][1]>=point_A[1]:
                p_cos=(point_l[i][0]-point_A[0])/math.sqrt((point_l[i][1]-point_A[1])**2+(point_l[i][0]-point_A[0])**2)
                if p_cos>up_cos and p_cos<=down_cos:
                    two_point=[]
                    two_point.append(point_A)
                    two_point.append((point_l[i][0]point_l[i][1]))
                    d=distance(two_point)
                    if d                        k=i
        if k!=-1:
            temp_p.append(copy.deepcopy(point_l[k]))
            k=-1
#第三向限
    for j in range(1n01):
        temp_d=2*max_distance
        up_cos=math.cos((pi*j)/(2*n0)+pi)
        down_cos=math.cos((pi*(j-1))/(2*n0)+pi)
        for i in range(len(point_l)):
            if point_l[i][0]<=point_A[0] and point_l[i][1]<=point_A[1]:
                p_cos=(point_l[i][0]-point_A[0])/math.sqrt((point_l[i][1]-point_A[1])**2+(point_l[i][0]-point_A[0])**2)
                if p_cos=down_cos:
                    two_point=[]
                    two_point.append(point_A)
                    two_point.append((point_l[i][0]point_l[i][1]))
                    d=distance(two_point)
                    if d                  

评论

共有 条评论

相关资源