Skip to content

Commit

Permalink
Merge branch 'master' into padding-tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
giswqs authored Feb 2, 2025
2 parents 49498ba + 096deff commit 6d5b9b1
Show file tree
Hide file tree
Showing 14 changed files with 2,884 additions and 1,856 deletions.
42 changes: 0 additions & 42 deletions .github/workflows/py313.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]

env:
USE_MKDOCS: ${{ secrets.USE_MKDOCS }}
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repos:
- id: black-jupyter

- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
rev: v2.4.0
hooks:
- id: codespell
args:
Expand Down
26 changes: 8 additions & 18 deletions geemap/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import urllib.request
import warnings
import zipfile
import importlib.resources

import ee
import ipywidgets as widgets
Expand Down Expand Up @@ -3454,12 +3455,11 @@ def create_colorbar(
import decimal

# import io
import pkg_resources
from colour import Color
from PIL import Image, ImageDraw, ImageFont

warnings.simplefilter("ignore")
pkg_dir = os.path.dirname(pkg_resources.resource_filename("geemap", "geemap.py"))
pkg_dir = str(importlib.resources.files("geemap").joinpath("geemap.py").parent)

if out_file is None:
filename = "colorbar_" + random_string() + ".png"
Expand Down Expand Up @@ -4120,11 +4120,9 @@ def ee_api_to_csv(outfile=None, timeout=300, proxies=None):
timeout (int, optional): Timeout in seconds. Defaults to 300.
proxies (dict, optional): Proxy settings. Defaults to None.
"""
import pkg_resources

from bs4 import BeautifulSoup

pkg_dir = os.path.dirname(pkg_resources.resource_filename("geemap", "geemap.py"))
pkg_dir = str(importlib.resources.files("geemap").joinpath("geemap.py").parent)
data_dir = os.path.join(pkg_dir, "data")
template_dir = os.path.join(data_dir, "template")
csv_file = os.path.join(template_dir, "ee_api_docs.csv")
Expand Down Expand Up @@ -4240,9 +4238,7 @@ def read_api_csv():
"""
import copy

import pkg_resources

pkg_dir = os.path.dirname(pkg_resources.resource_filename("geemap", "geemap.py"))
pkg_dir = str(importlib.resources.files("geemap").joinpath("geemap.py").parent)
data_dir = os.path.join(pkg_dir, "data")
template_dir = os.path.join(data_dir, "template")
csv_file = os.path.join(template_dir, "ee_api_docs.csv")
Expand Down Expand Up @@ -5129,9 +5125,8 @@ def vis_to_qml(ee_class_table, out_qml):
ee_class_table (str): An Earth Engine class table with triple quotes.
out_qml (str): File path to the output QGIS Layer Style (.qml).
"""
import pkg_resources

pkg_dir = os.path.dirname(pkg_resources.resource_filename("geemap", "geemap.py"))
pkg_dir = str(importlib.resources.files("geemap").joinpath("geemap.py").parent)
data_dir = os.path.join(pkg_dir, "data")
template_dir = os.path.join(data_dir, "template")
qml_template = os.path.join(template_dir, "NLCD.qml")
Expand Down Expand Up @@ -5178,9 +5173,7 @@ def create_nlcd_qml(out_qml):
Args:
out_qml (str): File path to the output qml.
"""
import pkg_resources

pkg_dir = os.path.dirname(pkg_resources.resource_filename("geemap", "geemap.py"))
pkg_dir = str(importlib.resources.files("geemap").joinpath("geemap.py").parent)
data_dir = os.path.join(pkg_dir, "data")
template_dir = os.path.join(data_dir, "template")
qml_template = os.path.join(template_dir, "NLCD.qml")
Expand Down Expand Up @@ -10012,9 +10005,7 @@ def get_census_dict(reset=False):
Returns:
dict: A dictionary of Census data.
"""
import pkg_resources

pkg_dir = os.path.dirname(pkg_resources.resource_filename("geemap", "geemap.py"))
pkg_dir = str(importlib.resources.files("geemap").joinpath("geemap.py").parent)
census_data = os.path.join(pkg_dir, "data/census_data.json")

if reset:
Expand Down Expand Up @@ -13729,10 +13720,9 @@ def create_legend(
str: The HTML code of the legend.
"""

import pkg_resources
from .legends import builtin_legends

pkg_dir = os.path.dirname(pkg_resources.resource_filename("geemap", "geemap.py"))
pkg_dir = str(importlib.resources.files("geemap").joinpath("geemap.py").parent)
legend_template = os.path.join(pkg_dir, "data/template/legend_style.html")

if draggable:
Expand Down
4 changes: 2 additions & 2 deletions geemap/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from pathlib import Path

import ipywidgets as widgets
import pkg_resources
import importlib.resources
from box import Box
from IPython.display import display

Expand All @@ -25,7 +25,7 @@ def get_data_csv() -> str:
Returns:
str: File path to the CSV file.
"""
pkg_dir = os.path.dirname(pkg_resources.resource_filename("geemap", "geemap.py"))
pkg_dir = str(importlib.resources.files("geemap").joinpath("geemap.py").parent)
template_dir = os.path.join(pkg_dir, "data/template")
data_csv = os.path.join(template_dir, "ee_data_catalog.csv")
return data_csv
Expand Down
11 changes: 5 additions & 6 deletions geemap/deck.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ def add_layer(self, layer, layer_name=None, **kwargs):
Args:
layer (pydeck.Layer): A pydeck Layer object.
layer_name (str, optional): Sets the layer 'id' for the pydeck Layer object.
**kwargs (Any): Additional keyword arguments for the pydeck Layer object.
"""

try:
Expand All @@ -94,23 +96,20 @@ def add_layer(self, layer, layer_name=None, **kwargs):
"resourceUri": "https://cdn.jsdelivr.net/gh/giswqs/pydeck_myTileLayer@master/dist/bundle.js",
}
]
layer = pdk.Layer("MyTileLayer", layer, id=layer_name)
layer = pdk.Layer("MyTileLayer", layer, id=layer_name, **kwargs)

self.layers.append(layer)
except Exception as e:
raise Exception(e)

def add_ee_layer(
self, ee_object, vis_params={}, name=None, shown=True, opacity=1.0, **kwargs
):
def add_ee_layer(self, ee_object, vis_params={}, name=None, **kwargs):
"""Adds a given EE object to the map as a layer.
Args:
ee_object (Collection|Feature|Image|MapId): The object to add to the map.
vis_params (dict, optional): The visualization parameters. Defaults to {}.
name (str, optional): The name of the layer. Defaults to 'Layer N'.
shown (bool, optional): A flag indicating whether the layer should be on by default. Defaults to True.
opacity (float, optional): The layer's opacity represented as a number between 0 and 1. Defaults to 1.
**kwargs (Any): Additional keyword arguments for the pydeck Layer object.
"""
import ee
from box import Box
Expand Down
4 changes: 2 additions & 2 deletions geemap/examples/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import box
import os
import pkg_resources
import importlib.resources

_pkg_dir = os.path.dirname(pkg_resources.resource_filename("geemap", "geemap.py"))
_pkg_dir = str(importlib.resources.files("geemap").joinpath("geemap.py").parent)
_datasets_path = os.path.join(_pkg_dir, "examples/datasets.txt")
_baseurl = (
"https://raw.githubusercontent.com/gee-community/geemap/master/examples/data/"
Expand Down
2 changes: 0 additions & 2 deletions geemap/legends.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,6 @@ def ee_table_to_legend(in_table, out_file):
in_table (str): The input file path (*.txt) to the Earth Engine color table.
out_file (str): The output file path (*.txt) to the legend dictionary.
"""
# pkg_dir = os.path.dirname(pkg_resources.resource_filename("geemap", "geemap.py"))
# ee_legend_table = os.path.join(pkg_dir, "data/template/ee_legend_table.txt")

if not os.path.exists(in_table):
print("The class table does not exist.")
Expand Down
6 changes: 3 additions & 3 deletions geemap/map_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1436,10 +1436,10 @@ def _select_dataset(self, dataset_title):

def get_ee_example(self, asset_id):
try:
import pkg_resources
import importlib.resources

pkg_dir = os.path.dirname(
pkg_resources.resource_filename("geemap", "geemap.py")
pkg_dir = str(
importlib.resources.files("geemap").joinpath("geemap.py").parent
)
with open(os.path.join(pkg_dir, "data/gee_f.json"), encoding="utf-8") as f:
functions = json.load(f)
Expand Down
6 changes: 2 additions & 4 deletions geemap/maplibregl.py
Original file line number Diff line number Diff line change
Expand Up @@ -2468,12 +2468,10 @@ def add_legend(
Returns:
None
"""
import pkg_resources
import importlib.resources
from .legends import builtin_legends

pkg_dir = os.path.dirname(
pkg_resources.resource_filename("geemap", "geemap.py")
)
pkg_dir = str(importlib.resources.files("geemap").joinpath("geemap.py").parent)
legend_template = os.path.join(pkg_dir, "data/template/legend.html")

if not os.path.exists(legend_template):
Expand Down
5 changes: 3 additions & 2 deletions geemap/timelapse.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,12 @@ def add_text_to_gif(
# import io
import warnings

import pkg_resources
import importlib.resources
from PIL import Image, ImageDraw, ImageFont, ImageSequence

warnings.simplefilter("ignore")
pkg_dir = os.path.dirname(pkg_resources.resource_filename("geemap", "geemap.py"))

pkg_dir = str(importlib.resources.files("geemap").joinpath("geemap.py").parent)
default_font = os.path.join(pkg_dir, "data/fonts/arial.ttf")

in_gif = os.path.abspath(in_gif)
Expand Down
4 changes: 2 additions & 2 deletions geemap/toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -1573,9 +1573,9 @@ def set_properties(_, geometry):

def get_tools_dict():
import pandas as pd
import pkg_resources
import importlib.resources

pkg_dir = os.path.dirname(pkg_resources.resource_filename("geemap", "geemap.py"))
pkg_dir = str(importlib.resources.files("geemap").joinpath("geemap.py").parent)
toolbox_csv = os.path.join(pkg_dir, "data/template/toolbox.csv")

df = pd.read_csv(toolbox_csv).set_index("index")
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dependencies = [
"bqplot",
"colour",
"earthengine-api>=1.0.0",
"eerepr>=0.0.4",
"eerepr>=0.0.5",
"folium>=0.17.0",
"geocoder",
"ipyevents",
Expand Down
Loading

0 comments on commit 6d5b9b1

Please sign in to comment.