Easy to use functions to plot geospatial data on maps using staticmaps.
Project description
Landfall: Easy to use functions for plotting geographic data on static maps
What is it?
Landfall is a modern, well-tested Python package with easy-to-use functions for plotting geographic data on static maps. Built with type safety, comprehensive testing, and cross-platform compatibility in mind.
✨ Features
- 🗺️ Easy geospatial plotting - Plot points, polygons, lines, and circles on static maps
- 🎨 Smart color generation - Automatic distinct color generation for data visualization
- 📍 GeoJSON support - Plot industry-standard GeoJSON data directly
- 🐼 GeoPandas integration - Optional integration with GeoDataFrames and Shapely geometries
- 🔧 Type-safe - Full type annotations with mypy support
- 🧪 Well-tested - 182+ tests with comprehensive coverage across Python 3.8-3.13
- 🚀 Modern packaging - Built with modern
pyproject.tomlstandards - 🔄 Cross-platform - Works on Windows, macOS, and Linux
- 📦 Minimal dependencies - Only essential packages required
🆕 What's New in v0.4.0
Major feature expansion with 4 new plotting capabilities:
- 🛣️ Line/Polyline Plotting - Plot routes, paths, and linear features with
plot_line()andplot_lines() - ⭕ Circle/Buffer Plotting - Create coverage areas and buffer zones with
plot_circle()andplot_circles() - 📄 GeoJSON Support - Plot industry-standard GeoJSON data directly with
plot_geojson()andplot_geojson_file() - 🐼 GeoPandas Integration - Optional GeoDataFrame support with
plot_geodataframe(),plot_geometry(), andplot_geometries()
Plus enhanced Context class with new methods:
add_line(),add_lines()- Add lines to existing mapsadd_circle(),add_circles()- Add circles to existing maps
Installation for GeoPandas support:
pip install landfall[geo]
Requirements
- Python 3.8-3.13 (comprehensive version support)
- Pillow >=10.0.0 (image processing)
- py-staticmaps (map rendering)
- distinctipy (color generation)
Installation
From PyPI
pip install landfall
Development Installation
pip install -e .[dev]
With GeoPandas Support
pip install landfall[geo]
This installs the package in editable mode with development dependencies including:
pytest- Testing frameworkpytest-cov- Coverage reportingmypy- Type checkingflake8- Lintingtox- Multi-environment testing
GeoPandas extras include:
geopandas>=0.14.0- GeoDataFrame supportshapely>=2.0.0- Geometry operations
Quick Start
Basic Point Plotting
import landfall
# Plot points on a map
lats = [27.88, 27.92, 27.94]
lons = [-82.49, -82.49, -82.46]
landfall.plot_points(lats, lons)
Advanced Plotting with Colors
import landfall
# Plot points with distinct colors
lats = [27.88, 27.92, 27.94, 27.96]
lons = [-82.49, -82.49, -82.46, -82.44]
# Use distinct colors for each point
landfall.plot_points(lats, lons, colors="distinct")
# Or use custom colors
landfall.plot_points(lats, lons, colors=["red", "blue", "green", "yellow"])
Polygon Plotting
import landfall
# Define polygon coordinates
polygon = [
(27.88, -82.49),
(27.92, -82.49),
(27.94, -82.46),
(27.88, -82.46)
]
# Plot polygon with fill
landfall.plot_polygon(polygon, fill_color="blue", color="red")
Using the Enhanced Context
import landfall
# Create a context for complex maps
context = landfall.Context()
# Add multiple elements
context.add_points([27.88, 27.92], [-82.49, -82.46], colors="distinct")
context.add_polygon(polygon, fill_color="blue", color="red", width=2)
# Render the map
image = context.render_pillow(800, 600)
Line Plotting
import landfall
# Plot lines/routes on a map
lines = [
[(27.88, -82.49), (27.92, -82.46), (27.94, -82.44)], # Route 1
[(27.90, -82.50), (27.95, -82.45), (27.98, -82.42)] # Route 2
]
# Plot multiple lines with distinct colors
landfall.plot_lines(lines, colors="distinct", width=3)
# Plot single line
line = [(27.88, -82.49), (27.92, -82.46), (27.94, -82.44)]
landfall.plot_line(line, color="red", width=2)
Circle/Buffer Plotting
import landfall
# Plot circles for coverage areas
lats = [27.88, 27.92, 27.94]
lons = [-82.49, -82.46, -82.44]
radii = [1000, 2000, 1500] # meters
# Plot circles with fill colors
landfall.plot_circles(lats, lons, radii,
fill_colors="distinct",
radius_unit="meters")
# Plot single circle
landfall.plot_circle(27.88, -82.49, 1000,
fill_color="blue",
color="red",
radius_unit="meters")
GeoJSON Support
import landfall
# Plot GeoJSON data directly
geojson_data = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [-82.49, 27.88]
},
"properties": {
"name": "Location 1",
"marker-color": "red"
}
}
]
}
# Plot GeoJSON from dict
landfall.plot_geojson(geojson_data)
# Plot GeoJSON from file
landfall.plot_geojson_file("data.geojson")
GeoPandas Integration (Optional)
import landfall
import geopandas as gpd
from shapely.geometry import Point
# Create GeoDataFrame
data = {'name': ['A', 'B', 'C'], 'value': [10, 20, 30]}
geometry = [Point(-82.49, 27.88), Point(-82.46, 27.92), Point(-82.44, 27.96)]
gdf = gpd.GeoDataFrame(data, geometry=geometry)
# Plot GeoDataFrame directly
landfall.plot_geodataframe(gdf, color_column="value")
# Plot individual Shapely geometries
point = Point(-82.49, 27.88)
landfall.plot_geometry(point)
Using the Enhanced Context
import landfall
# Create a context for complex maps
context = landfall.Context()
# Add multiple elements
context.add_points([27.88, 27.92], [-82.49, -82.46], colors="distinct")
context.add_polygon(polygon, fill_color="blue", color="red", width=2)
context.add_lines(lines, colors="random", width=2)
context.add_circles([27.88], [-82.49], [1000], fill_color="yellow")
# Render the map
image = context.render_pillow(800, 600)
API Reference
Core Functions
plot_points(lats, lons, **kwargs)- Plot points on a mapplot_polygon(polygon, **kwargs)- Plot a single polygonplot_polygons(polygons, **kwargs)- Plot multiple polygonsplot_line(line, **kwargs)- Plot a single line/polylineplot_lines(lines, **kwargs)- Plot multiple lines/polylinesplot_circle(lat, lon, radius, **kwargs)- Plot a single circleplot_circles(lats, lons, radii, **kwargs)- Plot multiple circlesplot_geojson(geojson_data, **kwargs)- Plot GeoJSON dataplot_geojson_file(filepath, **kwargs)- Plot GeoJSON from filerandom_color(rng=None)- Generate a random colorContext()- Enhanced context for complex maps
GeoPandas Functions (Optional)
plot_geodataframe(gdf, **kwargs)- Plot GeoDataFrameplot_geometry(geometry, **kwargs)- Plot Shapely geometryplot_geometries(geometries, **kwargs)- Plot multiple geometries
Color Options
"random"- Generate random colors"distinct"- Generate visually distinct colors"wheel"- Generate colors from HSV color wheel- Custom color list:
["red", "blue", "green"] - RGB tuples:
[(255, 0, 0), (0, 255, 0)]
Development
Setup Development Environment
git clone https://github.com/eddiethedean/landfall.git
cd landfall
pip install -e .[dev]
Running Tests
# Run all tests
pytest
# Run with coverage
pytest --cov=landfall
# Run specific test categories
pytest tests/test_colors.py # Color-related tests
pytest tests/test_plotting.py # Plotting tests
pytest tests/test_comprehensive.py # Comprehensive tests
# Run tests excluding slow tests
pytest -m "not slow"
# Run tests across all Python versions
tox
Code Quality
# Linting
flake8 src tests
# Type checking
mypy src
# Formatting
ruff format src tests
# All quality checks
tox -e flake8,mypy
Multi-Version Testing
# Test across all supported Python versions (3.8-3.13)
tox
# Test specific Python versions
tox -e py38,py311,py313
Dependencies
- py-staticmaps - Static map image generation
- distinctipy - Visually distinct color generation
- Pillow - Python Imaging Library
Changelog
v0.3.6 (Latest)
- ✅ Full modernization - Migrated to modern
pyproject.tomlpackaging - ✅ Enhanced testing - 105+ tests with 80% coverage across Python 3.8-3.13
- ✅ Type safety - Complete type annotations with mypy support
- ✅ Bug fixes - Fixed critical color scaling bug in
distinctipyintegration - ✅ Cross-platform - Verified compatibility across Windows, macOS, and Linux
- ✅ Modern CI/CD - Updated GitHub Actions with pip caching and separate linting
- ✅ Compatibility patches - Automatic fixes for Pillow compatibility issues
Previous Versions
- v0.3.5 - Initial modernization and bug fixes
- v0.3.4 and earlier - Legacy versions
Contributing
We welcome contributions! Please see our development guidelines:
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make your changes with tests
- Run quality checks:
tox -e flake8,mypy - Run tests:
tox - Submit a pull request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
- 📖 Documentation: GitHub README
- 🐛 Issues: GitHub Issues
- 💬 Discussions: GitHub Discussions
Made with ❤️ for the geospatial Python community
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file landfall-0.4.1.tar.gz.
File metadata
- Download URL: landfall-0.4.1.tar.gz
- Upload date:
- Size: 30.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a0378d91eeda5afa6b8e972f5173ec385a0816a1f404be81fa5f6ffe8a705d4f
|
|
| MD5 |
ff07a676871219121fcbd5023928b63c
|
|
| BLAKE2b-256 |
36266a0def8ae0c4b4547ac8e6c2026546ac1cc4c392abf77c07d5f78d7056e9
|
File details
Details for the file landfall-0.4.1-py3-none-any.whl.
File metadata
- Download URL: landfall-0.4.1-py3-none-any.whl
- Upload date:
- Size: 21.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e8ac9550de2097af75a7cbda185400e593a81073492ee58b02fa4802de0e1bd
|
|
| MD5 |
3aef9b3ae654385640113f5994a4d3b0
|
|
| BLAKE2b-256 |
f2bebe097987fc9582424e5a050214da4430b2a90c3b74685b23b4d51d08e254
|