Skip to content

Commit

Permalink
Merge pull request #174 from gicait/dev
Browse files Browse the repository at this point in the history
Making gdal, seaborn and matplotlib as a optional dependencies
  • Loading branch information
iamtekson authored Jan 23, 2025
2 parents ee500d1 + 61a9eba commit b4b9a39
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 18 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ target/

# Jupyter Notebook
.ipynb_checkpoints
test.ipynb

# IPython
profile_default/
Expand Down
5 changes: 5 additions & 0 deletions docs/source/how_to_use.rst
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ You can create a layer group from layers that have been uploaded previously with
Uploading and publishing styles
-------------------------------

**WARNING:** As of version 2.9.0, the required dependency ``gdal``, ``matplotlib`` and ``seaborn`` was converted into an optional dependency. Fresh installations of this library will require that you then install ``gdal``, ``matplotlib`` and ``seaborn`` yourself with ``pip install gdal matplotlib seaborn``.


It is used for uploading ``SLD`` files and publish style. If the style name already exists, you can pass the parameter ``overwrite=True`` to overwrite it. The name of the style will be name of the uploaded file name.

Before uploading ``SLD`` file, please check the version of your sld file. By default the version of sld will be ``1.0.0``. As I noticed, by default the QGIS will provide the .sld file of version ``1.0.0`` for raster data version ``1.1.0`` for vector data.
Expand Down Expand Up @@ -228,6 +231,8 @@ For generating the style for ``classified raster``, you can pass the another par
Creating feature styles
-----------------------

**WARNING:** As of version 2.9.0, the required dependency ``gdal``, ``matplotlib`` and ``seaborn`` was converted into an optional dependency. Fresh installations of this library will require that you then install ``gdal``, ``matplotlib`` and ``seaborn`` yourself with ``pip install gdal matplotlib seaborn``.

It is used for creating the style for ``point``, ``line`` and ``polygon`` dynamically. It currently supports three different types of feature styles:

1. ``Outline featurestyle``: For creating the style which have only boundary color but not the fill style
Expand Down
33 changes: 24 additions & 9 deletions docs/source/installation.rst
Original file line number Diff line number Diff line change
@@ -1,24 +1,43 @@
Installation
=============

.. warning::
As of version 2.9.0, the required dependency ``gdal``, ``matplotlib`` and ``seaborn`` was converted into an optional dependency. Fresh installations of this library will require that you then install ``gdal``, ``matplotlib`` and ``seaborn`` yourself with ``pip install gdal matplotlib seaborn``.


Conda installation
^^^^^^^^^^^^^^^^^^

The ``geoserver-rest`` can be installed from either ``conda-forge`` channel as below:

.. code-block:: shell
conda install -c conda-forge geoserver-rest
$ conda install -c conda-forge geoserver-rest[all]
Pip installation
^^^^^^^^^^^^^^^^

For installation of this package, following packages should be installed first:
The ``geoserver-rest`` library can be installed using ``pip`` as below:

.. code-block:: shell
$ pip install geoserver-rest
But best way to get all the functationality is to install the optional dependencies as well:

.. code-block:: shell
$ pip install geoserver-rest[all]
If you want to install the geoserver-rest library with the optional dependencies (this will be useful if you are planning to create dynamic style files based on your dataset. Explore ``create_coveragestyle``, ``upload_style`` etc functions), you need to install the following dependencies first:

* `GDAL <https://gdal.org/>`_
* `matplotlib <https://matplotlib.org/>`_
* `seaborn <https://seaborn.pydata.org/>`_


Windows installation
--------------------
Dependencies installation in Windows
------------------------------------

.. warning::
As of March 2022, ``pipwin`` has been deprecated and is no longer maintained. Do not use this method.
Expand All @@ -31,14 +50,10 @@ One way is install the wheel directly from the `Geospatial library wheels for Py
# For Python3.10 on Windows 64-bit systems
$ pip.exe install https://github.com/cgohlke/geospatial-wheels/releases/download/<release_version>/GDAL-3.7.1-cp310-cp310-win_amd64.whl
$ pip.exe install seaborn matplotlib
Another way is to use the GDAL network installer binary package available at: `OSGeo4W <https://trac.osgeo.org/osgeo4w/>`_.

Now you can then install ``geoserver-rest`` library with ``pip``:

.. code-block:: shell
$ pip install geoserver-rest

macOS installation
------------------
Expand Down
10 changes: 9 additions & 1 deletion geo/Geoserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from xmltodict import parse, unparse

# custom functions
from .Style import catagorize_xml, classified_xml, coverage_style_xml, outline_only_xml
from .supports import prepare_zip_file, is_valid_xml, is_surrounded_by_quotes


Expand Down Expand Up @@ -1612,6 +1611,7 @@ def create_coveragestyle(
"""

from .Calculation_gdal import raster_value
from .Style import coverage_style_xml

raster = raster_value(raster_path)
min_value = raster["min"]
Expand Down Expand Up @@ -1708,6 +1708,9 @@ def create_catagorized_featurestyle(
Inputs: column_name (based on which column style should be generated), workspace,
color_or_ramp (color should be provided in hex code or the color ramp name, geom_type(point, line, polygon), outline_color(hex_color))
"""

from .Style import catagorize_xml

catagorize_xml(column_name, column_distinct_values, color_ramp, geom_type)

style_xml = "<style><name>{}</name><filename>{}</filename></style>".format(
Expand Down Expand Up @@ -1782,6 +1785,9 @@ def create_outline_featurestyle(
The geometry type must be point, line or polygon
Inputs: style_name (name of the style file in geoserver), workspace, color (style color)
"""

from .Style import outline_only_xml

outline_only_xml(color, width, geom_type)

style_xml = "<style><name>{}</name><filename>{}</filename></style>".format(
Expand Down Expand Up @@ -1863,6 +1869,8 @@ def create_classified_featurestyle(
Inputs: column_name (based on which column style should be generated), workspace,
color_or_ramp (color should be provided in hex code or the color ramp name, geom_type(point, line, polygon), outline_color(hex_color))
"""

from .Style import classified_xml
classified_xml(
style_name,
column_name,
Expand Down
2 changes: 1 addition & 1 deletion geo/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from . import Calculation_gdal, Style

2 changes: 1 addition & 1 deletion geo/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

__author__ = "Tek Kshetri"
__email__ = "iamtekson@gmail.com"
__version__ = "2.9.0"
__version__ = "2.9.1"
2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
pygments
requests
seaborn
matplotlib
xmltodict
3 changes: 3 additions & 0 deletions requirements_style.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
matplotlib
seaborn
gdal
5 changes: 1 addition & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,8 @@
install_requires=[
"pygments",
"requests",
"seaborn",
"gdal",
"matplotlib",
"xmltodict",
],
extras_require={"dev": ["pytest", "black", "flake8", "sphinx>=1.7", "pre-commit"]},
extras_require={"dev": ["pytest", "black", "flake8", "sphinx>=1.7", "pre-commit"], 'style': ['matplotlib', 'seaborn', 'gdal'], 'all': ['matplotlib', 'seaborn', 'gdal']},
python_requires=">=3.6",
)

0 comments on commit b4b9a39

Please sign in to comment.