|
| 1 | +# SFEOS Viewer Quick Start |
| 2 | + |
| 3 | +The SFEOS Viewer is a Streamlit-based interactive web application for exploring STAC collections and items with map visualization. |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +Install the viewer dependencies: |
| 8 | + |
| 9 | +```bash |
| 10 | +pip install -e .[viewer] |
| 11 | +``` |
| 12 | + |
| 13 | +Or if you want all dev dependencies including the viewer: |
| 14 | + |
| 15 | +```bash |
| 16 | +pip install -e .[dev] |
| 17 | +``` |
| 18 | + |
| 19 | +## Usage |
| 20 | + |
| 21 | +### Basic Usage |
| 22 | + |
| 23 | +Launch the viewer with default settings (connects to http://localhost:8080): |
| 24 | + |
| 25 | +```bash |
| 26 | +sfeos-tools viewer |
| 27 | +``` |
| 28 | + |
| 29 | +### Custom STAC API |
| 30 | + |
| 31 | +Connect to a different STAC API: |
| 32 | + |
| 33 | +```bash |
| 34 | +sfeos-tools viewer --stac-url https://my-stac-api.com |
| 35 | +``` |
| 36 | + |
| 37 | +### Custom Port |
| 38 | + |
| 39 | +Run on a different port: |
| 40 | + |
| 41 | +```bash |
| 42 | +sfeos-tools viewer --port 8502 |
| 43 | +``` |
| 44 | + |
| 45 | +## Features |
| 46 | + |
| 47 | +- **Interactive Map**: Visualize STAC items on an OpenStreetMap-based map using Folium |
| 48 | +- **Collection Browser**: Select and explore different STAC collections |
| 49 | +- **Item Search**: Search for items with configurable limits |
| 50 | +- **Metadata Display**: View collection and item metadata in a clean interface |
| 51 | +- **Asset Preview**: Display imagery and other assets from STAC items |
| 52 | + - Automatic thumbnail detection |
| 53 | + - Full image viewer for JPEG, PNG, TIFF formats |
| 54 | + - Asset selector to browse all available assets |
| 55 | + - Support for COG (Cloud Optimized GeoTIFF) and other formats |
| 56 | +- **Responsive Layout**: Three-column layout with map, metadata, and asset preview |
| 57 | + |
| 58 | +## Architecture |
| 59 | + |
| 60 | +### Components |
| 61 | + |
| 62 | +1. **STACClient** (`viewer.py`): Simple HTTP client for STAC API interactions |
| 63 | + - `get_collections()`: Fetch all collections |
| 64 | + - `get_collection(id)`: Fetch a specific collection |
| 65 | + - `search_items()`: Search for items with optional filters |
| 66 | + - `get_item()`: Fetch a specific item with full details |
| 67 | + |
| 68 | +2. **Asset Management**: Extract and display STAC assets |
| 69 | + - `get_asset_urls()`: Extract all asset URLs from items |
| 70 | + - `get_thumbnail_url()`: Smart thumbnail detection |
| 71 | + - `load_image_from_url()`: Load and display images using Pillow |
| 72 | + |
| 73 | +3. **Map Visualization**: Folium-based map rendering |
| 74 | + - Supports Point and Polygon geometries |
| 75 | + - Interactive popups with item metadata |
| 76 | + - Auto-centering based on item locations |
| 77 | + |
| 78 | +4. **Streamlit UI**: Clean, responsive interface |
| 79 | + - Sidebar controls for collection selection and search |
| 80 | + - Main map view |
| 81 | + - Collection info and item selector |
| 82 | + - Asset preview panel with image display |
| 83 | + |
| 84 | +### File Structure |
| 85 | + |
| 86 | +``` |
| 87 | +sfeos_tools/ |
| 88 | +├── viewer.py # Main viewer module |
| 89 | +├── cli.py # CLI command integration |
| 90 | +tests/ |
| 91 | +├── test_viewer.py # Unit tests for viewer |
| 92 | +``` |
| 93 | + |
| 94 | +## Development |
| 95 | + |
| 96 | +### Running Tests |
| 97 | + |
| 98 | +```bash |
| 99 | +pytest tests/test_viewer.py -v |
| 100 | +``` |
| 101 | + |
| 102 | +### Modifying the Viewer |
| 103 | + |
| 104 | +The viewer is designed to be easily extensible: |
| 105 | + |
| 106 | +- **Add new filters**: Modify the sidebar section in `run_viewer()` |
| 107 | +- **Change map style**: Update the `folium.Map()` initialization in `create_map()` |
| 108 | +- **Add new visualizations**: Extend the Streamlit layout in `run_viewer()` |
| 109 | + |
| 110 | +### Testing Locally |
| 111 | + |
| 112 | +1. Start your STAC API (e.g., SFEOS instance) |
| 113 | +2. Load some test data using `sfeos-tools load-data` |
| 114 | +3. Launch the viewer: `sfeos-tools viewer` |
| 115 | +4. Open http://localhost:8501 in your browser |
| 116 | + |
| 117 | +## Troubleshooting |
| 118 | + |
| 119 | +### "Streamlit is not installed" |
| 120 | + |
| 121 | +Install the viewer dependencies: |
| 122 | +```bash |
| 123 | +pip install -e .[viewer] |
| 124 | +``` |
| 125 | + |
| 126 | +### "No collections found" |
| 127 | + |
| 128 | +- Verify your STAC API is running |
| 129 | +- Check the STAC URL is correct |
| 130 | +- Ensure the API is accessible from your machine |
| 131 | + |
| 132 | +### Port already in use |
| 133 | + |
| 134 | +Use a different port: |
| 135 | +```bash |
| 136 | +sfeos-tools viewer --port 8502 |
| 137 | +``` |
| 138 | + |
| 139 | +## Future Enhancements |
| 140 | + |
| 141 | +Potential improvements for the viewer: |
| 142 | + |
| 143 | +- [ ] Advanced search filters (date range, bbox drawing) |
| 144 | +- [x] Asset preview (thumbnails, imagery) ✅ |
| 145 | +- [ ] Export functionality (GeoJSON, CSV) |
| 146 | +- [ ] Bookmark/save searches |
| 147 | +- [ ] Multi-collection comparison |
| 148 | +- [ ] Custom basemap options |
| 149 | +- [ ] Item detail modal with full metadata |
| 150 | +- [ ] COG band visualization and manipulation |
| 151 | +- [ ] Image histogram and statistics |
| 152 | +- [ ] Side-by-side asset comparison |
0 commit comments