Source code for rapidtools.data_sources.google_aerial_image_extractor
# Copyright (c) 2025 The University of Washington
#
# This file is part of rapidtools.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors
# may be used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# You should have received a copy of the BSD 3-Clause License along with
# rapidtools. If not, see <http://www.opensource.org/licenses/>.
#
# Contributors:
# Barbaros Cetiner
#
# Last updated:
# 09-22-2026
"""
Keyless extraction of Google Maps satellite imagery tiles.
Google serves its satellite (``lyrs=s``) and hybrid (``lyrs=y``) layers as
256 px tiles from ``mt0``-``mt3.google.com`` in the standard XYZ scheme; no
API key is required. This mirrors the approach used by BRAILS++'s
``GoogleSatellite`` scraper while exposing the same interface as
:class:`~rapidtools.data_sources.BingAerialImageExtractor`.
Example:
>>> from rapidtools.data_sources import GoogleAerialImageExtractor
>>> with GoogleAerialImageExtractor('google_crops', zoom_level=20) as extractor:
... extractor.process_geojson(
... 'buildings.geojson', pad_to_square=True, resize_to=(640, 640)
... )
"""
from __future__ import annotations
from pathlib import Path
from typing import Any
from .tile_imagery_base import WebMercatorTileExtractor
GOOGLE_TILE_URL = 'https://mt{subdomain}.google.com/vt/lyrs={layer}&x={x}&y={y}&z={z}'
# Layers served by the Google tile endpoint that contain aerial imagery.
GOOGLE_TILE_LAYERS = {
's': 'satellite',
'y': 'hybrid (satellite + labels)',
}