Replaced gippy with rasterio

pull/979/head
Piero Toffanin 2019-04-29 17:20:09 -04:00
rodzic f9ed7900fd
commit 5a06291ac3
6 zmienionych plików z 29 dodań i 40 usunięć

Wyświetl plik

@ -74,7 +74,6 @@ RUN pip install -U \
scipy \
shapely \
xmltodict \
https://github.com/OpenDroneMap/gippy/archive/numpyfix.zip \
rasterio \
attrs==19.1.0

Wyświetl plik

@ -91,7 +91,7 @@ install() {
libboost-log-dev
echo "Installing split-merge Dependencies"
pip install -U scipy numpy==1.15.4 shapely pyproj https://github.com/OpenDroneMap/gippy/archive/numpyfix.zip psutil
pip install -U scipy numpy==1.15.4 shapely pyproj psutil
echo "Compiling SuperBuild"
cd ${RUNPATH}/SuperBuild

Wyświetl plik

@ -1,6 +1,6 @@
import os
import sys
import gippy
import rasterio
import numpy
import math
import time
@ -236,35 +236,33 @@ def post_process(geotiff_path, output_path, smoothing_iterations=1):
log.ODM_INFO('Starting post processing (smoothing)...')
img = gippy.GeoImage(geotiff_path)
nodata = img[0].nodata()
arr = img[0].read()
with rasterio.open(geotiff_path) as img:
nodata = img.nodatavals[0]
dtype = img.dtypes[0]
arr = img.read()[0]
# Median filter (careful, changing the value 5 might require tweaking)
# the lines below. There's another numpy function that takes care of
# these edge cases, but it's slower.
for i in range(smoothing_iterations):
log.ODM_INFO("Smoothing iteration %s" % str(i + 1))
arr = signal.medfilt(arr, 5)
# Median filter (careful, changing the value 5 might require tweaking)
# the lines below. There's another numpy function that takes care of
# these edge cases, but it's slower.
for i in range(smoothing_iterations):
log.ODM_INFO("Smoothing iteration %s" % str(i + 1))
arr = signal.medfilt(arr, 5)
# Fill corner points with nearest value
if arr.shape >= (4, 4):
arr[0][:2] = arr[1][0] = arr[1][1]
arr[0][-2:] = arr[1][-1] = arr[2][-1]
arr[-1][:2] = arr[-2][0] = arr[-2][1]
arr[-1][-2:] = arr[-2][-1] = arr[-2][-2]
# Median filter leaves a bunch of zeros in nodata areas
locs = numpy.where(arr == 0.0)
arr[locs] = nodata
# write output
with rasterio.open(output_path, 'w', **img.profile) as imgout:
imgout.write(arr.astype(dtype), 1)
# Fill corner points with nearest value
if arr.shape >= (4, 4):
arr[0][:2] = arr[1][0] = arr[1][1]
arr[0][-2:] = arr[1][-1] = arr[2][-1]
arr[-1][:2] = arr[-2][0] = arr[-2][1]
arr[-1][-2:] = arr[-2][-1] = arr[-2][-2]
# Median filter leaves a bunch of zeros in nodata areas
locs = numpy.where(arr == 0.0)
arr[locs] = nodata
# write output
imgout = gippy.GeoImage.create_from(img, output_path)
imgout.set_nodata(nodata)
imgout[0].write(arr)
output_path = imgout.filename()
imgout = None
log.ODM_INFO('Completed post processing to create %s in %s' % (os.path.relpath(output_path), datetime.now() - start))
return output_path

Wyświetl plik

@ -41,10 +41,7 @@ def euclidean_merge_dems(input_dems, output_dem, creation_options={}):
logging.disable(logging.DEBUG)
with rasterio.open(existing_dems[0]) as first:
src_nodata = 0
nodatavals = first.get_nodatavals()
if len(nodatavals) > 0:
src_nodata = nodatavals[0]
src_nodata = first.nodatavals[0]
res = first.res
dtype = first.dtypes[0]
profile = first.profile
@ -148,10 +145,7 @@ def euclidean_merge_dems(input_dems, output_dem, creation_options={}):
# With rio merge this just adds an extra row, but when the
# imprecision occurs at each block, you get artifacts
nodata = 0
nodatavals = src_d.get_nodatavals()
if len(nodatavals) > 0:
nodata = nodatavals[0]
nodata = src_d.nodatavals[0]
# Alternative, custom get_window using rounding
src_window = tuple(zip(rowcol(

Wyświetl plik

@ -1,6 +1,5 @@
from __future__ import absolute_import
import os, shutil, sys, struct, random, math
from gippy import GeoImage
from opendm.dem import commands
from opendm import system
from opendm import log

Wyświetl plik

@ -74,7 +74,6 @@ RUN pip install -U \
scipy \
shapely \
xmltodict \
https://github.com/OpenDroneMap/gippy/archive/numpyfix.zip \
rasterio \
attrs==19.1.0