Skip to content

Commit

Permalink
Merge branch 'alyssamf-bug-fix-90'
Browse files Browse the repository at this point in the history
  • Loading branch information
iamtekson committed Nov 10, 2022
2 parents 8900162 + 1584e87 commit 100f66e
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 25 deletions.
24 changes: 0 additions & 24 deletions docs/source/advance_use.rst

This file was deleted.

50 changes: 50 additions & 0 deletions docs/source/advanced_uses.rst
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')
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Welcome to geoserver-rest documentation!
about
installation
how_to_use
advance_use
advanced_uses
change_log
license
contribution
Expand Down

0 comments on commit 100f66e

Please sign in to comment.