eldang / elevation_lookups

Takes an input file of paths described as series of points, outputs a file of data about the elevation changes along those paths.
Apache License 2.0
3 stars 2 forks source link

Assorted cleanup #14

Closed eldang closed 3 years ago

eldang commented 3 years ago

I'm having a harder time with parallelisation than I expected to, so I'll return to that tomorrow or possibly on Thursday after addressing https://github.com/eldang/elevation_lookups/issues/13 . So here's a very small increment of work:

  1. Reverts the README change yesterday which claimed that GDAL's not really a dependency, because https://github.com/eldang/elevation_lookups/issues/9#issuecomment-805337411 revealed that it is.
  2. Makes the SRTM subsystem give its temp files unique names and delete them at the end of a run, so that multiple instances of this project can run in parallel using the same data directory. This is probably not a particularly useful form of parallelisation, but it seems like better behaviour anyway.
  3. Sets up both objects that need a close() method so they can be called as context managers, just because I find that syntax tidier and more pythonic.
  4. Removes some debug output
eldang commented 3 years ago

Yeah, it's working how you've guessed. Specifically:

  1. Step through each integer degree square covering the input file, check if a local TIFF already exists for that and if not then download one as srtm/srtm.minx.miny.tif so future runs can find it.
  2. Make a temp file that stitches together whatever TIFFs are required, and then clips that to the extent of the input file.
  3. Load that temp file in rasterio and use that for all the lookups.
  4. Delete the temp file when done, but leave the source files.