Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make gdal dep optional #172

Merged
merged 7 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ permissions:
jobs:
deploy:

runs-on: ubuntu-latest
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

test-ubuntu:

runs-on: ubuntu-latest
runs-on: ubuntu-22.04

strategy:
matrix:
Expand Down
2 changes: 2 additions & 0 deletions docs/source/how_to_use.rst
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ Before uploading ``SLD`` file, please check the version of your sld file. By def
Creating and applying dynamic styles based on the raster coverages
------------------------------------------------------------------

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

It is used to create the style file for raster data. You can get the ``color_ramp`` name from `matplotlib colormaps <https://matplotlib.org/3.3.0/tutorials/colors/colormaps.html>`_. By default ``color_ramp='RdYlGn'`` (red to green color ramp).

.. code-block:: python
Expand Down
2 changes: 2 additions & 0 deletions geo/Calculation_gdal.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from osgeo import gdal # noqa
except ImportError:
import gdal # noqa
except ImportError:
raise ImportError("Package `gdal` is required to run this function. Install it with `pip install gdal`.")


def raster_value(path: str) -> dict:
Expand Down
4 changes: 3 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 .Calculation_gdal import raster_value
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 @@ -1611,6 +1610,9 @@ def create_coveragestyle(
This function will dynamically create the style file for raster.
Inputs: name of file, workspace, cmap_type (two options: values, range), ncolors: determines the number of class, min for minimum value of the raster, max for the max value of raster
"""

from .Calculation_gdal import raster_value

raster = raster_value(raster_path)
min_value = raster["min"]
max_value = raster["max"]
Expand Down
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__ = "[email protected]"
__version__ = "2.8.3"
__version__ = "2.9.0"
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
pygments
requests
seaborn
gdal
matplotlib
xmltodict
Loading