Skip to content

Add force-tile-extent module #8635

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .github/skip_nf_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"modules/nf-core/fcs/fcsadaptor",
"modules/nf-core/fcs/fcsgx",
"modules/nf-core/force/cube",
"modules/nf-core/force/tileextent",
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does this need to be added to skip_nf_test.json? It seems like you have nf-tests setup

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is within the conda scope. The tool in this module is not available on conda. Thus, we skip the tests with the conda profile.

"modules/nf-core/ganon/buildcustom",
"modules/nf-core/ganon/classify",
"modules/nf-core/ganon/report",
Expand Down
1 change: 1 addition & 0 deletions modules/nf-core/force/tileextent/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM quay.io/nfcore/force:3.8.01
43 changes: 43 additions & 0 deletions modules/nf-core/force/tileextent/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
process FORCE_TILEEXTENT {
tag "${aoi.simpleName}"
label 'process_single'

container "nf-core/force:3.8.01"

input:
path aoi
path "tmp/datacube-definition.prj"
path shapefile_dbf
path shapefile_prj
path shapefile_shx

output:
path "tile_allow.txt", emit: tile_allow
path "versions.yml" , emit: versions

when:
task.ext.when == null || task.ext.when

script:
def args = task.ext.args ?: ''
"""
force-tile-extent -d tmp/ -a tile_allow.txt $aoi
rm -r tmp

cat <<-END_VERSIONS > versions.yml
"${task.process}":
force: \$(force-tile-extent -v)
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
"""
touch tile_allow.txt

cat <<-END_VERSIONS > versions.yml
"${task.process}":
force: \$(force-tile-extent -v)
END_VERSIONS
"""
}
61 changes: 61 additions & 0 deletions modules/nf-core/force/tileextent/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json
name: "force_tileextent"
description: |
Compute valid tiles for a given datacube definition and area of interest.
This list can be used by downstream analysis tasks to limit processing to the area of interest when satellite data covers a larger region.
keywords:
- satellite data
- extent
- tile
- datacube
tools:
- "force":
description: |
A all-in-one tool for processing satellite data.
Specialized on medium resolution data such as Landsat or Sentinel imagery.
homepage: "https://davidfrantz.github.io/code/force/"
documentation: "https://force-eo.readthedocs.io/en/latest/index.html"
tool_dev_url: "https://github.com/davidfrantz/force"
doi: "10.3390/rs11091124"
licence: ["GPL-3.0"]
identifier: ""

input:
- - aoi:
type: file
description: Vector file (either shapefile geometry or geopackage) defining the area of interest.
pattern: "*.{shp,gpkg}"
- - tmp/datacube-definition.prj:
type: file
description: Datacube file in FORCE format defining the properties of the targeted datacube.
pattern: "*.{prj}"
- - shapefile_dbf:
type: file
description: Optional attribute table for shapefiles. Required if aoi is a shapefile.
pattern: "*.{dbf}"
- - shapefile_prj:
type: file
description: Optional projection for shapefiles. Required if aoi is a shapefile.
pattern: "*.{prj}"
- - shapefile_shx:
type: file
description: Optional shape index for shapefiles. Required if aoi is a shapefile.
pattern: "*.{shx}"

output:
- tile_allow:
- "tile_allow.txt":
type: file
description: List of allowed datacube tiles. Each line contains an tile identifier.
pattern: "tile_allow.txt"
- versions:
- "versions.yml":
type: file
description: File containing software versions
pattern: "versions.yml"

authors:
- "@Felix-Kummer"
maintainers:
- "@Felix-Kummer"
85 changes: 85 additions & 0 deletions modules/nf-core/force/tileextent/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
nextflow_process {

name "Test Process FORCE_TILEEXTENT"
script "../main.nf"
process "FORCE_TILEEXTENT"

tag "modules"
tag "modules_nfcore"
tag "force"
tag "force/tileextent"

test("force-tile-extent - gpkg") {

when {
process {
"""
input[0] = file(params.modules_testdata_base_path + "earth_sciences/vector/gpkg/crete.gpkg")
input[1] = file(params.modules_testdata_base_path + "earth_sciences/datacubes/datacube-definition.prj")
input[2] = []
input[3] = []
input[4] = []
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}

test("force-tile-extent - shp") {

config "./nextflow.shp.config"

when {
process {
"""
input[0] = file(params.modules_testdata_base_path + "/earth_sciences/vector/shp/denmark.shp")
input[1] = file(params.modules_testdata_base_path + "/earth_sciences/datacubes/datacube-definition.prj")
input[2] = file(params.modules_testdata_base_path + "/earth_sciences/vector/shp/denmark.dbf")
input[3] = file(params.modules_testdata_base_path + "/earth_sciences/vector/shp/denmark.prj")
input[4] = file(params.modules_testdata_base_path + "/earth_sciences/vector/shp/denmark.shx")
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}

test("force-tile-extent - gpkg - stub") {

options "-stub"

when {
process {
"""
input[0] = file(params.modules_testdata_base_path + "earth_sciences/vector/gpkg/crete.gpkg")
input[1] = file(params.modules_testdata_base_path + "earth_sciences/datacubes/datacube-definition.prj")
input[2] = []
input[3] = []
input[4] = []
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}

}
71 changes: 71 additions & 0 deletions modules/nf-core/force/tileextent/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"force-tile-extent - gpkg": {
"content": [
{
"0": [
"tile_allow.txt:md5,3428a70fcfcfb2ce50e5c65e369fbf75"
],
"1": [
"versions.yml:md5,6b3d57b4f9567d44e502036809c80e2f"
],
"tile_allow": [
"tile_allow.txt:md5,3428a70fcfcfb2ce50e5c65e369fbf75"
],
"versions": [
"versions.yml:md5,6b3d57b4f9567d44e502036809c80e2f"
]
}
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "25.04.2"
},
"timestamp": "2025-06-13T15:16:51.909565499"
},
"force-tile-extent - gpkg - stub": {
"content": [
{
"0": [
"tile_allow.txt:md5,d41d8cd98f00b204e9800998ecf8427e"
],
"1": [
"versions.yml:md5,6b3d57b4f9567d44e502036809c80e2f"
],
"tile_allow": [
"tile_allow.txt:md5,d41d8cd98f00b204e9800998ecf8427e"
],
"versions": [
"versions.yml:md5,6b3d57b4f9567d44e502036809c80e2f"
]
}
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "25.04.2"
},
"timestamp": "2025-06-13T15:17:23.741824063"
},
"force-tile-extent - shp": {
"content": [
{
"0": [
"tile_allow.txt:md5,f194cf6f608930e6dc31f59453f7ae02"
],
"1": [
"versions.yml:md5,6b3d57b4f9567d44e502036809c80e2f"
],
"tile_allow": [
"tile_allow.txt:md5,f194cf6f608930e6dc31f59453f7ae02"
],
"versions": [
"versions.yml:md5,6b3d57b4f9567d44e502036809c80e2f"
]
}
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "25.04.2"
},
"timestamp": "2025-06-13T15:17:15.400884563"
}
}
4 changes: 4 additions & 0 deletions modules/nf-core/force/tileextent/tests/nextflow.shp.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
process {
// this is required because the module needs all shapefile files in the same directory
stageInMode = 'copy'
}
Loading