checkpoint the post

This commit is contained in:
Joe Ardent 2023-01-14 23:05:45 -08:00
parent dba851bfa7
commit 6c38572d58

View file

@ -1,7 +1,7 @@
+++ +++
title = "A Thoroughly Digital Artifact" title = "A Thoroughly Digital Artifact"
slug = "a-thoroughly-digital-artifact" slug = "a-thoroughly-digital-artifact"
date = "2023-01-11" date = "2023-01-17"
[taxonomies] [taxonomies]
tags = ["3dprinting", "CAD", "GIS", "CNC", "art", "sundries", "proclamation"] tags = ["3dprinting", "CAD", "GIS", "CNC", "art", "sundries", "proclamation"]
+++ +++
@ -40,7 +40,7 @@ say, that was a bluff.
![the programmer's creed: we do these things not because they are easy, but because we thought they ![the programmer's creed: we do these things not because they are easy, but because we thought they
were going to be easy -- from twitter user @unoservix, 2016-08-05][programmers_creed] were going to be easy -- from twitter user @unoservix, 2016-08-05][programmers_creed]
*<center><sup><sub>me, every single time</sub></sup></center>* *<center><sup><sub>me, every. single. time.</sub></sup></center>*
Also needless to say, my bluff was immediately called, and I had the following exchange with the Also needless to say, my bluff was immediately called, and I had the following exchange with the
shop: shop:
@ -96,7 +96,7 @@ too complicated and your computer doesn't have enough RAM (*note: foreshadowing*
*<center><sup><sub>this cube's mesh has too many vertices and edges, I hope my computer has enough *<center><sup><sub>this cube's mesh has too many vertices and edges, I hope my computer has enough
RAM to work with it</sub></sup></center>* RAM to work with it</sub></sup></center>*
But so far, I had nothing at all. Time to get some data and see if I can turn it into a model. But at that moment, I had nothing at all. Time to get some data and see if I can turn it into a model.
# Public data # Public data
@ -107,16 +107,16 @@ have been perfect:
[https://apps.nationalmap.gov/downloader/](https://apps.nationalmap.gov/downloader/) [https://apps.nationalmap.gov/downloader/](https://apps.nationalmap.gov/downloader/)
Did I just accidentally miss it then? Did I not know how to recognize it because I didn't know what Did I just accidentally miss it then? Did I find it and not recognize its utility because I didn't
I was doing *at all*? The world may never know, but at least now you can benefit from my many, many know what I was doing *at all*? The world may never know, but at least now you can benefit from my
missteps. many, many missteps.
## From space? ## From space?
Anyway, having not found anything I could really use from the USGS, I found [this Anyway, having not found anything I could really use from the USGS, I found [this
site](https://portal.opentopography.org/raster?opentopoID=OTSRTM.082015.4326.1), from site](https://portal.opentopography.org/raster?opentopoID=OTSRTM.082015.4326.1), from
OpenTopography, an organization run by the UCSD Supercomputer Center, under a grant from the OpenTopography, an organization run by the UCSD Supercomputer Center, under a grant from the
National Science Foundation. So, hooray for public data! National Science Foundation. So, still hooray for public data!
That particular page is for a particular dataset; in this case, "[SRTM That particular page is for a particular dataset; in this case, "[SRTM
GL1](http://www2.jpl.nasa.gov/srtm/) Global 30m". "SRTM" stands for "[Shuttle Radar Topography GL1](http://www2.jpl.nasa.gov/srtm/) Global 30m". "SRTM" stands for "[Shuttle Radar Topography
@ -204,10 +204,12 @@ the entire border of California, then one billion, four-hundred-forty-three mill
five-hundred-thirty-one thousand, and four-hundred-twenty-six (40,757 times 35,418) is pretty close. five-hundred-thirty-one thousand, and four-hundred-twenty-six (40,757 times 35,418) is pretty close.
The other units in there are under the "Coordinate System is" section, and are meters relative to The other units in there are under the "Coordinate System is" section, and are meters relative to
the [World Geodetic System 1984](https://en.wikipedia.org/wiki/World_Geodetic_System) vertical the [World Geodetic System 1984](https://en.wikipedia.org/wiki/World_Geodetic_System) vertical datum
datum; the very last line is the lowest and highest points in file, which are <a (distances from this reference surface in the dataset are within 16 meters of the true distance in
reality); the very last line is the lowest and highest points in file, which are <a
name="minmax-height"></a>-130 meters and 4,412 meters respectively, relative to the baseline height name="minmax-height"></a>-130 meters and 4,412 meters respectively, relative to the baseline height
defined by the WGS84 ellipsoid. If you were to view the file as though it were an image, it would look like this: defined by the WGS84 ellipsoid. If you were to view the file as though it were an image, it would
look like this:
![the ca_topo image; it's hard to make out details and very dark][small_ca_topo] ![the ca_topo image; it's hard to make out details and very dark][small_ca_topo]
*<center><sup><sub>if you squint, you can kinda see the mountains</sub></sup></center>* *<center><sup><sub>if you squint, you can kinda see the mountains</sub></sup></center>*
@ -215,7 +217,8 @@ defined by the WGS84 ellipsoid. If you were to view the file as though it were a
This is because the highest possible value an image like that could have for a pixel is This is because the highest possible value an image like that could have for a pixel is
65,535[^16-bit-ints], and the highest point in our dataset is only 4,412, which is not that much in 65,535[^16-bit-ints], and the highest point in our dataset is only 4,412, which is not that much in
comparison. Plus, it includes portions of not-California in the height data, and ideally, we want comparison. Plus, it includes portions of not-California in the height data, and ideally, we want
those places to be 0; we have a little more processing to do before we can use this. those places to not be represented in our dataset; we have a little more processing to do before we
can use this.
## Cartography is complicated ## Cartography is complicated
@ -404,25 +407,28 @@ actual location in the real world.
A "heightmap" is an image file, like a geotiff, where each pixel's monochromatic intensity is meant A "heightmap" is an image file, like a geotiff, where each pixel's monochromatic intensity is meant
to represent height above some lowest plane. The difference is that the height values are normalized to represent height above some lowest plane. The difference is that the height values are normalized
so that the lowest value is 0, and the highest is the maximum possible value in the number so that the lowest value is 0, and the highest is the maximum possible value in the number
range. For our geotiff, which uses 16-bit numbers as previously mentioned, that maximum possible range. For geotiff digital elevation maps, which use 16-bit numbers as previously mentioned, that
value is 65,535. It also has no exact correspondence with anything else; it's not necessarily an maximum possible value is 65,535. But unlike a geotiff, a generic heightmap has no exact
accurate dataset, and won't include the GIS stuff like what projection it is, what the coordinate correspondence with anything else; it's not necessarily an accurate dataset, and won't include the
bounding boxes are, etc. But it *is* useful for turning into a mesh. GIS stuff like what projection it is, what the coordinate bounding boxes are, etc. But it *is*
useful for turning into a mesh.
And here I get to the [final GDAL tool](https://gdal.org/programs/gdal_translate.html) I used, And here I get to the [final GDAL tool](https://gdal.org/programs/gdal_translate.html) I used,
`gdal_translate`. This is something that can read in a geotiff, and write out a different image `gdal_translate`. This is something that can read in a geotiff, and write out a different image
format. When in doubt, [PNG](https://en.wikipedia.org/wiki/Portable_Network_Graphics) is fine, I format. When in doubt, [PNG](https://en.wikipedia.org/wiki/Portable_Network_Graphics) is fine, I
always say. It's a simple format that nearly everything can read, and is compressed so it should be always say. It's a simple format that nearly everything can read, and is compressed so it should be
much smaller file. a much smaller file on disk, even if it's the same number of pixels. Smaller file size is always
easier.
> `gdal_translate -of PNG -ot UInt16 -scale -130 4412 0 65535 masked_ca_topo.tif heightmap.png` > `gdal_translate -of PNG -ot UInt16 -scale -130 4412 0 65535 masked_ca_topo.tif heightmap.png`
Like we saw <a href="#minmax-height">earlier</a>, the lowest point we had was -130, and the highest Like we saw <a href="#minmax-height">earlier</a>, the lowest point we had in our data was -130
was 4,412. The `-scale -130 4412 0 65535` arguments are saying, "anything with a height of -130 meters, and the highest was 4,412. The `-scale -130 4412 0 65535` arguments are saying, "anything
should be set to 0, and anything with a height of 4,412 should be set to 65,535, and anything with a height of -130 should be totally dark, and anything with a height of 4,412 should be as
in-between should be set proportionately." This is a linear mapping, and preserves the relationships bright as possible, and anything in-between should be set proportionately." This is a linear
between vertical features (so, if something is twice as tall as another thing, that will mapping, and preserves the relationships between vertical features (that is, if something is twice
still be true after being scaled), so it's "accurate" in a sense (*note: more foreshadowing*). as tall as another thing, that will still be true after being scaled), so in a sense, it's
"accurate" (*note: more foreshadowing*).
Once I had the PNG file, I used the [ImageMagick](https://imagemagick.org/script/convert.php) `convert` Once I had the PNG file, I used the [ImageMagick](https://imagemagick.org/script/convert.php) `convert`
command to scale the file down to a reasonable size. Finally, I had something I could use to make a command to scale the file down to a reasonable size. Finally, I had something I could use to make a
@ -438,9 +444,11 @@ geometry with the heightmap!
# A mesh is born # A mesh is born
# Test prints # Test prints
## Give it a good smear ## Back to the realm of the image
# Final cut # Final cut