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
191 stars 44 forks source link

Output min and max elevations within generated output #47

Closed doug-harriman closed 3 years ago

doug-harriman commented 3 years ago

On the output page that lists the parameters used for generation, I would like to request that you also output the minimum and maximum elevations within the data set. That provides the information necessary to determine the actual Z-scaling used if the data is scaled to a fixed height, as well as the base offset elevation. I'm working on a small program to generate topographic elevation lines from the data set to laser etch them into a CNC'd topographic relief, and need that info to get the line labels right. Very much a work in progress, see: https://github.com/doug-harriman/topo-box

ChHarding commented 3 years ago

I already log the pre-z-scaled elevation min/max like this:

process started: 23:06:48.595372

Region (lat/lon): 46.22980441137155 -122.12893771814642 (top right) 46.154584342537 -122.25169467848252 (bottom left) center at [-122.19031619831446, 46.192194376954276] UTM 10 N , EPSG:32610 lon/lat size in degrees: [0.12275696033610473, 0.0752200688345539] Earth Engine raster: USGS/NED USGS National Elevation Dataset 1/3 arc-second URL for geotiff is: https://earthengine.googleapis.com/v1alpha/projects/earthengine-legacy/thumbnails/35551c7968acbf9b6691d5a69193042e-49ddba912b6be89eef1716d27d68432d:getPixels geotiff size: 0.1846637725830078 Mb cell size 37.90471094952414 m, upper left corner (x/y): 557692.0122003487 5119978.831506973 full (untiled) raster (height,width) (224, 253) float64 elev. min/max: 795.51416015625 2536.448486328125 cell size: 37.90471094952414 m
adjusted print res from the requested 0.4 mm to 0.3952569169960474 mm to ensure correct model dimensions total model size in mm: 100.0 x 88.53754940711462 map scale is 1 : 95898.91870229607 From requested model height of 20.0 mm, calculated a z-scale of 1.1016948458149751 Cells per tile (x/y) 253 x 224 using single-core only

1 x 1 tiles, tile size 100.00 x 88.54 mm

tile 1 1 : height: 1.0 - 21.0 mm , file size: 11 Mb

total size for all tiles: 11 Mb added full geotiff as NED_-122.19_46.19.tif

processing finished: 23:06:54.087557

Granted, it’s no pretty and I could give the min/max it’s own line. Or are you looking for something different?

Cheers

Chris

On Jun 22, 2021, at 09:56, Doug Harriman @.***> wrote:

On the output page that lists the parameters used for generation, I would like to request that you also output the minimum and maximum elevations within the data set. That provides the information necessary to determine the actual Z-scaling used if the data is scaled to a fixed height.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ChHarding/TouchTerrain_for_CAGEO/issues/47, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEYDF5L7XUSDETIWQ5ZQQPDTUCQANANCNFSM47D3UNAA.

Chris Harding Associate Professor Department of Geological & Atmospheric Sciences

TouchTerrain.geol.iastate.edu

doug-harriman commented 3 years ago

Chris - That's what I needed. I had not looked at the log file in the zip, my apologies. I had only looked at the web page generated that provides the zip download link, and this info wasn't present there. Thanks for the follow up.

ChHarding commented 3 years ago

Doug,

no problem! It’s a pretty obscure file :) Can I ask what you’re using the app for?

Cheers

Chris

On Jun 23, 2021, at 17:03, Doug Harriman @.***> wrote:

Chris - That's what I needed. I had not looked at the log file in the zip, my apologies. I had only looked at the web page generated that provides the zip download link, and this info wasn't present there. Thanks for the follow up.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ChHarding/TouchTerrain_for_CAGEO/issues/47#issuecomment-867190546, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEYDF5IGEZ5BP6K6ZGB63A3TUJK4PANCNFSM47D3UNAA.

Chris Harding Associate Professor Department of Geological & Atmospheric Sciences

TouchTerrain.geol.iastate.edu

doug-harriman commented 3 years ago

Chris -

My goal is to mill terrain profiles out of wood, then laser etch elevation contours into them. I have a Sainsmart 3018 mill with a laser head for it. Because there's an active Z axis unlike most laser cutters, I can run it at different focal planes. Need the elevations to get the proper labels on the elevation lines. I'm using Matplotlib contour plots to generate the elevation lines, then converting to G-Code. I have that working now. Next up is to get the labels properly sized and rotated so they're aligned with the surface at the proper location. You can check out the project on github.

ChHarding commented 3 years ago

Neat!

Looking at

https://github.com/doug-harriman/topo-box/blob/32f45db05bcb0401126a116644ac1aa66968bc5a/oregon-black-butte/stl2topo_contours.py#L95

have you tried opening the geo tiff in GDAL? This is essentially how I read in the DEM data to the make a messy from. It’s kinda clunky and can be tricky to install but it will give you a numpy array with elevation values.

Otherwise PIL/pillow might be able to read in a geotiff. I certainly can do tiffs with float pixels but I don’t remember if I ever tried a geotiff.

On Jun 24, 2021, at 08:44, Doug Harriman @.***> wrote:

Chris -

My goal is to mill terrain profiles out of wood, then laser etch elevation contours into them. I have a Sainsmart 3018 mill with a laser head for it. Because there's an active Z axis unlike most laser cutters, I can run it at different focal planes. Need the elevations to get the proper labels on the elevation lines. I'm using Matplotlib contour plots to generate the elevation lines, then converting to G-Code. I have that working now. Next up is to get the labels properly sized and rotated so they're aligned with the surface at the proper location. You can check out the project on github https://github.com/doug-harriman/topo-box#elevation-contour-generation-tool-process-overview.

Doug — You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ChHarding/TouchTerrain_for_CAGEO/issues/47#issuecomment-867648656, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEYDF5MNA7MDO5WWUDLSIZDTUMZFNANCNFSM47D3UNAA.

Chris Harding Associate Professor Department of Geological & Atmospheric Sciences

TouchTerrain.geol.iastate.edu

doug-harriman commented 3 years ago

I haven't tried the GeoTIFF. My initial run through this code (you can see it in the python file history) was reading in an image from https://tangrams.github.io/heightmapper/. That was easy to deal with, but in the end, the image was too low of a resolution to deal with. I may play with that. Label positioning is going to be a bit of a pain with STL. I've calculated the center of the text label, but now I need to find the mesh triangle that encloses the center point so I can determine the Z height, and the normal direction. Prefiltering the Z-levels from the image might limit the search quite a bit. Without some sort of optimization, it's going to be slow.

ChHarding commented 3 years ago

https://pypi.org/project/trimesh/

say it has

Ray-mesh queries including location, triangle index, etc.

So I imagine you would construct a vertical ray from the bottom at the center point and it would return the triangle id?

On Jun 24, 2021, at 12:43, Doug Harriman @.***> wrote:

I haven't tried the GeoTIFF. My initial run through this code (you can see it in the python file history) was reading in an image from https://tangrams.github.io/heightmapper/ https://tangrams.github.io/heightmapper/. That was easy to deal with, but in the end, the image was too low of a resolution to deal with. I may play with that. Label positioning is going to be a bit of a pain with STL. I've calculated the center of the text label, but now I need to find the mesh triangle that encloses the center point so I can determine the Z height, and the normal direction. Prefiltering the Z-levels from the image might limit the search quite a bit. Without some sort of optimization, it's going to be slow.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ChHarding/TouchTerrain_for_CAGEO/issues/47#issuecomment-867830117, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEYDF5PWTJ5DLKJUAJPIL6TTUNVF5ANCNFSM47D3UNAA.

Chris Harding Associate Professor Department of Geological & Atmospheric Sciences

TouchTerrain.geol.iastate.edu

doug-harriman commented 3 years ago

Awesome! Thank you. That's the functionality I'm after. I'm taking tomorrow off from work, so hope to have the text G-Code generation done tomorrow. Should see commits coming through on my project. I also need to dink with the font size. I need to figure out how to get the matplotlib figure set up with the correct units so that there's a clear mapping from the pt size to mm. Always another layer to the onion. After that, it should have all of the functionality needed, then just some code cleanup. Hope to get milling soon.

ChHarding commented 3 years ago

Could you use PIL/pillow instead of Matplotlib? There’s some info on how specific fonts relate to pixels: https://stackoverflow.com/questions/43060479/how-to-get-the-font-pixel-height-using-pils-imagefont-class

On Jun 24, 2021, at 16:27, Doug Harriman @.***> wrote:

Awesome! Thank you. That's the functionality I'm after. I'm taking tomorrow off from work, so hope to have the text G-Code generation done tomorrow. Should see commits coming through on my project. I also need to dink with the font size. I need to figure out how to get the matplotlib figure set up with the correct units so that there's a clear mapping from the pt size to mm. Always another layer to the onion. After that, it should have all of the functionality needed, then just some code cleanup. Hope to get milling soon.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ChHarding/TouchTerrain_for_CAGEO/issues/47#issuecomment-867962894, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEYDF5NS2IHUNUFLQFW7VALTUOPKRANCNFSM47D3UNAA.

Chris Harding Associate Professor Department of Geological & Atmospheric Sciences

TouchTerrain.geol.iastate.edu

doug-harriman commented 3 years ago

That doesn't really solve my problem. Matplotlib.clabel generates the text labels for the contour elevation. It also breaks the contour lines so that the labels have a space to live in within the contour line. That functionality is important. I need to know the size of the text in that box so that when I generate the gcode for the text using https://pypi.org/project/TextToGcode/ I can make it the right size to fit.

On Thu, Jun 24, 2021 at 5:40 PM ChHarding @.***> wrote:

Could you use PIL/pillow instead of Matplotlib? There’s some info on how specific fonts relate to pixels: https://stackoverflow.com/questions/43060479/how-to-get-the-font-pixel-height-using-pils-imagefont-class

On Jun 24, 2021, at 16:27, Doug Harriman @.***> wrote:

Awesome! Thank you. That's the functionality I'm after. I'm taking tomorrow off from work, so hope to have the text G-Code generation done tomorrow. Should see commits coming through on my project. I also need to dink with the font size. I need to figure out how to get the matplotlib figure set up with the correct units so that there's a clear mapping from the pt size to mm. Always another layer to the onion. After that, it should have all of the functionality needed, then just some code cleanup. Hope to get milling soon.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/ChHarding/TouchTerrain_for_CAGEO/issues/47#issuecomment-867962894>, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AEYDF5NS2IHUNUFLQFW7VALTUOPKRANCNFSM47D3UNAA .

Chris Harding Associate Professor Department of Geological & Atmospheric Sciences

TouchTerrain.geol.iastate.edu

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/ChHarding/TouchTerrain_for_CAGEO/issues/47#issuecomment-868097838, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHKPL5FNVKBXASTXXIBD4OLTUPF7FANCNFSM47D3UNAA .

doug-harriman commented 3 years ago

Chris -

Got my first prototype done of a topographic map with laser etched elevation contour mapping. It worked really well, though I have a little work to do on the alignment of the laser image to the 3D part. Photos at: https://github.com/doug-harriman/topo-box#oregon-black-butte

Thanks for advice on the ray tracing with trimesh. That worked perfectly for both Z-height mapping and finding the surface normal to do the 3D rotation of the text. I also used it for taking an SVG from OpenStreetMaps and mapping roads and trails to the proper Z-height for laser etching. In the end, this one is a little busy with all of those etches, but with a little cleanup, I think it'll look really good.

On Fri, Jun 25, 2021 at 6:02 AM doug harriman @.***> wrote:

That doesn't really solve my problem. Matplotlib.clabel generates the text labels for the contour elevation. It also breaks the contour lines so that the labels have a space to live in within the contour line. That functionality is important. I need to know the size of the text in that box so that when I generate the gcode for the text using https://pypi.org/project/TextToGcode/ I can make it the right size to fit.

On Thu, Jun 24, 2021 at 5:40 PM ChHarding @.***> wrote:

Could you use PIL/pillow instead of Matplotlib? There’s some info on how specific fonts relate to pixels: https://stackoverflow.com/questions/43060479/how-to-get-the-font-pixel-height-using-pils-imagefont-class

On Jun 24, 2021, at 16:27, Doug Harriman @.***> wrote:

Awesome! Thank you. That's the functionality I'm after. I'm taking tomorrow off from work, so hope to have the text G-Code generation done tomorrow. Should see commits coming through on my project. I also need to dink with the font size. I need to figure out how to get the matplotlib figure set up with the correct units so that there's a clear mapping from the pt size to mm. Always another layer to the onion. After that, it should have all of the functionality needed, then just some code cleanup. Hope to get milling soon.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/ChHarding/TouchTerrain_for_CAGEO/issues/47#issuecomment-867962894>, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AEYDF5NS2IHUNUFLQFW7VALTUOPKRANCNFSM47D3UNAA .

Chris Harding Associate Professor Department of Geological & Atmospheric Sciences

TouchTerrain.geol.iastate.edu

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/ChHarding/TouchTerrain_for_CAGEO/issues/47#issuecomment-868097838, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHKPL5FNVKBXASTXXIBD4OLTUPF7FANCNFSM47D3UNAA .

ChHarding commented 3 years ago

Very nice!

Couple of notes:

Cheers

Chris

On Jul 1, 2021, at 10:10, Doug Harriman @.***> wrote:

Chris -

Got my first prototype done of a topographic map with laser etched elevation contour mapping. It worked really well, though I have a little work to do on the alignment of the laser image to the 3D part. Photos at: https://github.com/doug-harriman/topo-box#oregon-black-butte

Thanks for advice on the ray tracing with trimesh. That worked perfectly for both Z-height mapping and finding the surface normal to do the 3D rotation of the text. I also used it for taking an SVG from OpenStreetMaps and mapping roads and trails to the proper Z-height for laser etching. In the end, this one is a little busy with all of those etches, but with a little cleanup, I think it'll look really good.

  • Doug

On Fri, Jun 25, 2021 at 6:02 AM doug harriman @.***> wrote:

That doesn't really solve my problem. Matplotlib.clabel generates the text labels for the contour elevation. It also breaks the contour lines so that the labels have a space to live in within the contour line. That functionality is important. I need to know the size of the text in that box so that when I generate the gcode for the text using https://pypi.org/project/TextToGcode/ I can make it the right size to fit.

On Thu, Jun 24, 2021 at 5:40 PM ChHarding @.***> wrote:

Could you use PIL/pillow instead of Matplotlib? There’s some info on how specific fonts relate to pixels: https://stackoverflow.com/questions/43060479/how-to-get-the-font-pixel-height-using-pils-imagefont-class

On Jun 24, 2021, at 16:27, Doug Harriman @.***> wrote:

Awesome! Thank you. That's the functionality I'm after. I'm taking tomorrow off from work, so hope to have the text G-Code generation done tomorrow. Should see commits coming through on my project. I also need to dink with the font size. I need to figure out how to get the matplotlib figure set up with the correct units so that there's a clear mapping from the pt size to mm. Always another layer to the onion. After that, it should have all of the functionality needed, then just some code cleanup. Hope to get milling soon.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/ChHarding/TouchTerrain_for_CAGEO/issues/47#issuecomment-867962894>, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AEYDF5NS2IHUNUFLQFW7VALTUOPKRANCNFSM47D3UNAA .

Chris Harding Associate Professor Department of Geological & Atmospheric Sciences

TouchTerrain.geol.iastate.edu

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/ChHarding/TouchTerrain_for_CAGEO/issues/47#issuecomment-868097838, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHKPL5FNVKBXASTXXIBD4OLTUPF7FANCNFSM47D3UNAA .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ChHarding/TouchTerrain_for_CAGEO/issues/47#issuecomment-872327913, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEYDF5IP4MLBO4HM6B6N3HDTVSAQFANCNFSM47D3UNAA.

Chris Harding Associate Professor Department of Geological & Atmospheric Sciences

TouchTerrain.geol.iastate.edu

doug-harriman commented 3 years ago

Chris -

On Thu, Jul 1, 2021 at 8:47 AM ChHarding @.***> wrote:

Very nice!

Couple of notes:

  • if you find that the TouchTerrain model is to detailed you can always increase the nozzle size parameter, which is directly linked to the resolution of the geotiff DEM I get. I know that for CNC’lers the width in mm and nozzle size makes little sense as all the scaling happens in post processing, so I’m experimenting with CNC specific presets for both: Did you use these?
  • Your link for mesh reduction is interesting! I personally just use MeshMixer, where I can reduce it down to X% or to Y triangles, It also does preserve sharp edges. I’m guessing that would be much faster than having Fusion do it (?)
  • I like your laser etching! I had a similar idea for laser etching geologic outcrop polygons onto a 3D printed terrain model. That would be super useful for us b/c we would like to hand color the polygon according to their rock type/age. However, I blew up the cheap $50 laser I had used and now have to replace the board. I did get it to work on one example and the etching was actually strong enough to make a good line on grey PLA. Focusing, however was kinda tricky with this cheap laser. I should probably re-activate this …

Cheers

Chris

On Jul 1, 2021, at 10:10, Doug Harriman @.***> wrote:

Chris -

Got my first prototype done of a topographic map with laser etched elevation contour mapping. It worked really well, though I have a little work to do on the alignment of the laser image to the 3D part. Photos at: https://github.com/doug-harriman/topo-box#oregon-black-butte

Thanks for advice on the ray tracing with trimesh. That worked perfectly for both Z-height mapping and finding the surface normal to do the 3D rotation of the text. I also used it for taking an SVG from OpenStreetMaps and mapping roads and trails to the proper Z-height for laser etching. In the end, this one is a little busy with all of those etches, but with a little cleanup, I think it'll look really good.

  • Doug

On Fri, Jun 25, 2021 at 6:02 AM doug harriman @.***> wrote:

That doesn't really solve my problem. Matplotlib.clabel generates the text labels for the contour elevation. It also breaks the contour lines so that the labels have a space to live in within the contour line. That functionality is important. I need to know the size of the text in that box so that when I generate the gcode for the text using https://pypi.org/project/TextToGcode/ I can make it the right size to fit.

On Thu, Jun 24, 2021 at 5:40 PM ChHarding @.***> wrote:

Could you use PIL/pillow instead of Matplotlib? There’s some info on how specific fonts relate to pixels:

https://stackoverflow.com/questions/43060479/how-to-get-the-font-pixel-height-using-pils-imagefont-class

On Jun 24, 2021, at 16:27, Doug Harriman @.***> wrote:

Awesome! Thank you. That's the functionality I'm after. I'm taking tomorrow off from work, so hope to have the text G-Code generation done tomorrow. Should see commits coming through on my project. I also need to dink with the font size. I need to figure out how to get the matplotlib figure set up with the correct units so that there's a clear mapping from the pt size to mm. Always another layer to the onion. After that, it should have all of the functionality needed, then just some code cleanup. Hope to get milling soon.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub <

https://github.com/ChHarding/TouchTerrain_for_CAGEO/issues/47#issuecomment-867962894 , or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AEYDF5NS2IHUNUFLQFW7VALTUOPKRANCNFSM47D3UNAA

.

Chris Harding Associate Professor Department of Geological & Atmospheric Sciences

TouchTerrain.geol.iastate.edu

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub < https://github.com/ChHarding/TouchTerrain_for_CAGEO/issues/47#issuecomment-868097838 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AHKPL5FNVKBXASTXXIBD4OLTUPF7FANCNFSM47D3UNAA

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/ChHarding/TouchTerrain_for_CAGEO/issues/47#issuecomment-872327913>, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AEYDF5IP4MLBO4HM6B6N3HDTVSAQFANCNFSM47D3UNAA .

Chris Harding Associate Professor Department of Geological & Atmospheric Sciences

TouchTerrain.geol.iastate.edu

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/ChHarding/TouchTerrain_for_CAGEO/issues/47#issuecomment-872354468, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHKPL5GL3N3IG3LUVX5XZILTVSEXPANCNFSM47D3UNAA .