-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
51 additions
and
25 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,50 @@ | ||
Advanced uses for automation | ||
============================ | ||
|
||
The following code will first convert all the ``.rst`` data format inside ``C:\Users\gic\Desktop\etlIa\`` folder, into ``tiff`` format and then upload all the ``tiff`` files to the GeoServer. | ||
|
||
|
||
.. code-block:: python3 | ||
from geo.Geoserver import Geoserver | ||
from osgeo import gdal | ||
import glob | ||
import os | ||
geo = Geoserver('http://localhost:8080/geoserver', username='admin', password='geoserver') | ||
rst_files = glob.glob(r'C:\Users\gic\Desktop\etlIa\*.rst') | ||
geo.create_workspace('geonode') | ||
for rst in rst_files: | ||
file_name = os.path.basename(rst) | ||
src = gdal.Open(rst) | ||
tiff = r'C:\Users\tek\Desktop\try\{}'.format(file_name) | ||
gdal.Translate(tiff, src) | ||
geo.create_coveragestore(layer_name=file_name, path=tiff, workspace='geonode') #, overwrite=True | ||
The following code will upload all the ``tiff`` files (with extension .tiff or .tif) located in ``data/landuse`` to the GeoServer. | ||
|
||
|
||
.. code-block:: python3 | ||
from geo.Geoserver import Geoserver | ||
import glob | ||
import os | ||
geo = Geoserver('http://localhost:8080/geoserver', username='admin', password='geoserver') | ||
geo.create_workspace('test') | ||
tiff_files = glob.glob('data/landuse/*.tiff') + glob.glob('data/landuse/*.tif') | ||
for tiff in tiff_files: | ||
file_name = os.path.basename(tiff) | ||
# Removing extension for layer name | ||
temp = os.path.splitext(file_name) | ||
layer_name = temp[0] | ||
# Will overwrite layer if it exists | ||
geo.create_coveragestore(layer_name=layer_name, path=tiff, workspace='test') | ||
print(file_name + ' uploaded to geoserver') |
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