0
저는 오래 전부터 좌표를 플로팅 한 3D로 어려움을 겪었습니다. 이제는 정말 좌절감을 느낍니다.CityGML 데이터로 건물 표면 지정하기
저는 원래 CityGML 파일 (원래는 XML 파일)에서 건물의 외양을 플롯하려고합니다. XML.etree를 사용하여 CityGML 파일을 구문 분석하고 좌표를 추출하는 데 아무런 문제가 없습니다. 그러나 좌표를 추출한 후에는 3D 플롯을 그릴 수있는 방법을 찾지 못했습니다.
from xml.etree import ElementTree as ET
tree = ET.parse('3860_5819__.gml')
root = tree.getroot()
namespaces = {
'ns0': "http://www.opengis.net/citygml/1.0",
'ns1': "http://www.opengis.net/gml",
'ns2': "http://www.opengis.net/citygml/building/1.0"
}
c = 0
wallString = []
for wallSurface in root.findall('.//ns2:WallSurface', namespaces):
for posList in wallSurface.findall('.//ns1:posList', namespaces):
c += 1
wallCoordinates = posList.text
wallCoordinates = wallCoordinates.split()
wallString.append(wallCoordinates)
verts = []
for string in wallString:
X, Y, Z = [], [], []
c = 0
for value in string:
value = float(value)
if c % 3 == 0:
X.append(value)
elif c % 3 == 1:
Y.append(value)
else:
Z.append(value)
c += 1
if c > len(string) - 3:
break
vert = [list(zip(X, Y, Z))]
verts.append(vert)
from mpl_toolkits.mplot3d import Axes3D
from mpl_toolkits.mplot3d.art3d import Poly3DCollection
import matplotlib.pyplot as plt
fig = plt.figure()
ax = Axes3D(fig)
for vert in verts:
ax.add_collection3d(Poly3DCollection(vert))
ax.autoscale_view(tight=True, scalex=True, scaley=True, scalez=True)
plt.show()
plt.close()
내 플롯을 "단단히"만들 수 없다는 것이 문제일까요? 그리고 그렇지 않다면 근본적으로 잘못된 일이 있습니까?
이 경우 CityGML 파일은 here에서 가져올 수있는 TU Berlin of entrepreneurship과 관련이 있습니다.