ChHarding / TouchTerrain_for_CAGEO

Touch Terrain: A python app to create 3D printable terrain models (STL/OBJ) from only elevation data (via Google Earth Engine) or from a local geotiff. Has been used for CNC terrain models. Runs as a web app (http://touchterrain.org), as .py file (standalone.py) or as jupyter notebook. Docker image: https://github.com/ChHarding/TouchTerrain_jupyter_docker
http://touchterrain.geol.iastate.edu
218 stars 47 forks source link

Misaligned Tiles #77

Open lukezirngibl opened 1 year ago

lukezirngibl commented 1 year ago

Hey Chris,

I seem to be getting misaligned tiles when generating.

Aligned bottom:

Screen Shot 2023-04-03 at 15 57 57

Aligned ridge (misaligned bottom):

Screen Shot 2023-04-03 at 16 02 43

My config:

          "trlat": 47.88266953319475,# bottom left corner lat
          "trlon": 10.707753906131003,# bottom left corner long
          "bllat": 45.62561851186426, #top right corner lat
          "bllon": 5.813401946902514,# top right corner long
          "importedDEM": "./data.tif", # if not None, the raster file to use as DEM instead of using GEE (null in JSON)
          "printres": 0.5,  # resolution (horizontal) of 3D printer (= size of one pixel) in mm
          "ntilesx": 9,      # number of tiles in x and y
          "ntilesy": 6,
          "tilewidth": 100, # width of each tile in mm (<- !!!!!), tile height is calculated
          "basethick": 15, # thickness (in mm) of printed base
          "zscale": 1.0,      # elevation (vertical) scaling
          "fileformat": "STLb",  # format of 3D model files: "obj" wavefront obj (ascii),"STLa" ascii STL or "STLb" binary STL
          "tile_centered": False, # True-> all tiles are centered around 0/0, False, all tiles "fit together"
          "zip_file_name": "alps",   # base name of zipfile, .zip will be added
          "CPU_cores_to_use" : 0,  # 0 means all cores, None (null in JSON!) => don't use multiprocessing
          "max_cells_for_memory_only" : 1000 * 1000, # if raster is bigger, use temp_files instead of memory
          "no_bottom": False, # omit bottom triangles?
          #"rot_degs": 0, # rotate by degrees ccw  # CH disabled for now
          "bottom_image": None,  # 1 band greyscale image used for bottom relief
          "ignore_leq": None, # set values <= this to NaN, so they are ignored
          "lower_leq": None,  # e.g. [0.0, 2.0] values <= 0.0 will be lowered by 2mm in the final model
          "unprojected": False, # don't project to UTM, only usefull when using GEE for DEM rasters
          "only": None,# list of tile index [x,y] with is the only tile to be processed. None means process all tiles (index is 1 based)
          "poly_file": None, #"idaho.kml", #TT_poly_test.kml",
          "smooth_borders": True, # smooth borders

logfile:

Log for creating 9 x 6 3D model tile(s) from data.tif 

started: 16:25:38.556908 
source raster upper left corner (x/y):  229110.0 5305650.0 
source raster cells size 30.0 m  (7769, 13815) 
projection: WGS 84 / UTM zone 32N 
z-scale: 1.3 
basethickness: 15 
fileformat: STLb 
tile_centered: False 
no_bottom: False 
no_normals: True 
ignore_leq: None 
lower_leq: None 
importedGPX: None 
undefined GDAL value: None 
tile_width: 100 
tile_height: 56.23597538906985 
source raster width 414450.0 m, cell size: 30.0 m, elev. min/max is 40.0 4809.0 m 
source raster 3D print resolution would be 0.06514657980456026 mm 
re-sampling data.tif :
  (13815, 7769) 0.06514657980456026 mm  30.0 m  40.0 - 4809.0 m to 
  (1800, 1012) 0.5 mm  230.25 m  59.468372 - 4736.3257 m 
print res is 0.5 mm 
Cropping for nice fit of 9 (width) x 6 (height) tiles, removing: 0 columns, 4 rows 
 cropped (1800, 1012) to (1800, 1008) 
 cropping changed physical size from 100 mm x 84.33333333333333 mm 
 to 100.0 mm x 84.0 mm 
map scale is 1 : 460500.0 
Cells per tile (x/y) 200 x 168 
using single-core only 

9 x 6 tiles, tile size 100.00 x 84.00 mm

tile 1 1 : height:  191.6655 - 15.802115 mm , file size: 3 Mb 
tile 1 2 : height:  183.84213 - 15.860547 mm , file size: 3 Mb 
tile 1 3 : height:  191.79538 - 17.04288 mm , file size: 3 Mb 
tile 1 4 : height:  195.88974 - 18.080755 mm , file size: 3 Mb 
tile 1 5 : height:  291.8095 - 18.951483 mm , file size: 3 Mb 
tile 1 6 : height:  225.69896 - 19.047348 mm , file size: 3 Mb 
tile 2 1 : height:  206.6946 - 16.24718 mm , file size: 3 Mb 
tile 2 2 : height:  216.4829 - 17.125134 mm , file size: 3 Mb 
tile 2 3 : height:  318.2327 - 18.50724 mm , file size: 3 Mb 
tile 2 4 : height:  368.91043 - 18.62294 mm , file size: 3 Mb 
tile 2 5 : height:  366.321 - 19.982578 mm , file size: 3 Mb 
tile 2 6 : height:  427.32034 - 21.141172 mm , file size: 3 Mb 
tile 3 1 : height:  246.68542 - 17.778305 mm , file size: 3 Mb 
tile 3 2 : height:  297.28238 - 17.79468 mm , file size: 3 Mb 
tile 3 3 : height:  422.0 - 18.236658 mm , file size: 3 Mb 
tile 3 4 : height:  369.37585 - 20.451563 mm , file size: 3 Mb 
tile 3 5 : height:  365.57553 - 22.839916 mm , file size: 3 Mb 
tile 3 6 : height:  454.22202 - 27.088457 mm , file size: 3 Mb 
tile 4 1 : height:  197.90182 - 18.331402 mm , file size: 3 Mb 
tile 4 2 : height:  257.0738 - 18.244726 mm , file size: 3 Mb 
tile 4 3 : height:  427.58197 - 17.398708 mm , file size: 3 Mb 
tile 4 4 : height:  528.4612 - 22.796164 mm , file size: 3 Mb 
tile 4 5 : height:  477.08356 - 24.418552 mm , file size: 3 Mb 
tile 4 6 : height:  845.9084 - 25.337296 mm , file size: 3 Mb 
tile 5 1 : height:  282.0828 - 18.356377 mm , file size: 3 Mb 
tile 5 2 : height:  286.19427 - 16.958464 mm , file size: 3 Mb 
tile 5 3 : height:  393.76727 - 21.491447 mm , file size: 3 Mb 
tile 5 4 : height:  470.08173 - 25.131504 mm , file size: 3 Mb 
tile 5 5 : height:  310.43695 - 25.670383 mm , file size: 3 Mb 
tile 5 6 : height:  191.5922 - 26.507986 mm , file size: 3 Mb 
tile 6 1 : height:  342.41873 - 16.677013 mm , file size: 3 Mb 
tile 6 2 : height:  355.72488 - 17.600143 mm , file size: 3 Mb 
tile 6 3 : height:  350.1448 - 22.64892 mm , file size: 3 Mb 
tile 6 4 : height:  453.6622 - 23.638344 mm , file size: 3 Mb 
tile 6 5 : height:  191.46535 - 23.769928 mm , file size: 3 Mb 
tile 6 6 : height:  173.82703 - 20.547045 mm , file size: 3 Mb 
tile 7 1 : height:  384.13315 - 16.263924 mm , file size: 3 Mb 
tile 7 2 : height:  391.51416 - 20.61398 mm , file size: 3 Mb 
tile 7 3 : height:  419.2372 - 22.603453 mm , file size: 3 Mb 
tile 7 4 : height:  564.86 - 22.121048 mm , file size: 3 Mb 
tile 7 5 : height:  181.94656 - 23.711742 mm , file size: 3 Mb 
tile 7 6 : height:  180.76138 - 21.588915 mm , file size: 3 Mb 
tile 8 1 : height:  401.62704 - 18.00505 mm , file size: 3 Mb 
tile 8 2 : height:  391.97302 - 21.087027 mm , file size: 3 Mb 
tile 8 3 : height:  490.00018 - 22.85838 mm , file size: 3 Mb 
tile 8 4 : height:  979.11 - 21.507284 mm , file size: 3 Mb 
tile 8 5 : height:  266.41058 - 25.268267 mm , file size: 3 Mb 
tile 8 6 : height:  182.18958 - 22.7939 mm , file size: 3 Mb 
tile 9 1 : height:  645.9717 - 18.776098 mm , file size: 3 Mb 
tile 9 2 : height:  656.80676 - 20.969414 mm , file size: 3 Mb 
tile 9 3 : height:  740.87946 - 23.244572 mm , file size: 3 Mb 
tile 9 4 : height:  633.40533 - 23.986706 mm , file size: 3 Mb 
tile 9 5 : height:  596.34216 - 23.880842 mm , file size: 3 Mb 
tile 9 6 : height:  59.468372 - 24.534832 mm , file size: 3 Mb 

total size for all tiles: 177 Mb 

processing finished: 16:26:05.614725 

Any idea what could be causing this? Thanks for your help!

ChHarding commented 1 year ago

Well, I’m guessing there’s something going wrong with calculating the lowest overall elevation. From memory, I think I grit the elevation min() of all tiles and use that the bottom for all tiles. Does this all happen for say just 2 x 2 tiles?

On Apr 3, 2023, at 09:04, Luke Zirngibl @.**@.>> wrote:

Hey Chris,

I seem to be getting misaligned tiles when generating.

[Screen Shot 2023-04-03 at 15 57 57]https://user-images.githubusercontent.com/8725920/229533087-ef1e6df3-05e9-486d-a86f-0ae17e692ff2.png

[Screen Shot 2023-04-03 at 16 02 43]https://user-images.githubusercontent.com/8725920/229533098-9e120801-36e0-409b-b4c9-1cdd904bab9b.png

My config:

      "trlat": 47.88266953319475,# bottom left corner lat
      "trlon": 10.707753906131003,# bottom left corner long
      "bllat": 45.62561851186426, #top right corner lat
      "bllon": 5.813401946902514,# top right corner long
      "importedDEM": "./data.tif", # if not None, the raster file to use as DEM instead of using GEE (null in JSON)
      "printres": 0.5,  # resolution (horizontal) of 3D printer (= size of one pixel) in mm
      "ntilesx": 9,      # number of tiles in x and y
      "ntilesy": 6,
      "tilewidth": 100, # width of each tile in mm (<- !!!!!), tile height is calculated
      "basethick": 15, # thickness (in mm) of printed base
      "zscale": 1.0,      # elevation (vertical) scaling
      "fileformat": "STLb",  # format of 3D model files: "obj" wavefront obj (ascii),"STLa" ascii STL or "STLb" binary STL
      "tile_centered": False, # True-> all tiles are centered around 0/0, False, all tiles "fit together"
      "zip_file_name": "Ikea-AlpsCH_9x6",   # base name of zipfile, .zip will be added
      "CPU_cores_to_use" : 0,  # 0 means all cores, None (null in JSON!) => don't use multiprocessing
      "max_cells_for_memory_only" : 1000 * 1000, # if raster is bigger, use temp_files instead of memory
      "no_bottom": False, # omit bottom triangles?
      #"rot_degs": 0, # rotate by degrees ccw  # CH disabled for now
      "bottom_image": None,  # 1 band greyscale image used for bottom relief
      "ignore_leq": None, # set values <= this to NaN, so they are ignored
      "lower_leq": None,  # e.g. [0.0, 2.0] values <= 0.0 will be lowered by 2mm in the final model
      "unprojected": False, # don't project to UTM, only usefull when using GEE for DEM rasters
      "only": None,# list of tile index [x,y] with is the only tile to be processed. None means process all tiles (index is 1 based)
      "poly_file": None, #"idaho.kml", #TT_poly_test.kml",
      "smooth_borders": True, # smooth borders

Any idea what could be causing this? Thanks for your help!

— Reply to this email directly, view it on GitHubhttps://github.com/ChHarding/TouchTerrain_for_CAGEO/issues/77, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AEYDF5JBPC6TP3D6ACPVWVDW7LKILANCNFSM6AAAAAAWRL4URQ. You are receiving this because you are subscribed to this thread.Message ID: @.***>

Chris Harding Associate Professor Department of Geological & Atmospheric Sciences Touchterrain.geol.iastate.eduhttp://Touchterrain.geol.iastate.edu

lukezirngibl commented 1 year ago

yeah, it seems like the less tiles i have, the less the severe the misalignment is (which would make sense if its related to the lowest elevation computations)

ChHarding commented 1 year ago

OK, I”m guessing I broke something then recently in that area when I added the min_elev setting. If I get some time tomorrow I’ll have a look.

On Apr 3, 2023, at 10:08, Luke Zirngibl @.**@.>> wrote:

yeah, it seems like the less tiles i have, the less the severe the misalignment is (which would make sense if its related to the lowest elevation computations)

— Reply to this email directly, view it on GitHubhttps://github.com/ChHarding/TouchTerrain_for_CAGEO/issues/77#issuecomment-1494503824, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AEYDF5J2MMOTK6VDBSEC5NTW7LRWVANCNFSM6AAAAAAWRL4URQ. You are receiving this because you commented.Message ID: @.***>

Chris Harding Associate Professor Department of Geological & Atmospheric Sciences Touchterrain.geol.iastate.eduhttp://Touchterrain.geol.iastate.edu

ChHarding commented 1 year ago

Luke,

I messed something up during the min_height parameter implementation (as I had suspected) and it should be fixed now. Thanks for telling me!