Import Related Modules¶
These modules are for importing data. Unlike the existing modules, they can import all files in a directory
by considering a certain pattern. Moreover, it is possible to import these data in different mapsets
. In addition,
the module i_fr_import
can import pyroSAR
datasets in a directory based on their metadata.
The name of the modules was chosen to ensure conformity with the GRASS GIS conventions. The addition r
stands for
raster where the addition d
and f
stand for directory and finder respectively.
Note, it is important for the parameter `pattern` that the asterisk(‘*’) contains a dot (see examples).
-
class
gscpy.i_import.i_dr_import.
DirImport
(input_dir, pattern=None, extension=None)[source]¶ Import data into a mapset from a file with considering certain patterns.
Parameters: - input_dir (str) – The directory where the files are located.
- pattern (str, optional) – The pattern of file names. If not specified all files with selected extension will be imported.
- extension ({'ENVI', 'GEOTIFF'}, optional) – Which extensions should be recognized? Default is ‘GEOTIFF’
-
input_dir
¶ str
-
extension
¶ str
-
filter_p
¶ str – Combines pattern and extension.
-
files
¶ list – All detected files.
Examples
The general usage is
$ i.dr.import [-r -l -c -p] input_dir=string [pattern=string] [extension=string] [mapset=string] [dbase=string] [location=string] [--verbose] [--quiet]
Import files that starts with ‘S1’ from a directory in current mapset and reproject it
$ i.dr.import -r input_dir=/home/user/data pattern=S1.*
Import files that starts with ‘S1’ from a directory in a new mapset and reproject it
$ i.dr.import -c -r input_dir=/home/user/data pattern=S1.* mapset=Goettingen
Notes
Note, it is important for the parameter pattern that the asterisk(‘*’) contains a dot (see examples).
- Flags:
- r : Reproject raster data (using r.import if needed).
- l : Link raster data instead of importing.
- c : Create a new mapset.
- p : Print the detected files and exit.
-
create_mapset
(mapset, dbase=None, location=None)[source] Create a new mapset calling the module g.c.mapset.
Parameters: - mapset (str, optional) – Name of mapset.
- dbase (str, optional) – Location of GRASS GIS database
- mapset – Name of the mapset that will be created.
Returns: Return type: None
-
import_products
(reproject=False, link=False)[source] Import detected files.
Parameters: - reproject (bool) – Reproject raster data (using r.import if needed).
- link (bool) – Link raster data instead of importing.
Returns: Return type: None
-
print_products
()[source] Print all detected files.
Returns: Return type: None
-
class
gscpy.i_import.i_fr_import.
FinderImport
(input_dir, recursive=False, sensor=None, projection=None, orbit=None, polarization=None, acquisition_mode=None, start=None, stop=None, product=None, spacing=None, sample=None, lines=None)[source]¶ Import pyroSAR dataset in a directory based on their metadata.
Parameters: - input_dir (str) – The directory where the files are located.
- recursive (bool, optional) – Recursive search. Default is False.
- sensor (str or tuple, optional) – Sensor.
- projection (str or tuple, optional) – Projection.
- orbit (str or tuple, optional) – Orbit.
- polarization (str or tuple, optional) – Polarization.
- acquisition_mode (str or tuple, optional) – Acquisition_mode.
- start (str or tuple, optional) – Start.
- stop (str or tuple, optional) – Stop.
- product (str or tuple, optional) – Product.
- spacing (str or tuple, optional) – Spacing.
- sample (str or tuple, optional) – Sample.
- lines (str or tuple, optional) – Lines.
-
input_dir
¶ str
-
recursive
¶ bool
-
kwargs
¶ dict – Selected attributs (sensor, polarization etc.) in a dictionary.
-
files
¶ list – All detected files.
Examples
The general usage is
$ i.fr.import [-r -l -c -p -e] input_dir=string [*attributes=string] [mapset=string] [dbase=string] [location=string] [--verbose] [--quiet]
For *attributes the following parameters can be used
>>> ['sensor', 'projection', 'orbit', 'polarization', 'acquisition_mode', 'start', 'stop', 'product', 'spacing', 'samples', 'lines']
Import Sentinel 1A files with polarization VV and VH from a directory in current mapset and reproject it
$ i.fr.import -r input_dir=/home/user/data sensor=SA1 polarization=VV, VH
Import Sentinel 1A and 1B files with polarization VV from a directory in a new mapset and reproject it
$ i.fr.import -c -r input_dir=/home/user/data sensor=S1A, S1B polarization=VV mapset=Goettingen
Notes
- Flags:
- r : Reproject raster data (using r.import if needed).
- l : Link raster data instead of importing.
- c : Create a new mapset.
- p : Print the detected files and exit.
- e : Recursive search.
-
create_mapset
(mapset, dbase=None, location=None)[source] Create a new mapset calling the module g.c.mapset.
Parameters: - mapset (str, optional) – Name of mapset.
- dbase (str, optional) – Location of GRASS GIS database
- mapset – Name of the mapset that will be created.
Returns: Return type: None
-
find_products
()[source] Find all files that matches the input attributes. :returns: :rtype: list
-
import_products
(reproject=False, link=False)[source] Import detected files.
Parameters: - reproject (bool) – Reproject raster data (using r.import if needed).
- link (bool) – Link raster data instead of importing.
Returns: Return type: None
-
print_products
()[source] Print all detected files.
Returns: Return type: None