Skip to content

Commit

Permalink
MapLayout and pyshp optional dependency.
Browse files Browse the repository at this point in the history
  • Loading branch information
swainn committed Sep 15, 2023
1 parent ce2e6c7 commit 49d9960
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
5 changes: 5 additions & 0 deletions docs/tethys_sdk/layouts/map_layout.rst
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,11 @@ build_param_string

.. automethod:: tethys_layouts.views.map_layout.MapLayout.build_param_string

convert_geojson_to_shapefile
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. automethod:: tethys_layouts.views.map_layout.MapLayout.convert_geojson_to_shapefile

JavaScript API Documentation
============================

Expand Down
6 changes: 5 additions & 1 deletion docs/tutorials/google_earth_engine/part_2/file_upload.rst
Original file line number Diff line number Diff line change
Expand Up @@ -395,12 +395,16 @@ Now that the file is written to disk, use the built-in ``zipfile`` module to ver

In this step you will add the logic to validate that the file contained in the ZIP archive is a shapefile. You will use the ``pyshp`` library to do this, which will introduce a new dependency for the app.

1. Install ``pyshp`` library into your Tethys conda environment. Run the following command in the terminal with your Tethys environment activated:
1. Install ``pyshp`` library into your Tethys conda environment using conda or pip. Run the following command in the terminal with your Tethys environment activated:

.. code-block:: bash
# conda: conda-forge channel highly recommended
conda install -c conda-forge pyshp
# pip
pip install pyshp
2. Add ``pyshp`` as a new dependency in the ``install.yml``:

.. code-block:: yaml
Expand Down
2 changes: 2 additions & 0 deletions docs/tutorials/google_earth_engine/part_2/rest_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ Add ``djangorestframework`` to the ``install.yml`` file to ensure it is installe
packages:
- earthengine-api
- oauth2client
- geojson
- pyshp
- djangorestframework
pip:
Expand Down
14 changes: 14 additions & 0 deletions tethys_layouts/views/map_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,20 @@ def convert_geojson_to_shapefile(self, request, *args, **kwargs):
AJAX handler that converts GeoJSON data into a shapefile for download.
Credit to: https://github.com/TipsForGIS/geoJSONToShpFile/blob/master/geoJ.py
.. important::
This method requires the `pyshp` library to be installed. Starting with Tethys 5.0 or if you are using `microtethys`, you will need to install `django-json-widget` using conda or pip as follows:
.. code-block:: bash
# conda: conda-forge channel strongly recommended
conda install -c conda-forge pyshp
# pip
pip install pyshp
**Don't Forget**: If you end up using this method in your app, add `pyshp` as a requirement to your `install.yml`.
Args:
request(HttpRequest): The request.
Expand Down

0 comments on commit 49d9960

Please sign in to comment.