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

Band references implementation #63

Merged
merged 136 commits into from
Aug 31, 2019
Merged

Conversation

landam
Copy link
Member

@landam landam commented Jul 26, 2019

This PR implements basic functionality related to image collections (https://developers.google.com/earth-engine/tutorial_api_04).

It's dedicated for testing, various improvements are still planned.

Development has been supported mundialis GmbH & Co.KG

How to test

1. Create GRASS location, download sample data

./bin.x86_64-pc-linux-gnu/grass77 -c EPSG:32633 /tmp/image-collection-test
> g.extension ext=i.sentinel
> i.sentinel.download settings=sentinel.txt uuid=a12d7d6d-0c41-4f5e-8789-7e9cff3529df output=/tmp
> i.sentinel.import input=/tmp

2. Create STRDS

> t.create test title=test description=test

3. Register maps from input file

3.a Create input file

(note that similar functionality is planned to be implemented in i.sentinel.import)

Run PyGRASS script in order to create input file for t.register:

#!/usr/bin/env python

from grass.pygrass.raster import RasterRow
from grass.pygrass.gis import Mapset

from datetime import datetime

def list_rasters():
    m = Mapset()
    return m.glist('raster')

def do_list():
    for name in list_rasters():
        with RasterRow(name) as rast:
            band = rast.name.split('_', -1)[-1].lstrip('B').lstrip('0')
            band_ref = "S2_{}".format(band)

            date = datetime.strptime(
                rast.name.split('_')[1],
                '%Y%m%dT%H%M%S'
            )
            print ('{}|{}|{}'.format(name, date, band_ref))

if __name__ == "__main__":
    do_list()

Expected result:

T33UYP_20190331T094039_B01|2019-03-31 09:40:39|S2_1
T33UYP_20190331T094039_B10|2019-03-31 09:40:39|S2_10
T33UYP_20190331T094039_B02|2019-03-31 09:40:39|S2_2
T33UYP_20190331T094039_B05|2019-03-31 09:40:39|S2_5
T33UYP_20190331T094039_B11|2019-03-31 09:40:39|S2_11
T33UYP_20190331T094039_B08|2019-03-31 09:40:39|S2_8
T33UYP_20190331T094039_B12|2019-03-31 09:40:39|S2_12
T33UYP_20190331T094039_B8A|2019-03-31 09:40:39|S2_8A
T33UYP_20190331T094039_B06|2019-03-31 09:40:39|S2_6
T33UYP_20190331T094039_B04|2019-03-31 09:40:39|S2_4
T33UYP_20190331T094039_B03|2019-03-31 09:40:39|S2_3
T33UYP_20190331T094039_B09|2019-03-31 09:40:39|S2_9

Redirect output into file:

python grass_image_collections_file.py > /tmp/t_register.txt

3.b Register sample raster data into STDS from input file

t.register input=test file=/tmp/t_register.txt

4. Quick band reference filtering tests

Commands like:

> t.rast.list test
> g.region rast=T33UYP_20190331T094039_B01
> t.rast.univar test

should process all raster maps registered in space time dataset.

Now let's try to set up band reference filter (first band only):

> t.rast.list test:S2_1
name|mapset|start_time|end_time
T33UYP_20190331T094039_B01|PERMANENT|2019-03-31 09:40:39|None
> t.rast.univar test:S2_1
id|start|end|mean|min|max|mean_of_abs|stddev|variance|coeff_var|sum|null_cells|cells|non_null_cells
T33UYP_20190331T094039_B01@PERMANENT|2019-03-31 09:40:39|None|784.356813580579|0|4309|784.356813580579|677.557914588275|459084.727621212|86.383888411096|2626732533|0|3348900|3348900

5. Metadata

Raster type:

t.info T33UYP_20190331T094039_B01 type=raster
...
 +-------------------- Metadata information ----------------------------------+
 | Band reference:............. S2B_1
...
t.info T33UYP_20190331T094039_B01 type=raster -g
...
band_reference=S2_1
...

STRDS type:

t.info test
...
+-------------------- Metadata information ----------------------------------+
...
 | Number of registered bands:. 13
...
t.info test -g
...
number_of_bands=13
...

Known limits

  • band reference can be assigned only to 2D raster map (3D raster maps and vector maps are currently not supported)
  • raster maps with band reference can be registered only in STRDS created in TGIS DB 3 (so with GRASS including this PR)
  • r.info does not print band reference info
  • only very limited band references included (Sentinel2, Landsat7, Landsat8)
  • tests for temporal lib are missing

landam and others added 30 commits May 25, 2019 15:52
This fix copies the output file name to the correct variable, as in GRASS 6
This PR adds a sponsorship button to the repo, pointing to our moneypool.
G_find_raster -> G_find_raster2 (see OSGeo#3854)
use Vect_subst_var() where needed (fix for default connection containing "$MAP")
fix for default connection containing "$MAP"

do not secretly convert user-defined column names to lower case
`unicode` is no longer a valid keyword for `gettext.install()` in Python 3
but we need it on Python 2.

This is in continuation of https://trac.osgeo.org/grass/changeset/74307
which was a fix for: https://trac.osgeo.org/grass/ticket/3790

Fixes https://trac.osgeo.org/grass/ticket/3838
landam and others added 3 commits August 31, 2019 13:28
@landam landam merged commit a83af32 into OSGeo:master Aug 31, 2019
@landam landam deleted the image-collections branch August 31, 2019 14:57
@neteler neteler changed the title WIP Band references implementation Band references implementation Sep 2, 2019
This was referenced Sep 14, 2019
petrasovaa pushed a commit to petrasovaa/grass that referenced this pull request Dec 3, 2019
Implements image collection support into GRASS GIS
@neteler neteler mentioned this pull request Jan 15, 2020
@landam landam mentioned this pull request Jan 28, 2020
2 tasks
neteler added a commit that referenced this pull request Mar 16, 2021
* TGRASS: remove bogus band references error msg

In `t.register` it must be possible to provide custom band names such as "mask", "ndvi", "prec", "temperature", etc. as per band reference definition.
Hence, the fatal error message `Error when registering strds: Unable to read band reference file` is incorrect.

This PR removes this incorrect error message, originating from #63.
marisn pushed a commit to marisn/grass that referenced this pull request Mar 22, 2021
* TGRASS: remove bogus band references error msg

In `t.register` it must be possible to provide custom band names such as "mask", "ndvi", "prec", "temperature", etc. as per band reference definition.
Hence, the fatal error message `Error when registering strds: Unable to read band reference file` is incorrect.

This PR removes this incorrect error message, originating from OSGeo#63.
@neteler neteler added this to the 7.8.0 milestone Dec 9, 2021
ninsbl pushed a commit to ninsbl/grass that referenced this pull request Oct 26, 2022
* TGRASS: remove bogus band references error msg

In `t.register` it must be possible to provide custom band names such as "mask", "ndvi", "prec", "temperature", etc. as per band reference definition.
Hence, the fatal error message `Error when registering strds: Unable to read band reference file` is incorrect.

This PR removes this incorrect error message, originating from OSGeo#63.
ninsbl pushed a commit to ninsbl/grass that referenced this pull request Feb 17, 2023
* TGRASS: remove bogus band references error msg

In `t.register` it must be possible to provide custom band names such as "mask", "ndvi", "prec", "temperature", etc. as per band reference definition.
Hence, the fatal error message `Error when registering strds: Unable to read band reference file` is incorrect.

This PR removes this incorrect error message, originating from OSGeo#63.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.