본문 바로가기

hacking or software engineering skills/etc

rasputin library import하기

728x90

설치...

github.com/expertanalytics/rasputin

 

expertanalytics/rasputin

Raster DEM to TIN tools. Contribute to expertanalytics/rasputin development by creating an account on GitHub.

github.com

brew install cmake

brew install gmp

brew install boost

brew install mpfr

brew install openblas

위 library들을 다 설치하고, github에서 하라는대로 다 했는데도 안 됨.

-> mac os에서는 안 돼서

-> linux에서 위 라이브러리를 모두 설치 후 빌드

성공적으로 설치

import test

 잘 된다. 기쁘다!

 

Untitled1
In [1]:
import numpy as np
import pyproj
from rasputin.reader import Rasterdata
from rasputin.mesh import Mesh
WARNING: RASPUTIN_DATA_DIR not set, using current directory.
In [2]:
def construct_rasterdata():
    raster = np.array([0, 0, 0, 
                       0, 1, 0, 
                       0, 0, 0], dtype=np.float32).reshape(3,3)
    cs = pyproj.CRS.from_epsg(32633)
    return Rasterdata(shape=(raster.shape[1], raster.shape[0]), x_min=0, 
                      y_max=20, delta_x=10, delta_y=10, array=raster,
                      coordinate_system=cs.to_proj4(), info={})
In [3]:
rd = construct_rasterdata()
mesh = Mesh.from_raster(data=rd)
pts = mesh.points
for face in mesh.faces:
    print("Face:", *[f'{fc:2d}' for fc in face])
    print(f"pts[{face[0]}]:", *[f'{pt:4.1f}' for pt in pts[face[0]]])
    print(f"pts[{face[1]}]:", *[f'{pt:4.1f}' for pt in pts[face[1]]])
    print(f"pts[{face[2]}]:", *[f'{pt:4.1f}' for pt in pts[face[2]]])
    print()
Face:  0  1  2
pts[0]: 10.0 10.0  1.0
pts[1]: 10.0 20.0  0.0
pts[2]:  0.0 20.0  0.0

Face:  0  2  3
pts[0]: 10.0 10.0  1.0
pts[2]:  0.0 20.0  0.0
pts[3]:  0.0 10.0  0.0

Face:  0  4  1
pts[0]: 10.0 10.0  1.0
pts[4]: 20.0 10.0  0.0
pts[1]: 10.0 20.0  0.0

Face:  4  5  1
pts[4]: 20.0 10.0  0.0
pts[5]: 20.0 20.0  0.0
pts[1]: 10.0 20.0  0.0

Face:  3  6  0
pts[3]:  0.0 10.0  0.0
pts[6]: 10.0  0.0  0.0
pts[0]: 10.0 10.0  1.0

Face:  3  7  6
pts[3]:  0.0 10.0  0.0
pts[7]:  0.0  0.0  0.0
pts[6]: 10.0  0.0  0.0

Face:  6  8  0
pts[6]: 10.0  0.0  0.0
pts[8]: 20.0  0.0  0.0
pts[0]: 10.0 10.0  1.0

Face:  8  4  0
pts[8]: 20.0  0.0  0.0
pts[4]: 20.0 10.0  0.0
pts[0]: 10.0 10.0  1.0

/root/anaconda3/envs/torch/lib/python3.7/site-packages/ipykernel_launcher.py:8: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems
  
/root/anaconda3/envs/torch/lib/python3.7/site-packages/rasputin/mesh.py:46: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems
  mesh = cls(triangulate_dem.make_mesh(rasterdata_cpp, CRS.from_proj4(proj4_str).to_proj4()))
In [ ]: