-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added new v.in.ogc.features addon * added new r.in.ogc.coverages addon Co-authored-by: Veronica Andreo <veroandreo@gmail.com>
- Loading branch information
1 parent
346da7e
commit 7c47469
Showing
10 changed files
with
357 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
MODULE_TOPDIR = ../.. | ||
|
||
PGM = r.in.ogc | ||
|
||
SUBDIRS = r.in.ogc.coverages | ||
|
||
include $(MODULE_TOPDIR)/include/Make/Dir.make | ||
|
||
default: parsubdirs htmldir | ||
|
||
install: installsubdirs | ||
$(INSTALL_DATA) $(PGM).html $(INST_DIR)/docs/html/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
MODULE_TOPDIR = ../../.. | ||
|
||
PGM = r.in.ogc.coverages | ||
|
||
include $(MODULE_TOPDIR)/include/Make/Script.make | ||
|
||
default: script | ||
$(MAKE) $(ETC)/grass_write_ascii.style | ||
|
||
$(ETC)/%: % | ||
$(INSTALL_DATA) $< $@ |
17 changes: 17 additions & 0 deletions
17
grass7/raster/r.in.ogc/r.in.ogc.coverages/r.in.ogc.coverages.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<h2>DESCRIPTION</h2> | ||
<em>r.in.ogc.coverages</em> is able to import data from an OGC API Coverages Service | ||
|
||
<h2>EXAMPLES</h2> | ||
|
||
<div class="code"><pre> | ||
r.in.ogc.coverages url=https://test.cubewerx.com/cubewerx/cubeserv/demo/ogcapi/Daraa -l | ||
|
||
r.in.ogc.coverages url=https://test.cubewerx.com/cubewerx/cubeserv/demo/ogcapi/Daraa layer=Daraa_DTED output=Daraa_DTED | ||
</pre></div> | ||
|
||
<h2>SEE ALSO</h2> | ||
More info about <a href="https://ogcapi.ogc.org/coverages/" target="blank">OGC API Coverages</a>. | ||
|
||
<h2>AUTHORS</h2> | ||
|
||
Luca Delucchi, Fondazione Edmund Mach, during Joint OGC OSGeo ASF Code Sprint 2021. |
90 changes: 90 additions & 0 deletions
90
grass7/raster/r.in.ogc/r.in.ogc.coverages/r.in.ogc.coverages.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#!/usr/bin/env python | ||
""" | ||
MODULE: r.in.ogc.coverages | ||
AUTHOR(S): Luca Delucchi <lucadeluge AT gmail.com> | ||
PURPOSE: Downloads and imports data from OGC API Coverages server. | ||
COPYRIGHT: (C) 2021 Luca Delucchi, and by the GRASS Development Team | ||
This program is free software under the GNU General Public License | ||
(>=v2). Read the file COPYING that comes with GRASS for details. | ||
""" | ||
|
||
#%module | ||
#% description: Downloads and imports data from OGC API Coverages server. | ||
#% keyword: raster | ||
#% keyword: import | ||
#% keyword: ogc | ||
#% keyword: coverages | ||
#%end | ||
|
||
#%option | ||
#% key: url | ||
#% type: string | ||
#% description: URL of OGC API Coverages server | ||
#% required: yes | ||
#%end | ||
|
||
#%option | ||
#% key: layer | ||
#% type: string | ||
#% description: Layer to request from server | ||
#%end | ||
|
||
#%option G_OPT_R_OUTPUT | ||
#% description: Name for output raster map | ||
#% required: no | ||
#%end | ||
|
||
#%flag | ||
#% key: l | ||
#% description: Get layers from the server | ||
#%end | ||
import sys | ||
import grass.script as grass | ||
|
||
|
||
def main(): | ||
try: | ||
from owslib.ogcapi.coverages import Coverages | ||
except: | ||
grass.fatal( | ||
_( | ||
"OSWLib was not found. Install OSWLib (http://geopython.github.com/OWSLib/)." | ||
) | ||
) | ||
|
||
feats = Coverages(options["url"]) | ||
collections = feats.coverages() | ||
if flags["l"]: | ||
for coll in collections: | ||
print("{}".format(coll)) | ||
return | ||
if not options["layer"]: | ||
grass.fatal( | ||
_("Required parameter <layer> not set: (Name for input vector map layer)") | ||
) | ||
elif options["layer"] not in collections: | ||
grass.fatal(_("Layer {} is not a Coverage layer")) | ||
|
||
if not options["output"]: | ||
grass.fatal( | ||
_("Required parameter <output> not set: (Name for output vector map)") | ||
) | ||
try: | ||
layer = feats.coverage(options["layer"]) | ||
except Exception as e: | ||
grass.fatal( | ||
_("Problem retrieving data from the server. The error was: {}".format(e)) | ||
) | ||
tmpfile = grass.tempfile() | ||
with open(tmpfile, "wb") as f: | ||
f.write(layer.getbuffer()) | ||
grass.run_command("r.import", input=tmpfile, output=options["output"]) | ||
|
||
|
||
if __name__ == "__main__": | ||
options, flags = grass.parser() | ||
sys.exit(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> | ||
<html> | ||
<head> | ||
<title>GRASS GIS manual: r.in.ogc</title> | ||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> | ||
<link rel="stylesheet" href="grassdocs.css" type="text/css"> | ||
</head> | ||
<body bgcolor="white"> | ||
<div id="container"> | ||
|
||
<a href="https://grass.osgeo.org/grass-stable/manuals/index.html"><img src="grass_logo.png" alt="GRASS logo"></a> | ||
<hr class="header"> | ||
|
||
<h2>NAME</h2> | ||
<em><b>r.in.ogc</b></em> imports raster data from an OGC API server. | ||
<h2>KEYWORDS</h2> | ||
<a href="https://grass.osgeo.org/grass-stable/manuals/vector.html">vector</a>, | ||
<a href="https://grass.osgeo.org/grass-stable/manuals/topic_import.html">import topic</a> | ||
|
||
<h2>DESCRIPTION</h2> | ||
|
||
The <em>r.in.ogc</em> suite is able to import raster data from several OGC API standards. It supports | ||
<ul> | ||
<li><a href="r.in.ogc.coverages.html">OGC API Coverages</a> - import raster data from an OGC API Coverages standard </li> | ||
</ul> | ||
|
||
<div class="code"><pre> | ||
g.extension r.in.ogc | ||
</pre></div> | ||
|
||
<h2>NOTES</h2> | ||
|
||
<em>r.in.ogc</em> requires <em>owslib</em> Python library. | ||
|
||
<h2>SEE ALSO</h2> | ||
|
||
<em> | ||
<a href="r.in.ogc.coverages">r.in.ogc.coverages</a> | ||
<a href="v.in.ogc.html">v.in.ogc</a> | ||
</em> | ||
|
||
<h2>AUTHORS</h2> | ||
|
||
Luca Delucchi, Fondazione Edmund Mach, during Joint OGC OSGeo ASF Code Sprint 2021. | ||
<!-- | ||
<p> | ||
<i>Last changed: $Date$</i> | ||
--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
MODULE_TOPDIR = ../.. | ||
|
||
PGM = v.in.ogc | ||
|
||
SUBDIRS = v.in.ogc.features | ||
|
||
include $(MODULE_TOPDIR)/include/Make/Dir.make | ||
|
||
default: parsubdirs htmldir | ||
|
||
install: installsubdirs | ||
$(INSTALL_DATA) $(PGM).html $(INST_DIR)/docs/html/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
MODULE_TOPDIR = ../../.. | ||
|
||
PGM = v.in.ogc.features | ||
|
||
include $(MODULE_TOPDIR)/include/Make/Script.make | ||
|
||
default: script | ||
$(MAKE) $(ETC)/grass_write_ascii.style | ||
|
||
$(ETC)/%: % | ||
$(INSTALL_DATA) $< $@ |
18 changes: 18 additions & 0 deletions
18
grass7/vector/v.in.ogc/v.in.ogc.features/v.in.ogc.features.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<h2>DESCRIPTION</h2> | ||
<em>v.in.ogc.features</em> in able to import data from a OGC API Features Service | ||
|
||
<h2>EXAMPLES</h2> | ||
|
||
<div class="code"><pre> | ||
v.in.ogc.features -l url=https://demo.pygeoapi.io/stable | ||
|
||
v.in.ogc.features url=https://demo.pygeoapi.io/stable layers=lakes output=large_lakes | ||
</pre></div> | ||
|
||
<h2>SEE ALSO</h2> | ||
More info about <a href="https://ogcapi.ogc.org/features/" target="blank">OGC API Features</a>. | ||
|
||
<h2>AUTHORS</h2> | ||
|
||
Luca Delucchi, Fondazione Edmund Mach, during Joint OGC OSGeo ASF Code Sprint 2021. | ||
|
91 changes: 91 additions & 0 deletions
91
grass7/vector/v.in.ogc/v.in.ogc.features/v.in.ogc.features.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#!/usr/bin/env python | ||
""" | ||
MODULE: v.in.ogc.features | ||
AUTHOR(S): Luca Delucchi <lucadeluge AT gmail.com> | ||
PURPOSE: Downloads and imports data from OGC API Features server. | ||
COPYRIGHT: (C) 2021 Luca Delucchi, and by the GRASS Development Team | ||
This program is free software under the GNU General Public License | ||
(>=v2). Read the file COPYING that comes with GRASS for details. | ||
""" | ||
|
||
#%module | ||
#% description: Downloads and imports data from OGC API Features server. | ||
#% keyword: vector | ||
#% keyword: import | ||
#% keyword: ogc | ||
#% keyword: features | ||
#%end | ||
|
||
#%option | ||
#% key: url | ||
#% type: string | ||
#% description: URL of OGC API Features server | ||
#% required: yes | ||
#%end | ||
|
||
#%option | ||
#% key: layer | ||
#% type: string | ||
#% description: Layer to request from server | ||
#%end | ||
|
||
#%option G_OPT_V_OUTPUT | ||
#% description: Name for output vector map | ||
#% required: no | ||
#%end | ||
|
||
#%flag | ||
#% key: l | ||
#% description: Get layers from the server | ||
#%end | ||
import sys | ||
import json | ||
import grass.script as grass | ||
|
||
|
||
def main(): | ||
try: | ||
from owslib.ogcapi.features import Features | ||
except: | ||
grass.fatal( | ||
_( | ||
"OSWLib was not found. Install OSWLib (http://geopython.github.com/OWSLib/)." | ||
) | ||
) | ||
|
||
feats = Features(options["url"]) | ||
collections = feats.feature_collections() | ||
if flags["l"]: | ||
for coll in collections: | ||
print("{}".format(coll)) | ||
return | ||
if not options["layer"]: | ||
grass.fatal( | ||
_("Required parameter <layer> not set: (Name for input vector map layer)") | ||
) | ||
elif options["layer"] not in collections: | ||
grass.fatal(_("Layer {} is not a Feature layer")) | ||
if not options["output"]: | ||
grass.fatal( | ||
_("Required parameter <output> not set: (Name for output vector map)") | ||
) | ||
|
||
try: | ||
layer = feats.collection_items(options["layer"]) | ||
except Exception as e: | ||
grass.fatal( | ||
_("Problem retrieving data from the server. The error was: {}".format(e)) | ||
) | ||
tmpfile = grass.tempfile() | ||
with open(tmpfile, "w") as f: | ||
json.dump(layer, f, indent=4) | ||
grass.run_command("v.import", input=tmpfile, output=options["output"]) | ||
|
||
|
||
if __name__ == "__main__": | ||
options, flags = grass.parser() | ||
sys.exit(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> | ||
<html> | ||
<head> | ||
<title>GRASS GIS manual: v.in.ogc</title> | ||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> | ||
<link rel="stylesheet" href="grassdocs.css" type="text/css"> | ||
</head> | ||
<body bgcolor="white"> | ||
<div id="container"> | ||
|
||
<a href="https://grass.osgeo.org/grass-stable/manuals/index.html"><img src="grass_logo.png" alt="GRASS logo"></a> | ||
<hr class="header"> | ||
|
||
<h2>NAME</h2> | ||
<em><b>v.in.ogc</b></em> imports vector data from an OGC API server. | ||
<h2>KEYWORDS</h2> | ||
<a href="https://grass.osgeo.org/grass-stable/manuals/vector.html">vector</a>, | ||
<a href="https://grass.osgeo.org/grass-stable/manuals/topic_import.html">import topic</a> | ||
|
||
<h2>DESCRIPTION</h2> | ||
|
||
The <em>v.in.ogc</em> suite is able to import vector data from several OGC API standards. It supports | ||
<ul> | ||
<li><a href="v.in.ogc.features.html">OGC API Features</a> - import vector data from a OGC API Features standard </li> | ||
</ul> | ||
|
||
<div class="code"><pre> | ||
g.extension v.in.ogc | ||
</pre></div> | ||
|
||
<h2>NOTES</h2> | ||
|
||
<em>v.in.ogc</em> requires <em>owslib</em> Python library. | ||
|
||
<h2>SEE ALSO</h2> | ||
|
||
<em> | ||
<a href="v.in.ogc.features.html">v.in.ogc.features</a> | ||
</em> | ||
|
||
<h2>AUTHORS</h2> | ||
|
||
Luca Delucchi, Fondazione Edmund Mach, during Joint OGC OSGeo ASF Code Sprint 2021. | ||
<!-- | ||
<p> | ||
<i>Last changed: $Date$</i> | ||
--> |