help@rskworld.in +91 93305 39277
RSK World
  • Home
  • Development
    • Web Development
    • Mobile Apps
    • Software
    • Games
    • Project
  • Technologies
    • Data Science
    • AI Development
    • Cloud Development
    • Blockchain
    • Cyber Security
    • Dev Tools
    • Testing Tools
  • Blog
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back to Project
RSK World
satellite-images
RSK World
satellite-images
Satellite Images Dataset - Land Cover Classification + Building Detection + Remote Sensing + Geospatial Analysis
satellite-images
  • __pycache__
  • data
  • visualizations
  • .gitignore780 B
  • ADVANCED_FEATURES.md7.2 KB
  • ATTRIBUTION.md1.5 KB
  • DATA_SUMMARY.md3.9 KB
  • DOWNLOAD_REAL_DATA_GUIDE.md3.4 KB
  • ERROR_FIXES_SUMMARY.md3.2 KB
  • GITHUB_RELEASE_INSTRUCTIONS.md4.9 KB
  • LICENSE1.2 KB
  • PROJECT_INFO.md3 KB
  • QUICK_DOWNLOAD_GUIDE.md2.1 KB
  • QUICK_START_ADVANCED.md2 KB
  • README.md8.1 KB
  • RELEASE_NOTES_v1.0.0.md7.1 KB
  • advanced_example.py11 KB
  • advanced_processing.py17.3 KB
  • advanced_visualization.py15.5 KB
  • batch_processing.py11.9 KB
  • batch_processor.py10.8 KB
  • check_errors.py6.9 KB
  • config.py1.1 KB
  • create_placeholder_image.py3.5 KB
  • create_sample_images.py5.3 KB
  • data_loader.py6 KB
  • download_real_images.py5 KB
  • download_real_satellite_data.py8.4 KB
  • download_with_landsatxplore.py4.6 KB
  • download_with_sentinelsat.py6 KB
  • enhanced_real_image_downloader.py17.8 KB
  • example_usage.py4.3 KB
  • generate_sample_data.py7.2 KB
  • get_real_satellite_data.py9.6 KB
  • index.html18.5 KB
  • ml_features.py11.8 KB
  • ml_integration.py13.6 KB
  • process_images.py7 KB
  • real_image_downloader.py15.7 KB
  • requirements.txt632 B
  • requirements_download.txt474 B
  • satellite-images.png2.6 MB
  • setup.py1.6 KB
  • visualize.py5.8 KB
enhanced_real_image_downloader.pyRELEASE_NOTES_v1.0.0.md
enhanced_real_image_downloader.py
Raw Download
Find: Go to:
#!/usr/bin/env python3
"""
Enhanced Real Satellite Image Downloader
Created by: RSK World
Website: https://rskworld.in
Email: help@rskworld.in
Phone: +91 93305 39277

Supports multiple data sources:
- Microsoft Planetary Computer (Sentinel-2, Landsat)
- USGS EarthExplorer (Landsat)
- Copernicus Hub (Sentinel-2)
- Google Earth Engine (multiple sources)
"""

import os
import sys
from pathlib import Path
from typing import Dict, List, Optional, Tuple
from datetime import datetime, timedelta
import json
import requests
from PIL import Image
import io
import numpy as np
import cv2


class EnhancedRealImageDownloader:
    """
    Enhanced downloader for real satellite images from multiple sources.
    Created by: RSK World (https://rskworld.in)
    """
    
    def __init__(self, output_dir: str = "data/images"):
        """
        Initialize the downloader.
        
        Args:
            output_dir: Directory to save downloaded images
        """
        self.output_dir = Path(output_dir)
        self.output_dir.mkdir(parents=True, exist_ok=True)
        self.downloaded_count = 0
    
    def download_from_planetary_computer(self, 
                                         locations: List[Dict],
                                         num_images: int = 10,
                                         date_start: Optional[datetime] = None,
                                         date_end: Optional[datetime] = None,
                                         max_cloud_cover: int = 30) -> List[str]:
        """
        Download images from Microsoft Planetary Computer.
        
        Args:
            locations: List of location dicts with 'bbox' and 'name'
            num_images: Number of images to download
            date_start: Start date for search
            date_end: End date for search
            max_cloud_cover: Maximum cloud cover percentage
            
        Returns:
            List of downloaded image paths
        """
        try:
            import pystac_client
            import planetary_computer
        except ImportError:
            print("ERROR: pystac-client and planetary-computer packages required.")
            print("Install with: pip install pystac-client planetary-computer")
            return []
        
        print("=" * 60)
        print("Downloading from Microsoft Planetary Computer")
        print("Created by: RSK World (https://rskworld.in)")
        print("=" * 60)
        
        if date_start is None:
            date_start = datetime(2023, 6, 1)
        if date_end is None:
            date_end = datetime(2023, 12, 31)
        
        downloaded_files = []
        
        try:
            # Open catalog
            catalog = pystac_client.Client.open(
                "https://planetarycomputer.microsoft.com/api/stac/v1",
                modifier=planetary_computer.sign_inplace,
            )
            
            for i in range(num_images):
                location = locations[i % len(locations)]
                
                try:
                    # Search for Sentinel-2 data
                    search = catalog.search(
                        collections=["sentinel-2-l2a"],
                        bbox=location["bbox"],
                        datetime=f"{date_start.strftime('%Y-%m-%d')}/{date_end.strftime('%Y-%m-%d')}",
                        query={"eo:cloud_cover": {"lt": max_cloud_cover}},
                        limit=10
                    )
                    
                    items = list(search.item_collection())
                    if items:
                        item = items[i % len(items)] if len(items) > i else items[0]
                        
                        # Try visual asset first
                        asset = item.assets.get("visual") or item.assets.get("rendered_preview")
                        
                        if asset:
                            href = planetary_computer.sign(asset.href)
                            
                            print(f"\n[{i+1}/{num_images}] Downloading from {location['name']}...")
                            print(f"  Date: {item.properties.get('datetime', 'N/A')}")
                            print(f"  Cloud cover: {item.properties.get('eo:cloud_cover', 'N/A')}%")
                            
                            try:
                                response = requests.get(href, timeout=60, stream=True)
                                
                                if response.status_code == 200:
                                    img_data = response.content
                                    img = Image.open(io.BytesIO(img_data))
                                    
                                    if img.mode != 'RGB':
                                        img = img.convert('RGB')
                                    
                                    # Resize to standard size
                                    if img.size != (512, 512):
                                        img = img.resize((512, 512), Image.Resampling.LANCZOS)
                                    
                                    # Save image
                                    output_file = self.output_dir / f"real_pc_{i+1:03d}.png"
                                    img.save(output_file, 'PNG')
                                    
                                    # Save metadata
                                    metadata = {
                                        'source': 'planetary_computer',
                                        'location': location['name'],
                                        'bbox': location['bbox'],
                                        'date': item.properties.get('datetime', ''),
                                        'cloud_cover': item.properties.get('eo:cloud_cover', 0),
                                        'download_date': datetime.now().isoformat()
                                    }
                                    
                                    metadata_file = self.output_dir / f"real_pc_{i+1:03d}_metadata.json"
                                    with open(metadata_file, 'w') as f:
                                        json.dump(metadata, f, indent=4)
                                    
                                    downloaded_files.append(str(output_file))
                                    self.downloaded_count += 1
                                    print(f"  [OK] Saved: {output_file}")
                                else:
                                    print(f"  [ERROR] HTTP {response.status_code}")
                            except Exception as e:
                                print(f"  [ERROR] {e}")
                        else:
                            print(f"  [SKIP] No visual asset available")
                    else:
                        print(f"  [SKIP] No images found for {location['name']}")
                
                except Exception as e:
                    print(f"  [ERROR] {e}")
                    continue
            
            print(f"\nDownloaded {len(downloaded_files)} images from Planetary Computer")
            return downloaded_files
        
        except Exception as e:
            print(f"ERROR: {e}")
            return []
    
    def download_from_usgs(self, username: str, password: str,
                          latitude: float = 37.7749,
                          longitude: float = -122.4194,
                          start_date: str = '2023-01-01',
                          end_date: str = '2023-12-31',
                          max_cloud_cover: int = 10,
                          num_images: int = 5) -> List[str]:
        """
        Download images from USGS EarthExplorer (Landsat).
        
        Args:
            username: USGS username
            password: USGS password
            latitude: Latitude
            longitude: Longitude
            start_date: Start date (YYYY-MM-DD)
            end_date: End date (YYYY-MM-DD)
            max_cloud_cover: Max cloud cover percentage
            num_images: Number of images to download
            
        Returns:
            List of downloaded image paths
        """
        try:
            from landsatxplore.api import API
        except ImportError:
            print("ERROR: landsatxplore package required.")
            print("Install with: pip install landsatxplore")
            return []
        
        print("=" * 60)
        print("Downloading from USGS EarthExplorer (Landsat)")
        print("Created by: RSK World (https://rskworld.in)")
        print("=" * 60)
        
        downloaded_files = []
        
        try:
            api = API(username, password)
            
            print(f"Searching for Landsat scenes near ({latitude}, {longitude})...")
            
            scenes = api.search(
                dataset='landsat_ot_c2_l2',
                latitude=latitude,
                longitude=longitude,
                start_date=start_date,
                end_date=end_date,
                max_cloud_cover=max_cloud_cover,
                max_results=num_images
            )
            
            print(f"Found {len(scenes)} scenes")
            
            if not scenes:
                print("No scenes found.")
                return []
            
            for i, scene in enumerate(scenes[:num_images], 1):
                print(f"\n[{i}/{min(num_images, len(scenes))}] Downloading: {scene['display_id']}")
                print(f"  Date: {scene['acquisition_date']}")
                print(f"  Cloud cover: {scene['cloud_cover']}%")
                
                try:
                    # Download to temp directory first
                    temp_dir = self.output_dir / "temp"
                    temp_dir.mkdir(exist_ok=True)
                    
                    api.download(scene['entity_id'], output_dir=str(temp_dir))
                    
                    # Process downloaded files (Landsat downloads are in tar.gz format)
                    # This is a simplified version - actual processing would extract and convert
                    print(f"  [OK] Downloaded (requires extraction)")
                    downloaded_files.append(f"temp/{scene['entity_id']}")
                
                except Exception as e:
                    print(f"  [ERROR] {e}")
            
            api.logout()
            print(f"\nDownloaded {len(downloaded_files)} scenes from USGS")
            return downloaded_files
        
        except Exception as e:
            print(f"ERROR: {e}")
            return []
    
    def download_from_copernicus(self, username: str, password: str,
                                 bbox: List[float],
                                 start_date: str = '20230601',
                                 end_date: str = '20230630',
                                 max_cloud_cover: int = 10,
                                 num_images: int = 5) -> List[str]:
        """
        Download images from Copernicus Hub (Sentinel-2).
        
        Args:
            username: Copernicus username
            password: Copernicus password
            bbox: Bounding box [min_lon, min_lat, max_lon, max_lat]
            start_date: Start date (YYYYMMDD)
            end_date: End date (YYYYMMDD)
            max_cloud_cover: Max cloud cover percentage
            num_images: Number of images to download
            
        Returns:
            List of downloaded image paths
        """
        try:
            from sentinelsat import SentinelAPI, geojson_to_wkt
            import json
        except ImportError:
            print("ERROR: sentinelsat package required.")
            print("Install with: pip install sentinelsat")
            return []
        
        print("=" * 60)
        print("Downloading from Copernicus Hub (Sentinel-2)")
        print("Created by: RSK World (https://rskworld.in)")
        print("=" * 60)
        
        downloaded_files = []
        
        try:
            api = SentinelAPI(username, password, 'https://scihub.copernicus.eu/dhus')
            
            # Create area WKT from bbox
            geojson = {
                "type": "FeatureCollection",
                "features": [{
                    "type": "Feature",
                    "geometry": {
                        "type": "Polygon",
                        "coordinates": [[
                            [bbox[0], bbox[1]],
                            [bbox[2], bbox[1]],
                            [bbox[2], bbox[3]],
                            [bbox[0], bbox[3]],
                            [bbox[0], bbox[1]]
                        ]]
                    }
                }]
            }
            area_wkt = geojson_to_wkt(geojson)
            
            print(f"Searching for Sentinel-2 products...")
            
            products = api.query(
                area=area_wkt,
                date=(start_date, end_date),
                platformname='Sentinel-2',
                processinglevel='Level-2A',
                cloudcoverpercentage=(0, max_cloud_cover)
            )
            
            print(f"Found {len(products)} products")
            
            if not products:
                print("No products found.")
                return []
            
            for i, (product_id, product_info) in enumerate(list(products.items())[:num_images], 1):
                print(f"\n[{i}/{min(num_images, len(products))}] Downloading: {product_info['title']}")
                print(f"  Date: {product_info['beginposition']}")
                print(f"  Cloud cover: {product_info['cloudcoverpercentage']}%")
                
                try:
                    api.download(product_id, directory_path=str(self.output_dir))
                    print(f"  [OK] Downloaded")
                    downloaded_files.append(product_id)
                
                except Exception as e:
                    print(f"  [ERROR] {e}")
            
            print(f"\nDownloaded {len(downloaded_files)} products from Copernicus")
            return downloaded_files
        
        except Exception as e:
            print(f"ERROR: {e}")
            return []
    
    def download_sample_real_images(self, num_images: int = 10) -> List[str]:
        """
        Download sample real images using Planetary Computer (no credentials needed).
        
        Args:
            num_images: Number of images to download
            
        Returns:
            List of downloaded image paths
        """
        # Predefined locations for variety
        locations = [
            {"bbox": [-122.5, 37.5, -122.0, 38.0], "name": "San Francisco"},
            {"bbox": [-74.0, 40.6, -73.9, 40.7], "name": "New York"},
            {"bbox": [2.2, 48.8, 2.4, 48.9], "name": "Paris"},
            {"bbox": [139.6, 35.6, 139.8, 35.7], "name": "Tokyo"},
            {"bbox": [-0.2, 51.4, 0.0, 51.5], "name": "London"},
            {"bbox": [151.2, -33.8, 151.3, -33.7], "name": "Sydney"},
            {"bbox": [-46.6, -23.5, -46.5, -23.4], "name": "Sao Paulo"},
            {"bbox": [103.8, 1.3, 103.9, 1.4], "name": "Singapore"},
        ]
        
        return self.download_from_planetary_computer(
            locations=locations,
            num_images=num_images
        )
    
    def get_download_stats(self) -> Dict:
        """
        Get download statistics.
        
        Returns:
            Dictionary with statistics
        """
        return {
            'total_downloaded': self.downloaded_count,
            'output_directory': str(self.output_dir),
            'files_in_directory': len(list(self.output_dir.glob("*.png")))
        }


def main():
    """
    Main function for downloading real images.
    Created by: RSK World (https://rskworld.in)
    """
    print("=" * 60)
    print("Enhanced Real Satellite Image Downloader")
    print("Created by: RSK World (https://rskworld.in)")
    print("=" * 60)
    print()
    
    downloader = EnhancedRealImageDownloader()
    
    # Option 1: Download from Planetary Computer (no credentials needed)
    print("Option 1: Download from Planetary Computer (Recommended - No credentials)")
    print("-" * 60)
    try:
        files = downloader.download_sample_real_images(num_images=10)
        print(f"\nSuccessfully downloaded {len(files)} images!")
    except Exception as e:
        print(f"Error: {e}")
        print("\nMake sure to install: pip install pystac-client planetary-computer requests pillow")
    
    # Option 2: Download from USGS (requires credentials)
    print("\n" + "=" * 60)
    print("Option 2: Download from USGS (Requires credentials)")
    print("-" * 60)
    username = os.getenv('USGS_USERNAME')
    password = os.getenv('USGS_PASSWORD')
    
    if username and password:
        try:
            files = downloader.download_from_usgs(
                username=username,
                password=password,
                num_images=3
            )
            print(f"\nSuccessfully downloaded {len(files)} images from USGS!")
        except Exception as e:
            print(f"Error: {e}")
    else:
        print("USGS_USERNAME and USGS_PASSWORD environment variables not set.")
        print("Skipping USGS download.")
    
    # Print statistics
    print("\n" + "=" * 60)
    stats = downloader.get_download_stats()
    print("Download Statistics:")
    print(f"  Total downloaded: {stats['total_downloaded']}")
    print(f"  Files in directory: {stats['files_in_directory']}")
    print(f"  Output directory: {stats['output_directory']}")
    print("=" * 60)


if __name__ == "__main__":
    main()

452 lines•17.8 KB
python
RELEASE_NOTES_v1.0.0.md
Raw Download

RELEASE_NOTES_v1.0.0.md

# Release Notes - v1.0.0

## Satellite Image Dataset - Initial Release

**Release Date:** January 2025
**Version:** 1.0.0
**Created by:** RSK World (https://rskworld.in)

---

## 🎉 What's New

This is the initial release of the Satellite Image Dataset project with comprehensive features for satellite image processing, machine learning, and analysis.

### ✨ Core Features

- **High-Resolution Images**: Support for PNG, TIFF, and GeoTIFF formats
- **Land Cover Classification**: JSON-based labels with multiple land cover classes
- **Building Detection**: Automated building detection with bounding boxes and confidence scores
- **Geospatial Metadata**: Complete metadata including CRS, bounds, resolution, and acquisition dates
- **Data Loading**: Easy-to-use data loader for images, labels, and metadata

### 🚀 Advanced Features

#### 1. Advanced Image Processing (`advanced_processing.py`)
- **Edge Detection**: Canny, Sobel, Laplacian, and Scharr methods
- **Image Segmentation**: Watershed, SLIC, Felzenszwalb, and Quickshift algorithms
- **Feature Extraction**:
- HOG (Histogram of Oriented Gradients)
- LBP (Local Binary Pattern)
- GLCM (Gray-Level Co-occurrence Matrix)
- **Image Enhancement**: CLAHE, histogram equalization, gamma correction, unsharp masking
- **Noise Reduction**: Gaussian, bilateral, median, and non-local means filtering
- **Histogram Analysis**: Comprehensive statistical analysis

#### 2. Machine Learning Integration (`ml_integration.py`)
- **Feature Extraction for ML**: Patch-based feature extraction for training
- **Land Cover Classification**: Random Forest classifier with training utilities
- **Building Detection**: Simple building detection using image processing
- **Change Detection**: Compare two images and detect changes over time
- **NDVI Extraction**: Normalized Difference Vegetation Index calculation
- **Training Dataset Creation**: Utilities for creating ML-ready datasets

#### 3. Real Image Downloading (`enhanced_real_image_downloader.py`)
- **Planetary Computer**: Download Sentinel-2 images (no credentials needed)
- **USGS EarthExplorer**: Download Landsat data (requires free account)
- **Copernicus Hub**: Download Sentinel-2 data (requires free account)
- **Multiple Locations**: Predefined locations worldwide
- **Automatic Metadata**: Metadata extraction and saving

#### 4. Advanced Visualization (`advanced_visualization.py`)
- **Statistical Visualization**: Comprehensive statistics dashboards
- **3D Surface Plots**: 3D visualization of image surfaces
- **Comparison Views**: Side-by-side image comparison
- **Time Series Visualization**: Visualize images over time
- **Overlay Visualization**: Buildings and regions overlaid on images
- **Interactive Dashboards**: Comprehensive data dashboards

#### 5. Batch Processing (`batch_processing.py`)
- **Parallel Processing**: ThreadPoolExecutor for efficient batch processing
- **Image Augmentation**:
- Horizontal/vertical flipping
- Rotation
- Brightness/contrast adjustment
- Noise addition
- Cropping and scaling
- **Export Utilities**: NumPy export, metadata export, manifest creation

---

## 📦 Installation

```bash
# Install all required packages
pip install -r requirements.txt

# For real image downloading (optional)
pip install pystac-client planetary-computer
```

## 🚀 Quick Start

```python
from data_loader import SatelliteDatasetLoader
from advanced_processing import AdvancedImageProcessor
from ml_integration import SatelliteMLProcessor

# Load data
loader = SatelliteDatasetLoader()
image, labels = loader.load_image_pair("sample_001")

# Advanced processing
processor = AdvancedImageProcessor()
edges = processor.detect_edges(image, method='canny')
features = processor.extract_all_features(image)

# ML processing
ml = SatelliteMLProcessor()
buildings = ml.detect_buildings_simple(image)
ndvi = ml.extract_ndvi(image)
```

## 📚 Documentation

- **README.md**: Complete project documentation
- **ADVANCED_FEATURES.md**: Detailed advanced features guide
- **QUICK_START_ADVANCED.md**: Quick start guide
- **ERROR_FIXES_SUMMARY.md**: Troubleshooting guide
- **DOWNLOAD_REAL_DATA_GUIDE.md**: Real data download instructions

## 🛠️ Files Included

### Core Modules
- `data_loader.py` - Dataset loading utilities
- `process_images.py` - Basic image processing
- `visualize.py` - Basic visualization
- `config.py` - Configuration settings

### Advanced Modules
- `advanced_processing.py` - Advanced image processing
- `ml_integration.py` - Machine learning integration
- `enhanced_real_image_downloader.py` - Real image downloading
- `advanced_visualization.py` - Advanced visualization
- `batch_processing.py` - Batch processing and augmentation

### Utilities
- `advanced_example.py` - Comprehensive example demonstrating all features
- `check_errors.py` - Error checking and validation script
- `example_usage.py` - Basic usage examples

### Documentation
- `README.md` - Main documentation
- `ADVANCED_FEATURES.md` - Advanced features documentation
- `QUICK_START_ADVANCED.md` - Quick start guide
- `ERROR_FIXES_SUMMARY.md` - Error fixes summary
- `DOWNLOAD_REAL_DATA_GUIDE.md` - Download guide

## 📋 Requirements

### Core Dependencies
- Python 3.7+
- numpy >= 1.21.0
- opencv-python >= 4.5.0
- matplotlib >= 3.4.0
- scikit-image >= 0.18.0
- scikit-learn >= 1.0.0
- scipy >= 1.7.0
- seaborn >= 0.11.0
- rasterio >= 1.2.0
- pillow >= 8.3.0
- tqdm >= 4.62.0

### Optional Dependencies
- pystac-client (for Planetary Computer)
- planetary-computer (for real image downloading)
- landsatxplore (for USGS downloads)
- sentinelsat (for Copernicus downloads)

## 🎯 Use Cases

1. **Remote Sensing**: Analyze land use and land cover changes
2. **Urban Planning**: Monitor urban growth and development
3. **Agriculture Monitoring**: Track crop health and yield estimation
4. **Environmental Monitoring**: Detect deforestation, water bodies, etc.
5. **Disaster Management**: Assess damage and plan recovery
6. **Machine Learning Research**: Train models for classification and detection
7. **Geospatial Analysis**: Advanced feature extraction and analysis

## 🔧 Error Checking

Run the error checker to verify your installation:

```bash
python check_errors.py
```

## 📝 Examples

Run the comprehensive example:

```bash
python advanced_example.py
```

## 🌐 Resources

- **Website**: https://rskworld.in
- **Email**: help@rskworld.in
- **Phone**: +91 93305 39277
- **GitHub**: https://github.com/rskworld/satellite-images

## 📄 License

Please refer to the LICENSE file included with the dataset.

## 🙏 Acknowledgments

This dataset is created and maintained by RSK World. For more free programming resources and source code, visit [rskworld.in](https://rskworld.in).

---

**Full Changelog**: This is the initial release with all core and advanced features.

**Next Steps**:
- Try the examples: `python advanced_example.py`
- Check installation: `python check_errors.py`
- Read the documentation: `README.md`

---

*Created by RSK World - https://rskworld.in*

About RSK World

Founded by Molla Samser, with Designer & Tester Rima Khatun, RSK World is your one-stop destination for free programming resources, source code, and development tools.

Founder: Molla Samser
Designer & Tester: Rima Khatun

Development

  • Game Development
  • Web Development
  • Mobile Development
  • AI Development
  • Development Tools

Legal

  • Terms & Conditions
  • Privacy Policy
  • Disclaimer

Contact Info

Nutanhat, Mongolkote
Purba Burdwan, West Bengal
India, 713147

+91 93305 39277

hello@rskworld.in
support@rskworld.in

© 2026 RSK World. All rights reserved.

Content used for educational purposes only. View Disclaimer