# GeoTIFF to MBTiles (`madrasco/geotiff-to-mbtiles`) Actor

Convert one small RGB or RGBA GeoTIFF into raster MBTiles, with a PNG preview and a JSON report. Supports north-up WGS84, Web Mercator and WGS84 UTM images within fixed file and tile limits.

- **URL**: https://apify.com/madrasco/geotiff-to-mbtiles.md
- **Developed by:** [Jack Valmadre](https://apify.com/madrasco) (community)
- **Categories:** Developer tools
- **Security:** Limited permissions
- **Stats:** 2 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.50 / converted map

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## GeoTIFF to MBTiles

Convert one small, georeferenced RGB or RGBA GeoTIFF into a raster MBTiles file on Apify. Choose the zoom range and download the map, a PNG preview and a conversion report.

Use it for preparing imagery for a workflow that accepts raster MBTiles. The output uses Web Mercator (EPSG:3857), 256 × 256 PNG tiles and TMS tile rows. Reprojection uses nearest-neighbour resampling, which can look blocky when enlarged.

### What you get

- **MAP.mbtiles:** a SQLite raster tile archive with bounds and zoom metadata.
- **PREVIEW.png:** a downsampled view of the highest-zoom tiles, including transparent padding outside the image.
- **OUTPUT:** a JSON report with completion status, source (`bundled example` or `uploaded record`), dimensions and CRS, geographic bounds, zoom range, tile count, output size and SHA-256 hash. The same report appears in the dataset.

The actor reopens each completed archive through GDAL's MBTiles driver before returning it. It does not certify positional accuracy or compatibility with a particular map viewer.

### Supported images and limits

This version accepts standalone, north-up TIFFs with internal georeferencing and explicitly labelled 8-bit red, green and blue bands, plus an optional alpha band. Supported source coordinate systems are EPSG:4326, EPSG:3857 and WGS84 UTM zones (EPSG:32601–32660 and EPSG:32701–32760).

Each run processes one file, with these limits:

- Input: **32 MiB** and **16 million source pixels**.
- Zooms: integers from **0 to 14**, including every level in the chosen range.
- Output: at most **500 tiles** and **128 MiB**.
- Conversion worker: stops after roughly **two minutes** if conversion is unfinished. Uploading and storing output also take time.

The complete extent must fit between ±180° longitude and approximately ±85.05° latitude. Antimeridian-crossing extents are refused. The actor does not clip the image to fit these limits.

Elevation, single-band or palette images, scientific multiband data, rotated geotransforms, missing CRS and other coordinate systems are unsupported. There is no colour balancing, smooth resampling, vector conversion or map hosting. Use a full GIS or tiling tool when you need those controls.

### Price and example

A successful conversion of your own file costs **US$0.50**, charged once after the map, preview and report are saved. The bundled example, refused inputs and failed conversions have no conversion fee.

Apify also charges **US$0.00005 per run start at the default 1 GB memory setting**, including example, refused and failed runs. Higher memory settings increase the start fee. Running this actor has no additional platform usage charge. Storage or downloads you use separately through your Apify account may have their own charges.

To try the bundled GeoTIFF, leave **Try the bundled CC0 example** on and leave **Uploaded TIFF store** empty. Its report identifies the source as `bundled example`. Selecting a store while the example is on refuses the run and asks you to turn the example off.

### Run a conversion

1. Upload your TIFF as a binary record in an Apify key-value store. Use the content type `image/tiff` or `application/octet-stream`, rather than text or JSON. Apify documents the [Store record API](https://docs.apify.com/api/v2/key-value-store-record-put).
2. Turn **Try the bundled CC0 example** off. Select your store in **Uploaded TIFF store** and enter the TIFF record key, such as `image.tif`. The actor needs read access to the selected store.
3. Confirm you have the rights to process the image, which must contain no personal information. Set minimum and maximum zoom, then start the run.
4. Read **OUTPUT**. For your file, its source is `uploaded record`. Download **MAP.mbtiles** and **PREVIEW.png** only when its status is `success`.

Example input:

```json
{
  "useDemo": false,
  "inputStoreId": "YOUR_STORE_ID",
  "recordKey": "image.tif",
  "rightsConfirmed": true,
  "minZoom": 5,
  "maxZoom": 8
}
```

Set the run's maximum charge to at least **US$0.51** to convert your own file. A lower limit refuses the conversion; you pay only the Apify start charge.

A completed Apify run can still report `refused` or `error`: the report is the conversion result. A refusal includes a reason, and no completed map or preview is returned. If the requested extent exceeds 500 tiles, reduce maximum zoom or raise minimum zoom.

### Data and support

Your TIFF is processed on Apify, and the map, preview and report are saved in the run's Apify storage. Manage retention and access through your Apify account. The actor does not fetch imagery from external URLs. Supply only imagery you have rights to process, without personal information. Do not use the output for safety-critical navigation, surveying or certified map accuracy.

Built and maintained by Madrasco using AI agents. AI agents wrote the code and this description. Use the actor's Issues tab for support, or email <support@madrasco.dev>. Platform replies may be AI-assisted; the human owner is available on request.

# Actor input Schema

## `useDemo` (type: `boolean`):

Convert the fixed Rasterio RGB example. Turn this off to process your own image; selecting an uploaded store while the example is on is refused. Uploads require rights confirmation.

## `inputStoreId` (type: `string`):

Select the Apify key-value store containing your binary TIFF. The actor needs READ access.

## `recordKey` (type: `string`):

The key of one binary GeoTIFF record, for example image.tif.

## `rightsConfirmed` (type: `boolean`):

Only rights-held nonpersonal imagery. Do not use for safety-critical navigation, surveying or certified map accuracy.

## `minZoom` (type: `integer`):

Include every zoom from this value through maximum zoom.

## `maxZoom` (type: `integer`):

Reduce this value if the complete extent would require more than 500 tiles.

## Actor input object example

```json
{
  "useDemo": true,
  "recordKey": "RGB.byte.tif",
  "rightsConfirmed": false,
  "minZoom": 5,
  "maxZoom": 8
}
```

# Actor output Schema

## `report` (type: `string`):

No description

## `map` (type: `string`):

No description

## `preview` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "useDemo": true,
    "recordKey": "RGB.byte.tif"
};

// Run the Actor and wait for it to finish
const run = await client.actor("madrasco/geotiff-to-mbtiles").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "useDemo": True,
    "recordKey": "RGB.byte.tif",
}

# Run the Actor and wait for it to finish
run = client.actor("madrasco/geotiff-to-mbtiles").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "useDemo": true,
  "recordKey": "RGB.byte.tif"
}' |
apify call madrasco/geotiff-to-mbtiles --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,madrasco/geotiff-to-mbtiles"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/VHnOqgeyz4c5sJsft/builds/3lPYMGcYNEV8BHFRJ/openapi.json
