Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streamlined site assessment process #50

Merged
merged 39 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
0ccae6f
Add buffer distance into max_count and max_offset.
Oct 13, 2024
7bf05a8
Fix incorrect use of meters in max_offset
Oct 14, 2024
e535981
fix incorrect removal of . and Float64
Oct 14, 2024
8a75fb8
Change to more efficient estimate of maximum pixel coverage
Oct 14, 2024
1bd14e6
update mistaken resolution parameter
Oct 24, 2024
4e1d793
Address comment around docstring formatting
Oct 25, 2024
42f6dc3
fix to filter based on region short names
Oct 28, 2024
c74f64c
Fix function signature in docstrings
ConnectedSystems Nov 6, 2024
924d4b8
Code format
ConnectedSystems Nov 6, 2024
9b06ce1
Remove threading (does not help in this instance)
ConnectedSystems Nov 6, 2024
e3e3323
Increase suitability threshold and change name for readability
ConnectedSystems Nov 6, 2024
639e99c
Remove threading (doesn't help)
ConnectedSystems Nov 6, 2024
e72850f
Format for readability
ConnectedSystems Nov 6, 2024
5e7408f
Changes to improve identify_edge_aligned_sites()
ConnectedSystems Nov 6, 2024
504a0a6
lookup tables already include `lons` and `lats` columns
ConnectedSystems Nov 6, 2024
a48dfff
Change extraction method for efficiency
ConnectedSystems Nov 6, 2024
ac110d2
Fix typo in docstring
ConnectedSystems Nov 6, 2024
0d63007
Specify return type
ConnectedSystems Nov 6, 2024
d0bcf51
Switch to a more efficient dim extraction approach
ConnectedSystems Nov 6, 2024
b93e816
Update references to `lons` and `lats` in readme and docs
ConnectedSystems Nov 6, 2024
46e6eed
Add a tiff writing method
ConnectedSystems Nov 6, 2024
e0d7c39
Simplify closest reef outline identification
ConnectedSystems Nov 6, 2024
dcc61bc
Update use of modified function
ConnectedSystems Nov 6, 2024
08edb7e
More efficient site filtering process
ConnectedSystems Nov 6, 2024
61383c4
Switch to writing a tiff instead of COG
ConnectedSystems Nov 6, 2024
c55d572
Committing unfinished code
ConnectedSystems Nov 6, 2024
3a45fe8
Updated project manifest
ConnectedSystems Nov 6, 2024
ed96ef4
Fix errors caused by merge/rebase and update var names for readability
ConnectedSystems Nov 7, 2024
9b0f927
Indicate time
ConnectedSystems Nov 7, 2024
3aafc4b
Fix var reference in docstring
ConnectedSystems Nov 7, 2024
2681105
Specify use of Base method and loosen msg check
ConnectedSystems Nov 7, 2024
9b45820
Expand docstrings and add additional geom rotation helper
ConnectedSystems Nov 7, 2024
2687dbf
Change rotation assessment approach
ConnectedSystems Nov 7, 2024
19bf133
Assess sites with static (fixed-size) arrays and multi-threading
ConnectedSystems Nov 11, 2024
2cc7a44
Use kd-trees to spatially cluster sites to reduce analysis workload
ConnectedSystems Nov 11, 2024
7a9f277
Update project spec
ConnectedSystems Nov 11, 2024
c1d2707
Auto-format for style check
ConnectedSystems Nov 11, 2024
ddaf69f
Constrain search with KD-trees and trade memory for performance
ConnectedSystems Nov 23, 2024
062ebad
Remove unused config arg
ConnectedSystems Nov 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 45 additions & 43 deletions Manifest-v1.11.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

julia_version = "1.11.1"
manifest_format = "2.0"
project_hash = "ec28c03ea5b6508584814371878b3d5173103b6b"
project_hash = "e5591687f4abad3ea1116f7e71704b3987e25a66"

[[deps.AbstractFFTs]]
deps = ["LinearAlgebra"]
Expand Down Expand Up @@ -47,9 +47,9 @@ version = "0.1.38"

[[deps.Adapt]]
deps = ["LinearAlgebra", "Requires"]
git-tree-sha1 = "d80af0733c99ea80575f612813fa6aa71022d33a"
git-tree-sha1 = "50c3c56a52972d78e8be9fd135bfb91c9574c140"
uuid = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
version = "4.1.0"
version = "4.1.1"
weakdeps = ["StaticArrays"]

[deps.Adapt.extensions]
Expand Down Expand Up @@ -125,9 +125,9 @@ version = "7.16.0"

[[deps.ArrayLayouts]]
deps = ["FillArrays", "LinearAlgebra"]
git-tree-sha1 = "0dd7edaff278e346eb0ca07a7e75c9438408a3ce"
git-tree-sha1 = "492681bc44fac86804706ddb37da10880a2bd528"
uuid = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
version = "1.10.3"
version = "1.10.4"
weakdeps = ["SparseArrays"]

[deps.ArrayLayouts.extensions]
Expand Down Expand Up @@ -474,15 +474,17 @@ version = "1.15.1"

[[deps.DimensionalData]]
deps = ["Adapt", "ArrayInterface", "ConstructionBase", "DataAPI", "Dates", "Extents", "Interfaces", "IntervalSets", "InvertedIndices", "IteratorInterfaceExtensions", "LinearAlgebra", "PrecompileTools", "Random", "RecipesBase", "SparseArrays", "Statistics", "TableTraits", "Tables"]
git-tree-sha1 = "cd2e8e778c53f6ac328c648964c225f7da959217"
git-tree-sha1 = "3b4ddf974521dad46365ce7bb5a34e3e38c23084"
uuid = "0703355e-b756-11e9-17c0-8b28908087d0"
version = "0.28.3"
version = "0.28.5"

[deps.DimensionalData.extensions]
DimensionalDataAlgebraOfGraphicsExt = "AlgebraOfGraphics"
DimensionalDataCategoricalArraysExt = "CategoricalArrays"
DimensionalDataMakie = "Makie"

[deps.DimensionalData.weakdeps]
AlgebraOfGraphics = "cbdf2221-f076-402e-a563-3d30da359d67"
CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"

Expand All @@ -494,15 +496,15 @@ version = "0.1.10"

[[deps.DiskArrays]]
deps = ["LRUCache", "OffsetArrays"]
git-tree-sha1 = "dea23e3d787c25fbf5f879c4501da828bc729472"
git-tree-sha1 = "e0e89a60637a62d13aa2107f0acd169b9b9b77e7"
uuid = "3c3547ce-8d99-4f5e-a174-61eb10b00ae3"
version = "0.4.5"
version = "0.4.6"

[[deps.Distances]]
deps = ["LinearAlgebra", "Statistics", "StatsAPI"]
git-tree-sha1 = "66c4c81f259586e8f002eacebc177e1fb06363b0"
git-tree-sha1 = "c7e3a542b999843086e2f29dac96a618c105be1d"
uuid = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7"
version = "0.10.11"
version = "0.10.12"
weakdeps = ["ChainRulesCore", "SparseArrays"]

[deps.Distances.extensions]
Expand All @@ -516,9 +518,9 @@ version = "1.11.0"

[[deps.Distributions]]
deps = ["AliasTables", "FillArrays", "LinearAlgebra", "PDMats", "Printf", "QuadGK", "Random", "SpecialFunctions", "Statistics", "StatsAPI", "StatsBase", "StatsFuns"]
git-tree-sha1 = "d7477ecdafb813ddee2ae727afa94e9dcb5f3fb0"
git-tree-sha1 = "3101c32aab536e7a27b1763c0797dba151b899ad"
uuid = "31c24e10-a181-5473-b8eb-7969acd0382f"
version = "0.25.112"
version = "0.25.113"

[deps.Distributions.extensions]
DistributionsChainRulesCoreExt = "ChainRulesCore"
Expand Down Expand Up @@ -680,9 +682,9 @@ version = "0.4.3"

[[deps.ForwardDiff]]
deps = ["CommonSubexpressions", "DiffResults", "DiffRules", "LinearAlgebra", "LogExpFunctions", "NaNMath", "Preferences", "Printf", "Random", "SpecialFunctions"]
git-tree-sha1 = "cf0fe81336da9fb90944683b8c41984b08793dad"
git-tree-sha1 = "a9ce73d3c827adab2d70bf168aaece8cce196898"
uuid = "f6369f11-7733-5829-9624-2563aa707210"
version = "0.10.36"
version = "0.10.37"
weakdeps = ["StaticArrays"]

[deps.ForwardDiff.extensions]
Expand Down Expand Up @@ -729,9 +731,9 @@ version = "0.4.2"

[[deps.GeoInterface]]
deps = ["Extents", "GeoFormatTypes"]
git-tree-sha1 = "2f6fce56cdb8373637a6614e14a5768a88450de2"
git-tree-sha1 = "826b4fd69438d9ce4d2b19de6bc2f970f45f0f88"
uuid = "cf35fbd7-0cd7-5166-be24-54bfbe79505f"
version = "1.3.7"
version = "1.3.8"

[[deps.GeoInterfaceMakie]]
deps = ["GeoInterface", "GeometryBasics", "MakieCore"]
Expand Down Expand Up @@ -834,9 +836,9 @@ version = "1.14.3+3"

[[deps.HTTP]]
deps = ["Base64", "CodecZlib", "ConcurrentUtilities", "Dates", "ExceptionUnwrapping", "Logging", "LoggingExtras", "MbedTLS", "NetworkOptions", "OpenSSL", "Random", "SimpleBufferStream", "Sockets", "URIs", "UUIDs"]
git-tree-sha1 = "d1d712be3164d61d1fb98e7ce9bcbc6cc06b45ed"
git-tree-sha1 = "bc3f416a965ae61968c20d0ad867556367f2817d"
uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3"
version = "1.10.8"
version = "1.10.9"

[[deps.HistogramThresholding]]
deps = ["ImageBase", "LinearAlgebra", "MappedArrays"]
Expand Down Expand Up @@ -1051,9 +1053,9 @@ version = "0.15.1"

[[deps.IntervalArithmetic]]
deps = ["CRlibm_jll", "LinearAlgebra", "MacroTools", "RoundingEmulator"]
git-tree-sha1 = "c59c57c36683aa17c563be6edaac888163f35285"
git-tree-sha1 = "24c095b1ec7ee58b936985d31d5df92f9b9cfebb"
uuid = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253"
version = "0.22.18"
version = "0.22.19"
weakdeps = ["DiffRules", "ForwardDiff", "IntervalSets", "RecipesBase"]

[deps.IntervalArithmetic.extensions]
Expand Down Expand Up @@ -1264,9 +1266,9 @@ version = "1.11.0"

[[deps.Libgcrypt_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Libgpg_error_jll"]
git-tree-sha1 = "9fd170c4bbfd8b935fdc5f8b7aa33532c991a673"
git-tree-sha1 = "8be878062e0ffa2c3f67bb58a595375eda5de80b"
uuid = "d4300ac3-e22c-5743-9152-c294e39db1e4"
version = "1.8.11+0"
version = "1.11.0+0"

[[deps.Libglvnd_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg", "Xorg_libX11_jll", "Xorg_libXext_jll"]
Expand All @@ -1276,15 +1278,15 @@ version = "1.6.0+0"

[[deps.Libgpg_error_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
git-tree-sha1 = "fbb1f2bef882392312feb1ede3615ddc1e9b99ed"
git-tree-sha1 = "c6ce1e19f3aec9b59186bdf06cdf3c4fc5f5f3e6"
uuid = "7add5ba3-2f88-524e-9cd5-f83b8a55f7b8"
version = "1.49.0+0"
version = "1.50.0+0"

[[deps.Libiconv_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
git-tree-sha1 = "f9557a255370125b405568f9767d6d195822a175"
git-tree-sha1 = "61dfdba58e585066d8bce214c5a51eaa0539f269"
uuid = "94ce4f54-9a6c-5748-9c1c-f9c7231a4531"
version = "1.17.0+0"
version = "1.17.0+1"

[[deps.Libtiff_jll]]
deps = ["Artifacts", "JLLWrappers", "JpegTurbo_jll", "LERC_jll", "Libdl", "XZ_jll", "Zlib_jll", "Zstd_jll"]
Expand Down Expand Up @@ -1337,9 +1339,9 @@ version = "1.11.0"

[[deps.LoggingExtras]]
deps = ["Dates", "Logging"]
git-tree-sha1 = "c1dd6d7978c12545b4179fb6153b9250c96b0075"
git-tree-sha1 = "f02b56007b064fbfddb4c9cd60161b6dd0f40df3"
uuid = "e6f89c97-d47a-5376-807f-9c37f3926c36"
version = "1.0.3"
version = "1.1.0"

[[deps.LoopVectorization]]
deps = ["ArrayInterface", "CPUSummary", "CloseOpenIntervals", "DocStringExtensions", "HostCPUFeatures", "IfElse", "LayoutPointers", "LinearAlgebra", "OffsetArrays", "PolyesterWeave", "PrecompileTools", "SIMDTypes", "SLEEFPirates", "Static", "StaticArrayInterface", "ThreadingUtilities", "UnPack", "VectorizationBase"]
Expand All @@ -1359,9 +1361,9 @@ uuid = "5ced341a-0733-55b8-9ab6-a4889d929147"
version = "1.10.0+1"

[[deps.MIMEs]]
git-tree-sha1 = "65f28ad4b594aebe22157d6fac869786a255b7eb"
git-tree-sha1 = "1833212fd6f580c20d4291da9c1b4e8a655b128e"
uuid = "6c6e2e6c-3030-632d-7369-2d6c69616d65"
version = "0.1.4"
version = "1.0.0"

[[deps.MKL_jll]]
deps = ["Artifacts", "IntelOpenMP_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "oneTBB_jll"]
Expand Down Expand Up @@ -1565,9 +1567,9 @@ version = "0.3.27+1"

[[deps.OpenEXR]]
deps = ["Colors", "FileIO", "OpenEXR_jll"]
git-tree-sha1 = "327f53360fdb54df7ecd01e96ef1983536d1e633"
git-tree-sha1 = "97db9e07fe2091882c765380ef58ec553074e9c7"
uuid = "52e1d378-f018-4a11-a4be-720524705ac7"
version = "0.3.2"
version = "0.3.3"

[[deps.OpenEXR_jll]]
deps = ["Artifacts", "Imath_jll", "JLLWrappers", "Libdl", "Zlib_jll"]
Expand Down Expand Up @@ -1980,9 +1982,9 @@ version = "1.2.1"

[[deps.SentinelArrays]]
deps = ["Dates", "Random"]
git-tree-sha1 = "ff11acffdb082493657550959d4feb4b6149e73a"
git-tree-sha1 = "d0553ce4031a081cc42387a9b9c8441b7d99f32d"
uuid = "91c51154-3ec4-41a3-a24f-3f23e20d615c"
version = "1.4.5"
version = "1.4.7"

[[deps.Serialization]]
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
Expand Down Expand Up @@ -2308,9 +2310,9 @@ version = "1.0.6"

[[deps.VectorizationBase]]
deps = ["ArrayInterface", "CPUSummary", "HostCPUFeatures", "IfElse", "LayoutPointers", "Libdl", "LinearAlgebra", "SIMDTypes", "Static", "StaticArrayInterface"]
git-tree-sha1 = "e7f5b81c65eb858bed630fe006837b935518aca5"
git-tree-sha1 = "4ab62a49f1d8d9548a1c8d1a75e5f55cf196f64e"
uuid = "3d5dd08c-fd9d-11e8-17fa-ed2836048c2f"
version = "0.21.70"
version = "0.21.71"

[[deps.WeakRefStrings]]
deps = ["DataAPI", "InlineStrings", "Parsers"]
Expand Down Expand Up @@ -2349,9 +2351,9 @@ version = "1.6.1"

[[deps.XML2_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Libiconv_jll", "Zlib_jll"]
git-tree-sha1 = "1165b0443d0eca63ac1e32b8c0eb69ed2f4f8127"
git-tree-sha1 = "6a451c6f33a176150f315726eba8b92fbfdb9ae7"
uuid = "02c8fc9c-b97f-50b9-bbe4-9be30ff0a78a"
version = "2.13.3+0"
version = "2.13.4+0"

[[deps.XSLT_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Libgcrypt_jll", "Libgpg_error_jll", "Libiconv_jll", "XML2_jll", "Zlib_jll"]
Expand All @@ -2361,9 +2363,9 @@ version = "1.1.41+0"

[[deps.XZ_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
git-tree-sha1 = "ac88fb95ae6447c8dda6a5503f3bafd496ae8632"
git-tree-sha1 = "15e637a697345f6743674f1322beefbc5dcd5cfc"
uuid = "ffd25f8a-64ca-5728-b0f7-c24cf3aae800"
version = "5.4.6+0"
version = "5.6.3+0"

[[deps.Xorg_libX11_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Xorg_libxcb_jll", "Xorg_xtrans_jll"]
Expand Down Expand Up @@ -2433,9 +2435,9 @@ version = "0.7.3"

[[deps.YAXArrays]]
deps = ["CFTime", "DataStructures", "Dates", "DimensionalData", "DiskArrayTools", "DiskArrays", "Distributed", "DocStringExtensions", "Glob", "Interpolations", "IntervalSets", "IterTools", "Markdown", "OffsetArrays", "OnlineStats", "Optim", "OrderedCollections", "ParallelUtilities", "ProgressMeter", "Reexport", "Requires", "Statistics", "StatsBase", "Tables", "WeightedOnlineStats", "YAXArrayBase"]
git-tree-sha1 = "09cd01df4817c4d5f6eda845c4d75cc2855cf0b3"
git-tree-sha1 = "02d9149f67b26256ffa1e1c3915d474fae57099e"
uuid = "c21b50f5-aa40-41ea-b809-c0f5e47bfa5c"
version = "0.5.11"
version = "0.5.12"

[[deps.Zlib_jll]]
deps = ["Libdl"]
Expand Down
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
MKL_jll = "856f044c-d86e-5d09-b602-aeab76dc8ba7"
Memoization = "6fafb56a-5788-4b4e-91ca-c0cea6611c73"
Mmap = "a63ad114-7e13-5084-954f-fe012c677804"
NearestNeighbors = "b8a86587-4115-5ab1-83bc-aa920d37bbce"
NetCDF = "30363a11-5582-574a-97bb-aa9a979735b9"
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
Oxygen = "df9a0d86-3283-4920-82dc-4555fc0d1d8b"
Expand All @@ -50,3 +51,4 @@ YAXArrays = "c21b50f5-aa40-41ea-b809-c0f5e47bfa5c"
[compat]
DiskArrays = "=0.3.23, ^0.4.5"
MKL_jll = "2024.2.0"
NearestNeighbors = "0.4.20"
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ The following processing is required before use:
### Parquet assessment additional setup

- A parquet GeoDataFrame must be loaded and filtered for unsuitable pixels based on user criteria thresholds using a Dict and `within_thresholds()`.
- `lon` and `lat` columns (FLoat64) must be added to the GeoDataFrame.
- E.g. `valid_pixels.lon = first.(GI.coordinates.(valid_pixels.geometry))`
- `lons` and `lats` columns (FLoat64) must be added to the GeoDataFrame.
- E.g. `valid_pixels.lons = first.(GI.coordinates.(valid_pixels.geometry))`
The column used for masking should be the same as the column specified as geometry_col in
`identify_edge_aligned_sites` (default = `:geometry`).

Expand Down
4 changes: 2 additions & 2 deletions docs/src/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ The following processing is required before use:
### Parquet assessment additional setup

- A parquet GeoDataFrame must be loaded and filtered for unsuitable pixels based on user criteria thresholds using a Dict and `within_thresholds()`.
- `lon` and `lat` columns (FLoat64) must be added to the GeoDataFrame.
- E.g. `valid_pixels.lon = first.(GI.coordinates.(valid_pixels.geometry))`
- `lons` and `lats` columns (FLoat64) must be added to the GeoDataFrame.
- E.g. `valid_pixels.lons = first.(GI.coordinates.(valid_pixels.geometry))`
The column used for masking should be the same as the column specified as geometry_col in
`identify_edge_aligned_sites` (default = `:geometry`).
8 changes: 8 additions & 0 deletions src/ReefGuideAPI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ function initialize_regional_data_cache(reef_data_path::String, reg_cache_fn::St
flat_table[!, :lats] .= last.(coords)

rst_stack = RasterStack(data_paths; name=data_names, lazy=true)

# Constrain to just the areas with valid data (with a 0.05 degree buffer)
# min_lon = min(minimum(slope_table.lons), minimum(flat_table.lons)) - 0.05
# max_lon = max(maximum(slope_table.lons), maximum(flat_table.lons)) + 0.05
# min_lat = min(minimum(slope_table.lats), minimum(flat_table.lats)) - 0.05
# max_lat = max(maximum(slope_table.lats), maximum(flat_table.lats)) + 0.05
# rst_stack = view(rst_stack, X(min_lon .. max_lon), Y(min_lat .. max_lat))

regional_assessment_data[reg] = RegionalCriteria(
rst_stack,
slope_table,
Expand Down
25 changes: 21 additions & 4 deletions src/criteria_assessment/criteria.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,19 @@ function _write_cog(file_path::String, data::Raster, config::Dict)::Nothing
return nothing
end

function _write_tiff(file_path::String, data::Raster, config::Dict)::Nothing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

config not used?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I think because we went from writing out a COG (which used the defined options) to writing out a geotiff...

I'll fix it up, thanks for catching.

Rasters.write(
file_path,
data;
ext=".tiff",
source="gdal",
driver="gtiff",
force=true
)

return nothing
end

"""
criteria_middleware(handle)

Expand Down Expand Up @@ -161,18 +174,19 @@ function setup_region_routes(config, auth)
)
# somewhere:8000/suitability/assess/region-name/reeftype?criteria_names=Depth,Slope&lb=-9.0,0.0&ub=-2.0,40
# 127.0.0.1:8000/suitability/assess/Cairns-Cooktown/slopes?Depth=-4.0:-2.0&Slope=0.0:40.0&Rugosity=0.0:6.0
# 127.0.0.1:8000/suitability/assess/Cairns-Cooktown/slopes?Depth=-4.0:-2.0&Slope=0.0:40.0&Rugosity=0.0:6.0&SuitabilityThreshold=95

qp = queryparams(req)
assessed_fn = cache_filename(qp, config, "$(reg)_suitable", "tiff")
if isfile(assessed_fn)
return file(assessed_fn; headers=COG_HEADERS)
end

@debug "$(now()) : Assessing region $(reg)"
assessed = assess_region(reg_assess_data, reg, qp, rtype)

@debug "$(now()) : Running on thread $(threadid())"
@debug "Writing to $(assessed_fn)"
_write_cog(assessed_fn, assessed, config)
@debug "$(now()) : Writing to $(assessed_fn)"
_write_tiff(assessed_fn, assessed, config)

return file(assessed_fn; headers=COG_HEADERS)
end
Expand All @@ -195,7 +209,7 @@ function setup_region_routes(config, auth)
assessed = Raster(assessed_fn)
else
assessed = assess_region(reg_assess_data, reg, qp, rtype)
_write_cog(assessed_fn, assessed, config)
_write_tiff(assessed_fn, assessed, config)
end

# Extract criteria and assessment
Expand All @@ -211,6 +225,9 @@ function setup_region_routes(config, auth)
)
)

# Specifically clear from memory to invoke garbage collector
assessed = nothing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't be necessary, assessed is local to this function. Did you actually see this make a difference?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, yes it does make a difference.

Triggers the GC to run a bit earlier, making space for the next big dataset. Otherwise you're more likely to hit an out-of-memory error.


output_geojson(suitable_sites_fn, best_sites)
return file(suitable_sites_fn)
end
Expand Down
Loading
Loading