[GRASS-user] Example project for a GRASS GIS module on GitHub

2020-01-29 Thread Vaclav Petras
Dear users and contributors,

I've created an example project (repository) on GitHub. It is a GRASS GIS
module written in Python which simply adds two raster maps together. It
uses GitHub Actions to build the module and publish its documentation as a
website (using GitHub Pages).

https://github.com/wenzeslaus/r.example.plus

This is based on my earlier work on an example project on GitLab [1] and
includes several improvements and changes:

* There is a test suite included with couple of test functions.
* It uses Black for code formatting (assuming author runs it manually).
* Repository is marked as a template (see the big "Use this template"
button).
* GitHub Actions are used for:
  * compiling the module and running tests,
  * checking code quality with Flake8 and Pylint, and
  * checking code style with Black.
* GitHub Actions are now used for publishing documentation (done by GitLab
CI before).
* Option names now follow GRASS GIS standards more.
* More documentation in the code and on how to use the code.
* Badges are now in the README file (GitLab had those as project
properties).

Otherwise, I hope the project should describe itself and if something is
missing or is not documented enough, please open an issue or a pull request.

Best,
Vaclav

PS: We can discuss on grass-dev if this should go under some organization
and how to improve the "what's next" part [2].

[1] https://lists.osgeo.org/pipermail/grass-dev/2018-November/090438.html
[2] https://github.com/wenzeslaus/r.example.plus#what-is-next
___
grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user

Re: [GRASS-user] error in i.sentinel.mask: nan values in xml file

2020-01-29 Thread Veronica Andreo
Hi Robi,

So I found that i.sentinel.import fails for latlong locations. I moved to
UTM as in the original data and all fine. I reached the cloud masking step,
and I find a different problem now.

Here's the command and an extract of the output:
GRASS 7.9.dev (dengue_cba):~/webgis > i.sentinel.mask -s \
>   blue=$blue \
>   green=$green \
>   red=$red \
>   swir11=$swir11 \
>   nir=$nir \
>   swir12=$swir12 \
>   nir8a=$nir8a \
>   cloud_raster=cloud \
>   shadow_raster=shadow \
>   mtd_file=`find $out_dir -name 'MTD_TL.xml'` \
>   scale_fac=1
WARNING: All subsequent operations will be limited to the current
 computational region
--- Start rescaling bands ---
T21JYM_20200126T134201_B02_10m
 100%
T21JYM_20200126T134201_B03_10m
 100%
T21JYM_20200126T134201_B04_10m
 100%
T21JYM_20200126T134201_B08_10m
 100%
T21JYM_20200126T134201_B8A_20m
 100%
T21JYM_20200126T134201_B11_20m
 100%
T21JYM_20200126T134201_B12_20m
 100%

T21JYM_20200126T134201_B02_10m_double,T21JYM_20200126T134201_B03_10m_double,T21JYM_20200126T134201_B04_10m_double,T21JYM_20200126T134201_B08_10m_double,T21JYM_20200126T134201_B8A_20m_double,T21JYM_20200126T134201_B11_20m_double,T21JYM_20200126T134201_B12_20m_double
--- All bands have been rescaled ---
--- Start computing maximum values of bands ---
T21JYM_20200126T134201_B02_10m_double
T21JYM_20200126T134201_B03_10m_double
T21JYM_20200126T134201_B04_10m_double
T21JYM_20200126T134201_B08_10m_double
T21JYM_20200126T134201_B8A_20m_double
T21JYM_20200126T134201_B11_20m_double
T21JYM_20200126T134201_B12_20m_double
--- Computed maximum value: dict_values([0.9352, 1.168, 1.1056, 1.0704,
0.7023, 0.9381, 1.3597]) ---
--- Statistics have been computed! ---
--- Start clouds detection procedure ---
--- Computing cloud mask... ---
 100%
--- Converting raster cloud mask into vector map ---
Extracting areas...
 100%
Writing areas...
 100%
Building topology for vector map ...
Registering primitives...
Building areas...
 100%
Attaching islands...
 100%
Attaching centroids...
 100%
r.to.vect complete.
--- Cleaning geometries ---
[...]
--- Start removing misclassification from the shadow mask ---
--- Data preparation... ---
WARNING: Values in column  will be overwritten
WARNING: Number of centroids exceeds number of areas: 24 > 22
WARNING: Number of duplicate centroids: 2
WARNING: Values in column  will be overwritten
WARNING: Values in column  will be overwritten
--- Reading mean sun zenith and azimuth from metadata file to compute
clouds shift ---
--- the mean sun Zenith is: 28.732 deg ---
--- the mean sun Azimuth is: 82.028 deg ---
--- Start computing the east and north clouds shift at steps of 100m of
clouds height---
Traceback (most recent call last):
  File "/home/veroandreo/.grass7/addons/scripts/i.sentinel.mask", line 638,
in 
main()
  File "/home/veroandreo/.grass7/addons/scripts/i.sentinel.mask", line 561,
in main
quiet=True, stderr=subprocess.DEVNULL)
  File
"/home/veroandreo/software/grass79-dev/dist.x86_64-pc-linux-gnu/etc/python/grass/script/core.py",
line 499, in run_command
return handle_errors(returncode, result=None, args=args, kwargs=kwargs)
  File
"/home/veroandreo/software/grass79-dev/dist.x86_64-pc-linux-gnu/etc/python/grass/script/core.py",
line 392, in handle_errors
returncode=returncode)
grass.exceptions.CalledModuleError: Module run v.overlay v.overlay --o --q
ainput=addcat_5922 binput=cl_shift_5922 operator=and output=overlay_5922
ended with error
Process ended with non-zero return code 1. See errors in the (error) output.

Where is this error output to inspect?

This is the UUID in case you want to test:
541021f8-63f5-4e9d-ba28-425c4c8451df

Thanks much in advance
Vero

ps: I use grass-dev with python 3.7.4 (because of the ctypes issue)



El mié., 29 ene. 2020 a las 14:53, Veronica Andreo ()
escribió:

> Hi Robi,
>
> My bad, region was wrong... anyway, trying to replicate from the beginning
> I see that i.sentinel.import with -r is importing empty maps. However, the
> jp2 files have data. I can visualize them in QGIS. I'll report in a
> different thread. Once I can figure it out and reach this point again, I'll
> report back to you. Thanks for the clarification!
>
> Cheers
> Vero
>
> El mié., 29 ene. 2020 a las 9:08, roberta fagandini (<
> robifagand...@hotmail.it>) escribió:
>
>> Hi Vero,
>> i.sentinel.mask doesn't retrieve the maximum from the xml file but
>> computes the value from the image using r.univar. The error could be due to
>> the computational region..has the region been set correctly?
>> Can you send the MTD_TL.xml file? I can download the image and make some
>> tests.
>>
>> Roberta
>>
>> --
>> *Da:* grass-user  per conto di
>> Veronica Andreo 
>> *Inviato:* martedì 28 gennaio 2020 19:57
>> *A:* grass-user 
>> *Oggetto:* [GRASS-user] error in i.sentinel.mask: nan values in xml file
>>
>> Hello
>>
>> I try to use i.sentinel.mask but I get the following error:
>>
>> i.sentinel.mask blue=$blue green=$green red=$red 

Re: [GRASS-user] i.sentinel.import imports empty maps

2020-01-29 Thread Markus Neteler
Hi Vero,

On Wed, Jan 29, 2020 at 3:20 PM Veronica Andreo  wrote:
...
> BTW, I noted that grass-addons repo does not have the issues activated. With 
> trac closed for new tickets, I think it is necessary to activate issues in 
> grass-addons too

Sorry for that, I have activated it now.

Please open a ticket at
https://github.com/OSGeo/grass-addons/issues

Best
Markus
___
grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user

Re: [GRASS-user] i.sentinel.import imports empty maps

2020-01-29 Thread Valter Albino
Same issue!
Cumprimentos,
*Valter Albino -* Geógrafo Físico, M.Sc.
Modelação H / Riscos ambientais / OT
www.valteralbino.wixsite.com/hydrodynamics


Veronica Andreo  escreveu no dia quarta, 29/01/2020
à(s) 14:31:

> Suspicion confirmed, this was a map imported with i.sentinel.import in
> latlong location. It forces a resolution of 20 degrees, instead of the
> equivalent of 20m in degrees
>
> GRASS 7.9.dev (latlong_wgs84):~ > r.info T21JYM_20200126T134201_B11_20m
>
>  
> ++
>  | Map:  T21JYM_20200126T134201_B11_20  Date: Wed Jan 29 11:09:18 2020
>|
>  | Mapset:   sentinel2  Login of Creator: vandreo
> |
>  | Location: latlong_wgs84
>|
>  | DataBase: /home/vandreo/grassdata
>|
>  | Title:
> |
>  | Timestamp: 26 Jan 2020 13:49:32.751425
> |
>
>  
> ||
>  |
>|
>  |   Type of Map:  raster   Number of Categories: 0
> |
>  |   Data Type:FCELL
>|
>  |   Rows: 1
>|
>  |   Columns:  1
>|
>  |   Total Cells:  1
>|
>  |Projection: Latitud - Longitud.
> |
>  |N:20SS:40S   Res:20
> |
>  |E:40WW:60W   Res:20
> |
>  |   Range of data:min = NULL  max = NULL
> |
>  |
>|
>  |   Data Description:
>|
>  |generado por r.proj
> |
>  |
>|
>  |   Comments:
>|
>  |r.proj --quiet location="temp_import_location_97485"
> mapset="PERMANE\   |
>  |NT" input="T21JYM_20200126T134201_B11_20m" method="bilinear"
> memory=\   |
>  |500 resolution=20.0
> |
>  |
>|
>
>  
> ++
>
> El mié., 29 ene. 2020 a las 11:20, Veronica Andreo ()
> escribió:
>
>> Hi all,
>>
>> I'm using i.sentinel.import with -r flag to import sentinel scenes into a
>> latlong location. No matter if I use, extent=region or extent=input, I get
>> empty maps imported.
>>
>> Estimated target resolution for input band
>> : 0.00018570053194443554
>> Using given resolution for input band :
>> 20.0
>> Reprojecting ...
>> ERROR: The reprojected raster  is empty
>>
>> Meanwhile a normal r.import with input and output, imports the map
>> properly. Is it possible that i.sentinel.import tries to set a 20
>> resolution also in a lat long location???That would be degrees then, and
>> hence the empty maps...
>>
>> BTW, I noted that grass-addons repo does not have the issues activated.
>> With trac closed for new tickets, I think it is necessary to activate
>> issues in grass-addons too
>>
>> Thanks much in advance
>>
>> Vero
>>
> ___
> grass-user mailing list
> grass-user@lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/grass-user
___
grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user

Re: [GRASS-user] i.sentinel.import imports empty maps

2020-01-29 Thread Veronica Andreo
Suspicion confirmed, this was a map imported with i.sentinel.import in
latlong location. It forces a resolution of 20 degrees, instead of the
equivalent of 20m in degrees

GRASS 7.9.dev (latlong_wgs84):~ > r.info T21JYM_20200126T134201_B11_20m
 ++
 | Map:  T21JYM_20200126T134201_B11_20  Date: Wed Jan 29 11:09:18 2020
   |
 | Mapset:   sentinel2  Login of Creator: vandreo
  |
 | Location: latlong_wgs84
   |
 | DataBase: /home/vandreo/grassdata
   |
 | Title:
  |
 | Timestamp: 26 Jan 2020 13:49:32.751425
  |
 ||
 |
   |
 |   Type of Map:  raster   Number of Categories: 0
  |
 |   Data Type:FCELL
   |
 |   Rows: 1
   |
 |   Columns:  1
   |
 |   Total Cells:  1
   |
 |Projection: Latitud - Longitud.
  |
 |N:20SS:40S   Res:20
  |
 |E:40WW:60W   Res:20
  |
 |   Range of data:min = NULL  max = NULL
  |
 |
   |
 |   Data Description:
   |
 |generado por r.proj
  |
 |
   |
 |   Comments:
   |
 |r.proj --quiet location="temp_import_location_97485" mapset="PERMANE\
  |
 |NT" input="T21JYM_20200126T134201_B11_20m" method="bilinear" memory=\
  |
 |500 resolution=20.0
  |
 |
   |
 ++

El mié., 29 ene. 2020 a las 11:20, Veronica Andreo ()
escribió:

> Hi all,
>
> I'm using i.sentinel.import with -r flag to import sentinel scenes into a
> latlong location. No matter if I use, extent=region or extent=input, I get
> empty maps imported.
>
> Estimated target resolution for input band
> : 0.00018570053194443554
> Using given resolution for input band :
> 20.0
> Reprojecting ...
> ERROR: The reprojected raster  is empty
>
> Meanwhile a normal r.import with input and output, imports the map
> properly. Is it possible that i.sentinel.import tries to set a 20
> resolution also in a lat long location???That would be degrees then, and
> hence the empty maps...
>
> BTW, I noted that grass-addons repo does not have the issues activated.
> With trac closed for new tickets, I think it is necessary to activate
> issues in grass-addons too
>
> Thanks much in advance
>
> Vero
>
___
grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user

[GRASS-user] i.sentinel.import imports empty maps

2020-01-29 Thread Veronica Andreo
Hi all,

I'm using i.sentinel.import with -r flag to import sentinel scenes into a
latlong location. No matter if I use, extent=region or extent=input, I get
empty maps imported.

Estimated target resolution for input band
: 0.00018570053194443554
Using given resolution for input band :
20.0
Reprojecting ...
ERROR: The reprojected raster  is empty

Meanwhile a normal r.import with input and output, imports the map
properly. Is it possible that i.sentinel.import tries to set a 20
resolution also in a lat long location???That would be degrees then, and
hence the empty maps...

BTW, I noted that grass-addons repo does not have the issues activated.
With trac closed for new tickets, I think it is necessary to activate
issues in grass-addons too

Thanks much in advance

Vero
___
grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user

Re: [GRASS-user] error in i.sentinel.mask: nan values in xml file

2020-01-29 Thread Veronica Andreo
Hi Robi,

My bad, region was wrong... anyway, trying to replicate from the beginning
I see that i.sentinel.import with -r is importing empty maps. However, the
jp2 files have data. I can visualize them in QGIS. I'll report in a
different thread. Once I can figure it out and reach this point again, I'll
report back to you. Thanks for the clarification!

Cheers
Vero

El mié., 29 ene. 2020 a las 9:08, roberta fagandini (<
robifagand...@hotmail.it>) escribió:

> Hi Vero,
> i.sentinel.mask doesn't retrieve the maximum from the xml file but
> computes the value from the image using r.univar. The error could be due to
> the computational region..has the region been set correctly?
> Can you send the MTD_TL.xml file? I can download the image and make some
> tests.
>
> Roberta
>
> --
> *Da:* grass-user  per conto di
> Veronica Andreo 
> *Inviato:* martedì 28 gennaio 2020 19:57
> *A:* grass-user 
> *Oggetto:* [GRASS-user] error in i.sentinel.mask: nan values in xml file
>
> Hello
>
> I try to use i.sentinel.mask but I get the following error:
>
> i.sentinel.mask blue=$blue green=$green red=$red swir11=$swir11 nir=$nir
> swir12=$swir12 nir8a=$nir8a cloud_mask=cloud shadow_mask=shadow
> mtd_file=`find $out_dir -name 'MTD_TL.xml'`
>
> ADVERTENCIA: All subsequent operations will be limited to the current
>  computational region
> ADVERTENCIA: Any rescale factor has been applied
> --- Start computing maximum values of bands ---
> T21JYM_20200126T134201_B02_10m
> T21JYM_20200126T134201_B03_10m
> T21JYM_20200126T134201_B04_10m
> T21JYM_20200126T134201_B08_10m
> T21JYM_20200126T134201_B8A_20m
> T21JYM_20200126T134201_B11_20m
> T21JYM_20200126T134201_B12_20m
> --- Computed maximum value: dict_values([nan, nan, nan, nan, nan, nan,
> nan]) ---
> --- Statistics have been computed! ---
> --- Start clouds detection procedure ---
> --- Computing cloud mask... ---
> Mapa no válido 
> Parse error
> ERROR: error al parsear
> ERROR: An error occurred while running r.mapcalc with expression:
>cloud_def82115 = ifT21JYM_20200126T134201_B02_10m > (0.08*nan))
>&& (T21JYM_20200126T134201_B03_10m > (0.08*nan)) &&
>(T21JYM_20200126T134201_B04_10m > (0.08*nan))) == 1) &&
>(((T21JYM_20200126T134201_B04_10m < ((0.08*nan)*1.5)) &&
>(T21JYM_20200126T134201_B04_10m >
>T21JYM_20200126T134201_B12_20m*1.3)) == 0) &&
>(((T21JYM_20200126T134201_B11_20m < (0.1*nan)) &&
>(T21JYM_20200126T134201_B12_20m < (0.1*nan))) == 0) &&
>((if(T21JYM_20200126T134201_B8A_20m ==
>max(T21JYM_20200126T134201_B8A_20m, 2 *
>T21JYM_20200126T134201_B02_10m, 2 * T21JYM_20200126T134201_B03_10m,
>2 * T21JYM_20200126T134201_B04_10m))) == 0) &&
>((T21JYM_20200126T134201_B02_10m > 0.2) == 1), 0, null())
>
> I checked the xml file and there are a lot of nan's yes, but there are
> also real values. Why doesn't the max function in this part:
> https://github.com/OSGeo/grass-addons/blob/master/grass7/imagery/i.sentinel/i.sentinel.mask/i.sentinel.mask.py#L321
> recognize them? Isn't there a way to avoid nan while computing max?
>
> Thanks much in advance
> Vero
>
> ps: I can provide the xml if needed.
>
___
grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user

Re: [GRASS-user] r.sim.water simulation considering dams

2020-01-29 Thread Anna Petrášová
Hi,

I don't have any experience with that parameter, but I think if you don't
need permeable structures, you don't need that parameter. I would try to
represent the structures in the elevation, that should work. But keep in
mind that it's a shallow water flow model, so it's not ideal for filling
large and deep depressions. In that case you can also consider Itzi model.

Anna

On Thu, Jan 23, 2020 at 5:16 AM Johannes Radinger <
johannesradin...@gmail.com> wrote:

> Dear GRASS users,
>
> maybe someone of you has already worked with r.sim.water while considering
> dams as impermeable structures that retain water, i.e. create
> impoundments/reservoirs.
>
> I am wondering how to best specify dams within r.sim.water: There is the
> parameter flow_control which is a raster map that indicates the
> permeability of the landscape. The manual mentions here a permeability
> ratio (0-1) and I guess this should be 0 for all cells that represent a dam
> and 1 for all other cells of the computational region?!
> But what about the elevation data then; Do I need to provide an
> elevation raster that includes the dam height or should this be the
> elevation as without dams?
> I'd like to know whether I need to provide a flow_control map or an
> elevation map that includes dams or both? I couldn't find any example of
> r.sim.water that uses the flow_control parameter so far... any
> ideas/experiences from your side?
>
> cheers,
> Johannes
>
> ___
> grass-user mailing list
> grass-user@lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/grass-user
___
grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user

[GRASS-user] R: error in i.sentinel.mask: nan values in xml file

2020-01-29 Thread roberta fagandini
Hi Vero,
i.sentinel.mask doesn't retrieve the maximum from the xml file but computes the 
value from the image using r.univar. The error could be due to the 
computational region..has the region been set correctly?
Can you send the MTD_TL.xml file? I can download the image and make some tests.

Roberta


Da: grass-user  per conto di Veronica 
Andreo 
Inviato: martedì 28 gennaio 2020 19:57
A: grass-user 
Oggetto: [GRASS-user] error in i.sentinel.mask: nan values in xml file

Hello

I try to use i.sentinel.mask but I get the following error:

i.sentinel.mask blue=$blue green=$green red=$red swir11=$swir11 nir=$nir 
swir12=$swir12 nir8a=$nir8a cloud_mask=cloud shadow_mask=shadow mtd_file=`find 
$out_dir -name 'MTD_TL.xml'`

ADVERTENCIA: All subsequent operations will be limited to the current
 computational region
ADVERTENCIA: Any rescale factor has been applied
--- Start computing maximum values of bands ---
T21JYM_20200126T134201_B02_10m
T21JYM_20200126T134201_B03_10m
T21JYM_20200126T134201_B04_10m
T21JYM_20200126T134201_B08_10m
T21JYM_20200126T134201_B8A_20m
T21JYM_20200126T134201_B11_20m
T21JYM_20200126T134201_B12_20m
--- Computed maximum value: dict_values([nan, nan, nan, nan, nan, nan,
nan]) ---
--- Statistics have been computed! ---
--- Start clouds detection procedure ---
--- Computing cloud mask... ---
Mapa no válido 
Parse error
ERROR: error al parsear
ERROR: An error occurred while running r.mapcalc with expression:
   cloud_def82115 = ifT21JYM_20200126T134201_B02_10m > (0.08*nan))
   && (T21JYM_20200126T134201_B03_10m > (0.08*nan)) &&
   (T21JYM_20200126T134201_B04_10m > (0.08*nan))) == 1) &&
   (((T21JYM_20200126T134201_B04_10m < ((0.08*nan)*1.5)) &&
   (T21JYM_20200126T134201_B04_10m >
   T21JYM_20200126T134201_B12_20m*1.3)) == 0) &&
   (((T21JYM_20200126T134201_B11_20m < (0.1*nan)) &&
   (T21JYM_20200126T134201_B12_20m < (0.1*nan))) == 0) &&
   ((if(T21JYM_20200126T134201_B8A_20m ==
   max(T21JYM_20200126T134201_B8A_20m, 2 *
   T21JYM_20200126T134201_B02_10m, 2 * T21JYM_20200126T134201_B03_10m,
   2 * T21JYM_20200126T134201_B04_10m))) == 0) &&
   ((T21JYM_20200126T134201_B02_10m > 0.2) == 1), 0, null())

I checked the xml file and there are a lot of nan's yes, but there are also 
real values. Why doesn't the max function in this part: 
https://github.com/OSGeo/grass-addons/blob/master/grass7/imagery/i.sentinel/i.sentinel.mask/i.sentinel.mask.py#L321
 recognize them? Isn't there a way to avoid nan while computing max?

Thanks much in advance
Vero

ps: I can provide the xml if needed.
___
grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user