[GRASS-user] r.proj WIND

2020-04-08 Thread Pavel Jansa

Hello,

I am trying to project data from ll  wgas84 location to custom 
projection. I end up with: ERROR: Unable to open element file <> for 
. Data were imported to wgs 84 location withou any problems 
(r.in.gdal) and than I made smaller area using r.resample.


I am using Grass 7.8.2 on Ubuntu 18.04.

Cheers,

Pavel

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

Re: [GRASS-user] Appropriate input/output range for i.atcorr WorldView2?

2020-04-08 Thread Paige Byassee
Thank you Nikos & Marcus,

Converting to TOA radiance (or reflectance) is not really the issue... I
have already been following "Absolute Radiometric Calibration, Prepared By:
Michele A. Kuester" using the formula for L (done in R, screenshot
attached). I do think it is necessary that this be done in FLOAT32 to
retain enough detail and per DigitalGlobe recommendations.

So, if I covert to TOA radiance as you've described, I am left with 32-bit
pixels. I then import the images using r.in.gdal and launch i.atcorr. *Would
the input range then be 0, 4294967295 (i.e. (2^32) - 1)? *

If so, I wonder what a good output range might be, as I presume using
r.out.gdal on a 32-bit image could take a long time.

Thank you for your help,
Paige

On Wed, Apr 8, 2020 at 6:31 AM  wrote:

> On 2020-04-08 15:17, Markus Neteler wrote:
> ..
> > I believe that you need to apply the formula along with the respective
> > band calibration values ABSCALFACTOR and  EFFECTIVEBANDWIDTH (the same
> > is also stored in the IMD files) from the XML metadata files:
> >
> > grep 'ABSCALFACTOR\|EFFECTIVEBANDWIDTH'
> > 058891334020_01_P001_MUL/18DEC03184338-M2AS-058891334020_01_P001.XML
> > 9.2956540e-03
> >
> > 4.730e-02
> > 9.7480511e-03
> >
> > 5.430e-02
> > 7.5414950e-03
> >
> > 6.300e-02
> > 5.1010880e-03
> >
> > 3.740e-02
> > 1.1036230e-02
> >
> > 5.740e-02
> > 4.5396190e-03
> >
> > 3.930e-02
> > 1.2243800e-02
> >
> > 9.890e-02
> > 9.0422340e-03
> >
> > 9.959e-02
> >
> > Citing from "Absolute Radiometric Calibration, Prepared By: Michele A.
> > Kuester"
> >
> https://dg-cms-uploads-production.s3.amazonaws.com/uploads/document/file/209/ABSRADCAL_FLEET_2016v0_Rel20170606.pdf
> >
> >   "The top-of-atmosphere radiance, L, in units of Wμm-1m-2sr-1, is
> > then found from the DigitalGlobe
> > image product for each band by converting from digital numbers
> > (DN) using the equation,
> >
> > L = Gain * DN * (abscalfactor/effective bandwidth) + Offset
> >
> > The TDI specific "abscalfactor" and "effectiveBandwidth" are
> > delivered with the imagery in the metadata file.
> > The digital number, DN, is the pixel value found in the imagery.
> > The Gain and Offset are the absolute
> > radiometric calibration band dependent adjustment factors that are
> > given in Table 1. Note that these
> > are not necessarily stagnant values and they are revisited
> > annually.
> >  "
> >
> > (the "Table 1" is found in the same PDF file above. You may want to
> > check if a newer table version exists).
> >
> > You can apply this formula with r.mapcalc, for each band to obtain TOA
> > data from DN.
>
> See also https://gitlab.com/NikosAlexandris/i.worldview.toar or
> https://github.com/NikosAlexandris/i.worldview.toar.
>
> Maybe useful (though ratehr badly programmed at the time).
>
> Nikos
>


-- 
*Paige Byassee*
Appalachian State University '19
B.S., Ecology|Certificate in GIS
(704)488-0872
byasseepa...@gmail.com
___
grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user

Re: [GRASS-user] Appropriate input/output range for i.atcorr WorldView2?

2020-04-08 Thread nik

On 2020-04-08 15:17, Markus Neteler wrote:
..

I believe that you need to apply the formula along with the respective
band calibration values ABSCALFACTOR and  EFFECTIVEBANDWIDTH (the same
is also stored in the IMD files) from the XML metadata files:

grep 'ABSCALFACTOR\|EFFECTIVEBANDWIDTH'
058891334020_01_P001_MUL/18DEC03184338-M2AS-058891334020_01_P001.XML
9.2956540e-03

4.730e-02

9.7480511e-03

5.430e-02

7.5414950e-03

6.300e-02

5.1010880e-03

3.740e-02

1.1036230e-02

5.740e-02

4.5396190e-03

3.930e-02

1.2243800e-02

9.890e-02

9.0422340e-03

9.959e-02


Citing from "Absolute Radiometric Calibration, Prepared By: Michele A. 
Kuester"

https://dg-cms-uploads-production.s3.amazonaws.com/uploads/document/file/209/ABSRADCAL_FLEET_2016v0_Rel20170606.pdf

  "The top-of-atmosphere radiance, L, in units of Wμm-1m-2sr-1, is
then found from the DigitalGlobe
image product for each band by converting from digital numbers
(DN) using the equation,

L = Gain * DN * (abscalfactor/effective bandwidth) + Offset

The TDI specific "abscalfactor" and "effectiveBandwidth" are
delivered with the imagery in the metadata file.
The digital number, DN, is the pixel value found in the imagery.
The Gain and Offset are the absolute
radiometric calibration band dependent adjustment factors that are
given in Table 1. Note that these
are not necessarily stagnant values and they are revisited 
annually.

 "

(the "Table 1" is found in the same PDF file above. You may want to
check if a newer table version exists).

You can apply this formula with r.mapcalc, for each band to obtain TOA
data from DN.


See also https://gitlab.com/NikosAlexandris/i.worldview.toar or 
https://github.com/NikosAlexandris/i.worldview.toar.


Maybe useful (though ratehr badly programmed at the time).

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

Re: [GRASS-user] Appropriate input/output range for i.atcorr WorldView2?

2020-04-08 Thread Markus Neteler
Hi Paige,

On Tue, Apr 7, 2020 at 1:45 AM Paige Byassee  wrote:
>
> Can anyone speak to the appropriate range/datatype of WorldView2 rasters when 
> using the i.atcorr module?
>
> I.atcorr requires the input raster be converted to at-sensor-radiance first, 
> which I have done according to DigitalGlobe documention.
> DG suggests all transformations be done in FLOAT32 datatype, and i.atcorr 
> requires a specified input/output range that is positive.

Yes, as per manual
https://grass.osgeo.org/grass78/manuals/i.atcorr.html:

Input range
  range=min,max
  Default: 0,255

.. the default range is 8bit. Since you use WorldView2, the range
parameter needs to be modified (see below).

I have a WorldView2 scene available here, so I am looking into the
details with gdalinfo:


Metadata:
  AREA_OR_POINT=Area
  METADATATYPE=DG
  TIFFTAG_COPYRIGHT=(C) COPYRIGHT 2018 DigitalGlobe, Inc., Longmont CO USA 80503
  TIFFTAG_DATETIME=2018:12:20 09:13:25
  TIFFTAG_IMAGEDESCRIPTION={
  bandList =
  [
6;
...
9;
  ]
}
  TIFFTAG_MAXSAMPLEVALUE=2047
  TIFFTAG_MINSAMPLEVALUE=0
Image Structure Metadata:
  INTERLEAVE=BAND
RPC Metadata:
...
Band 1 Block=3217x162 Type=UInt16, ColorInterp=Red
  Overviews: 1609x1660, 805x830, 403x415, 202x208
Band 2 Block=3217x162 Type=UInt16, ColorInterp=Green
...

So, UInt16 also here. Now:

> I convert from the original DN's (delivered in UINT16) to radiance (FLOAT32),

I am not entirely convinced that you need to convert UINT16 to FLOAT32
like that.
I believe that you need to apply the formula along with the respective
band calibration values ABSCALFACTOR and  EFFECTIVEBANDWIDTH (the same
is also stored in the IMD files) from the XML metadata files:

grep 'ABSCALFACTOR\|EFFECTIVEBANDWIDTH'
058891334020_01_P001_MUL/18DEC03184338-M2AS-058891334020_01_P001.XML
9.2956540e-03
4.730e-02
9.7480511e-03
5.430e-02
7.5414950e-03
6.300e-02
5.1010880e-03
3.740e-02
1.1036230e-02
5.740e-02
4.5396190e-03
3.930e-02
1.2243800e-02
9.890e-02
9.0422340e-03
9.959e-02

Citing from "Absolute Radiometric Calibration, Prepared By: Michele A. Kuester"
https://dg-cms-uploads-production.s3.amazonaws.com/uploads/document/file/209/ABSRADCAL_FLEET_2016v0_Rel20170606.pdf

  "The top-of-atmosphere radiance, L, in units of Wμm-1m-2sr-1, is
then found from the DigitalGlobe
image product for each band by converting from digital numbers
(DN) using the equation,

L = Gain * DN * (abscalfactor/effective bandwidth) + Offset

The TDI specific "abscalfactor" and "effectiveBandwidth" are
delivered with the imagery in the metadata file.
The digital number, DN, is the pixel value found in the imagery.
The Gain and Offset are the absolute
radiometric calibration band dependent adjustment factors that are
given in Table 1. Note that these
are not necessarily stagnant values and they are revisited annually.
 "

(the "Table 1" is found in the same PDF file above. You may want to
check if a newer table version exists).

You can apply this formula with r.mapcalc, for each band to obtain TOA
data from DN.

> and while my radiance values are positive, the datatype range is not. In 
> another sense, WV2 is encoded with an 11-bit dynamic range (i.e. 2^11-bit 
> range), but I am unsure if any of these values are right for the module... 
> For example, Sentinel 2 L1C are also encoded as UINT16 with 15 significant 
> bits. However, documentation states that the correct i.atcorr Sentinel range 
> is 1-1; 1 being a specified QUANTIFICATION_VALUE by Sentinel.
>
> Is there a WorldView 2 equivalent to this quantification value? Is there an 
> alternative range specific to WV2? Might this range be affected by the 
> radiance conversion? Respectively, what would be the appropriate 
> output/rescale range?

I hope the explanations above help.
Please let us know how it goes.

> In general- Is the i.atcorr module seeking the literal range of the image 
> pixel values, t
> he range of the datatype they're in, or the range of data the satellite can 
> collect?

Well, unfortunately i.atcorr isn't yet clever enough to parse the
values itself from the metadata. So, one needs to find the values and
apply them.

Here is an overview:
https://grasswiki.osgeo.org/wiki/Atmospheric_correction

and this page should IMHO be updated (your input is most welcome here
- just register there to edit or comment here)
https://grasswiki.osgeo.org/wiki/WorldView#Spectral_Radiance


Best,
Markus

--
Markus Neteler, PhD
https://www.mundialis.de - free data with free software
https://grass.osgeo.org
https://courses.neteler.org/blog
___
grass-user mailing list

Re: [GRASS-user] Install package for add-on in /usr/bin/python3

2020-04-08 Thread Stefan Blumentrath
Hi Robin,

After installing from python-fmask source as described I got the same error 
message as you did on:

from fmask import fmask

(just importing fmask worked also before).

The problem seems to be that fmask (including it`s C components) gets installed 
in /usr/local/. See:
https://github.com/ubarsc/python-fmask/issues/19

You can fix that by specifying /usr as a prefix during install:
sudo python3 setup.py install --prefix=/usr

(note that I also had to specifically call setup.py with python3 which was an 
error in my initial installation script.)

When python-fmask gets available on PyPi, I guess this will be taken care of…

If you set the PYTHONPATH environment variable before starting GRASS GIS, GRASS 
should temporarily add the path to the GRASS python libs (but nothing more). If 
you use a prepackaged GRASS installation, it is compiled against a specific 
Python version (usually system Python). You can see which Python installation 
GRASS is using by typing:

echo $GRASS_PYTHON

So, if you want to use your conda Python in GRASS (despite possible issues 
other places), my understanding is that you would need to point GRASS_PYTHON 
variable to conda python. However, with the installation described above, GRASS 
should find fmask and _fillminima from fmask… In the long run, this will be the 
most convenient solution for an addon. For the time being, the installation 
procedure could be added to the manual as a note (and probably as an error 
message if import fails), until it becomes available on PyPi.

Hope that helps.

Cheers
Stefan

From: robin 
Sent: søndag 5. april 2020 19:13
To: Stefan Blumentrath 
Subject: Re: [GRASS-user] Install package for add-on in /usr/bin/python3


Hi Stefan,

thank you very much!! Why does my PYTHONPATH needs to point to the 
system-python? So the issue is, that I would like to have a script that I can 
run from within GRASS with launch user-defined script. I created a conda 
environment (“spatial”) and installed python-fmask with:

conda install -c conda-forge python-fmask

This automativally installes python3.8.2, fmask and rios in:

home/robin/miniconda3/envs/spatial/lib/python3.8/site-packages/

I then added this path in my .bashrc (I thought I needed to put it in the 
.profile, but this didn’t work for some reason) my PYTHONPATH with:

export 
PYTHONPATH=/home/robin/miniconda3/envs/spatial/lib/python3.8/site-packages

I then did a source .bashrc and when printing the PYTHONPATH with

echo $PYTHONPATH it prints

/home/robin/miniconda3/envs/spatial/lib/python3.8/site-packages

I then made a little test script where I wanted to test if the fmask-import and 
rios-import works
from within GRASS

#



  1 #! /usr/bin/env python3

  2

  3 import sys

  4 import os

  5

  6 for i in sys.path:

  7 print(i)

  8

  9 print("PYTHONPATH")

 10 print(os.environ["PYTHONPATH"])

 11

 12 import fmask

 13 import rios

 13 import rios

#

When importing this script in GRASS with the “launch user-defined 
script”-option, the output is:

/home/robin/Desktop

/usr/lib/grass78/etc/python

/usr/lib/python36.zip

/usr/lib/python3.6

/usr/lib/python3.6/lib-dynload

/home/robin/.local/lib/python3.6/site-packages

/usr/local/lib/python3.6/dist-packages

/usr/lib/python3/dist-packages

PYTHONPATH

/usr/lib/grass78/etc/python

Traceback (most recent call last):

  File "/home/robin/Desktop/test.py", line 12, in 

import fmask

ModuleNotFoundError: No module named 'fmask'

I don’t know why the PYTHONPATH is different when run from GRASS. Probably I’m 
just not understanding something really basic. If so I’m really sorry. It’s 
just a little frustrating to spend so much time in something so basic.

Anyways: Thanks so much for the help!
Cheers,
Robin

On 05.04.2020 14:35, Stefan Blumentrath wrote:
Did you check that your pythonpath again points to system python. And can you 
share your code, esp. the imports. That would simplify testing...
Sent from Outlook Mobile


From: robin kohrs 
Sent: Sunday, April 5, 2020 11:04:02 AM
To: Stefan Blumentrath 

Subject: Re: [GRASS-user] Install package for add-on in /usr/bin/python3

Hi Stefan,

thank you very much for the answer! That would be great if it'd become a
standard python package!
I managed to install everything as you explained it. But when I run:

In [1]: from fmask import fmask

I still get

ModuleNotFoundError: No module named 'rios'

I guess this is, because they are still in seperate folders right?
When I copy everything from the installed rios into fmask (I know this
seems really wrong...) and then do :

In [2]: from fmask import fmask

ImportError: cannot import name '_fillminima'

I'm sorry for these basic questions, but I just can't find a solution:/

cheers and thanks a lot!!
Robin

On 04.04.20 20:56, Stefan Blumentrath wrote:
> Hi Robin,
>
> The errors you encountered after setting the python path,