티스토리 뷰
https://gis4design.wordpress.com/2015/10/22/houdini-installing-hdas/
Houdini: Installing HDAs
Some custom nodes have been created by Dr. Patrick Janssen for the purposes of urban planning and design. We will be using some of these nodes in the Houdini tutorials. Custom nodes are installed w…
gis4design.wordpress.com
houdarcs
파일 압축 해제하고
후디니 에셋 - 에셋 불러오기
otls- phtj_shape_files_02.otl
이 파일 쓰면,후디니에서 .shp 파일 불러올수있다.
phtj_geojson GEO JSON파일도 .
MyGeodata Converter | MyGeodata Cloud
--> --> Uploaded Files Type Size Please note that your data will not be shared to anybody. Recently used data is your data that you have recently uploaded and can only be seen by you from your computer and your web browser. You can reuse them for a repeat
mygeodata.cloud
.shp 파일을 GEOJson파일로 변경해주는 사이트
shp는 단독으로 쓰이지 않는다.

이런 값을 가지고 있는데.
https://www.data.go.kr/index.do
공공데이터 포털
국가에서 보유하고 있는 다양한 데이터를『공공데이터의 제공 및 이용 활성화에 관한 법률(제11956호)』에 따라 개방하여 국민들이 보다 쉽고 용이하게 공유•활용할 수 있도록 공공데이터(Datase
www.data.go.kr
나는 한국 제주도 지형 데이터를 사용했다.

dbf 가 속성들을 들고있나 그렇다.
나는 맥환경이고 QGIS
여기 프로그램 다운받아서 속성을 영어로 변경하거나 파일이 잘 동작하는건지 확인했다..

후디니에서 노드 불러오면
GEO - 안에서 작업해야함.

오류가 엄청나는데
고쳐주면 된다.
아래 고친것..


# This code is called when instances of this SOP cook.
import hou
import shapefile
import re
import sys
# --- clean_attrib_name 함수 정의 ---
def clean_attrib_name(name):
"""Houdini에서 허용되지 않는 문자를 제거하고 이름을 정리합니다."""
cleaned_name = name.strip()
cleaned_name = re.sub(r'[^a-zA-Z0-9_]', '_', cleaned_name)
cleaned_name = re.sub(r'_{2,}', '_', cleaned_name)
cleaned_name = cleaned_name.strip('_')
if not cleaned_name:
return "shp_attr"
return cleaned_name
# --- Houdini 타입 변환 함수 (ValueError 방지) ---
def safe_convert(value, target_type_code):
"""값 설정 시 문자열을 float으로 변환할 때 발생하는 오류를 0.0으로 처리"""
try:
# target_type_code: 1 (Int), 0.1 (Float), "" (String)
if target_type_code == 1:
return int(value)
elif target_type_code == 0.1:
return float(value)
else:
return str(value)
except (ValueError, TypeError):
return 0 if target_type_code == 1 else (0.0 if target_type_code == 0.1 else "")
# =========================================================================
# 메인 스크립트 시작
# =========================================================================
this_node = hou.pwd()
geo = this_node.geometry()
# --- 필수 초기화: 이전 쿡의 잔여 지오메트리 및 속성 제거 ---
geo.clear()
selected=hou.evalParm("./file_mode")
if selected==0:
state="read"
elif selected==1:
state="write"
else:
state="do_nothing"
sf_path=hou.evalParm("./shape_file")
# -------------------------------------------------------------------------------------------------
# READ MODE
# -------------------------------------------------------------------------------------------------
if state=="read" and sf_path !="":
# 1. Shapefile 리더 생성 및 인코딩 시도
sf = None
for encoding in ['cp949', 'utf-8', 'latin1']:
try:
sf = shapefile.Reader(sf_path, encoding=encoding)
sys.stdout.write(f"✅ 인코딩 성공: {encoding}\n")
break
except:
continue
if sf is None:
sys.stderr.write("❌ 오류: Shapefile을 로드할 수 없습니다 (인코딩 실패).\n")
attribs=[]
field_types_map=dict([('N',1),('F',0.1),('C',"")])
# 2. 속성 필드 구성 및 클렌징
if sf and sf.fields:
for field in sf.fields:
try:
field_name = clean_attrib_name(field[0])
field_type_code = field[1]
field_default_value = field_types_map.get(field_type_code, "")
except Exception as e:
sys.stderr.write(f"Attribute processing error: {e}\n")
field_name = "error_attr"
field_default_value = ""
attribs.append([field_name,field_type_code, field_default_value])
# DeletionFlag 제거 (첫 번째 필드)
attribs=attribs[1:]
# 3. 지오메트리 로드 및 생성
shapeRecs=sf.shapeRecords()
# 빈 데이터셋 체크 (IndexError 방지)
if shapeRecs:
shapetype = shapeRecs[0].shape.shapeType
# Prim/Detail Attribute Creation
if shapetype == 5 or shapetype == 3:
for attrib in attribs:
geo.addAttrib(hou.attribType.Prim, attrib[0], attrib[2])
# Point Attribute Creation
if shapetype == 1 or shapetype == 8: # MultiPoint (8)도 Point 속성으로 처리
for attrib in attribs:
geo.addAttrib(hou.attribType.Point, attrib[0], attrib[2])
# 지오메트리 및 속성 값 설정 루프
for rec in shapeRecs:
shape=rec.shape
poly_attribs=rec.record
# --- 디버깅 출력: 현재 처리 중인 Shape Type을 확인합니다. ---
if shape.shapeType not in [1, 3, 5]:
sys.stdout.write(f"⚠️ 현재 Shapefile에 예상치 못한 타입 ({shape.shapeType})이 포함되어 있습니다.\n")
# -----------------------------------------------------------
# --- SHAPE TYPE 5: POLYGON ---
if shape.shapeType == 5:
parts=shape.parts
num_parts=len(parts)
points=shape.points
count=0
for part in parts:
poly=geo.createPolygon()
part_s=parts[count]
if count==num_parts-1:
part_e=len(points)
else:
part_e=parts[count+1]
part_points=points[part_s:part_e]
for point in part_points:
position=(point[0],point[1],0)
point=geo.createPoint()
point.setPosition(position)
poly.addVertex(point)
count+=1
for i in range(0,len(attribs)):
attrib_name = attribs[i][0]
type_code = attribs[i][1]
value = poly_attribs[i]
converted_value = safe_convert(value, type_code)
poly.setAttribValue(attrib_name, converted_value)
# --- SHAPE TYPE 1 (Point) and 8 (MultiPoint) ---
if shape.shapeType in [1, 8]:
points=shape.points
# MultiPoint의 경우, 모든 포인트를 반복합니다.
for pt_coord in points:
position = (pt_coord[0],pt_coord[1],0)
point=geo.createPoint()
point.setPosition(position)
for i in range(0,len(attribs)):
attrib_name = attribs[i][0]
type_code = attribs[i][1]
value = poly_attribs[i]
converted_value = safe_convert(value, type_code)
point.setAttribValue(attrib_name, converted_value)
# --- SHAPE TYPE 3: POLYLINE ---
if shape.shapeType == 3:
parts=shape.parts
num_parts=len(parts)
points=shape.points
count=0
for part in parts:
part_s=parts[count]
if count==num_parts-1:
part_e=len(points)
else:
part_e=parts[count+1]
part_points=points[part_s:part_e]
curve=geo.createBezierCurve(len(part_points), is_closed=False, order=2)
vcnt = 0
for vertex in curve.vertices():
vertex.point().setPosition((part_points[vcnt][0], part_points[vcnt][1], 0))
vcnt = vcnt+1
for i in range(0,len(attribs)):
attrib_name = attribs[i][0]
type_code = attribs[i][1]
value = poly_attribs[i]
converted_value = safe_convert(value, type_code)
curve.setAttribValue(attrib_name, converted_value)
else:
sys.stdout.write("WARNING: Shapefile contains no features/records. Exiting READ mode.\n")
# -------------------------------------------------------------------------------------------------
# WRITE MODE (완전 삭제)
# -------------------------------------------------------------------------------------------------
if state=="write" and sf_path !="":
sys.stderr.write("❌ 오류: WRITE MODE는 데이터 손실 방지를 위해 이 HDA에서 비활성화되었습니다. \n데이터 내보내기는 File SOP를 사용해 주세요.\n")
짠..

'후디니' 카테고리의 다른 글
| houdini - stable diffusion (0) | 2024.02.25 |
|---|---|
| houdini_기초 (1) | 2024.02.25 |
| houdini _ procedural modeling _01 (0) | 2024.01.26 |
| houdini_ math (1) | 2024.01.26 |
| houdini _ GEO format_BGEO (0) | 2024.01.03 |
- Total
- Today
- Yesterday
- sequelize
- Midjourney
- docker
- AI
- Express
- RNN
- opencv
- Java
- ai film
- node.js
- 4d guassian splatting
- houdini
- krea
- colab
- VFXgraph
- Arduino
- VR
- 라즈베리파이
- 후디니
- MCP
- CNC
- three.js
- MQTT
- Python
- opticalflow
- 유니티
- Unity
- 4dgs
- TouchDesigner
- DeepLeaning
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 |
