add options and postpone imports to massively reduce memory usage

This commit is contained in:
Laura Klünder 2024-02-07 18:17:13 +01:00
parent 0e5b10b586
commit d7f175f7ef
12 changed files with 89 additions and 61 deletions

View file

@ -4,7 +4,6 @@ from functools import reduce
from itertools import chain
import numpy as np
from scipy.interpolate import NearestNDInterpolator
from shapely import prepared
from shapely.geometry import GeometryCollection
from shapely.ops import unary_union
@ -309,6 +308,8 @@ class LevelGeometries:
vertex_values[i_vertices] = value_func(item, i_vertices)
vertex_value_mask[i_vertices] = True
from scipy.interpolate import NearestNDInterpolator # moved in here to save memory
if np.any(vertex_value_mask) and not np.all(vertex_value_mask):
interpolate = NearestNDInterpolator(self.vertices[vertex_value_mask],
vertex_values[vertex_value_mask])