Image geolocation API
Get the location of an image using Artificial Intelligence, from your own code. Send a photo or a link, get back GPS coordinates with confidence scores and EXIF data.
# First, pip install picarta
from picarta import Picarta
api_token = "YOUR_API_TOKEN"
localizer = Picarta(api_token)
# Geolocate a local image worldwide
result = localizer.localize(img_path="/path/to/local/image.jpg")
print(result)
# Geolocate an image from URL with optional parameters for a specific location search
# If you want to search worldwide, keep these as None;
# country_code is a 2-letter country code (e.g., "US", "FR", "DE")
# admin1 is the region/state name (e.g., "California", "Niedersachsen", "Toscana")
# To get supported admin1 regions: GET https://api.picarta.ai/v1/admin1/{country_code}
# admin2 is the county/district name (only supported for some countries)
# To get supported admin2 regions: GET https://api.picarta.ai/v1/admin2/{country_code}/{admin1}
# center_latitude and center_longitude define the center of the search area.
# radius defines the search area around the center point in kilometers (max 25km).
# context is optional free-text hints about the photo. Maximum 500 characters.
result = localizer.localize(
img_path="https://upload.wikimedia.org/wikipedia/commons/8/83/San_Gimignano_03.jpg",
top_k=3,
country_code="IT",
admin1="Toscana",
center_latitude=43.464,
center_longitude=11.038,
radius=25,
context="Medieval hill town in Italy")
print(result)
const fs = require('fs');
const url = "https://api.picarta.ai/v1/geolocalize";
const apiToken = "API_TOKEN"; // Replace with your API token
const headers = {"Content-Type": "application/json"};
// Read the image from a local file
const imagePath = "path/to/local/image";
const imageData = fs.readFileSync(imagePath);
const imgPath = Buffer.from(imageData).toString('base64');
// OR from a URL
// const imgPath = "https://upload.wikimedia.org/wikipedia/commons/8/83/San_Gimignano_03.jpg";
// Optional parameters for a specific location search.
// If you want to search worldwide, keep these as null.
// country_code is a 2-letter country code (e.g., "US", "FR", "DE")
// admin1 is the region/state name (e.g., "California", "Niedersachsen", "Toscana")
// To get supported admin1 regions: GET https://api.picarta.ai/v1/admin1/{country_code}
// admin2 is the county/district name (only supported for some countries)
// To get supported admin2 regions: GET https://api.picarta.ai/v1/admin2/{country_code}/{admin1}
// center_latitude and center_longitude define the center of the search area.
// radius defines the search area around the center point in kilometers (max 25km).
// context is optional free-text hints about the photo. Maximum 500 characters.
let country_code = null;
let admin1 = null;
let center_latitude = null;
let center_longitude = null;
let radius = null;
let context = null;
let top_k = 3; // You can choose up to 10 GPS predictions. The default is 3
const payload = {
TOKEN: apiToken,
IMAGE: imgPath,
TOP_K: top_k,
COUNTRY_CODE: country_code,
ADMIN1: admin1,
Center_LATITUDE: center_latitude,
Center_LONGITUDE: center_longitude,
RADIUS: radius,
CONTEXT: context
};
fetch(url, {
method: 'POST',
headers: headers,
body: JSON.stringify(payload)
})
.then(response => response.json())
.then(result => console.log(result))
.catch(error => console.error('Error:', error));
# For local image file
img_path=$(base64 -w0 "/path/to/local/image.jpg")
# OR
# For image from a URL (comment out the above line and uncomment the next line)
#img_path="https://upload.wikimedia.org/wikipedia/commons/8/83/San_Gimignano_03.jpg"
# Optional parameters for a specific location search.
# If you want to search worldwide, keep these as null.
# country_code is a 2-letter country code (e.g., "US", "FR", "DE")
# admin1 is the region/state name (e.g., "California", "Niedersachsen", "Toscana")
# To get supported admin1 regions: GET https://api.picarta.ai/v1/admin1/{country_code}
# admin2 is the county/district name (only supported for some countries)
# To get supported admin2 regions: GET https://api.picarta.ai/v1/admin2/{country_code}/{admin1}
# center_latitude and center_longitude define the center of the search area.
# radius defines the search area around the center point in kilometers (max 25km).
# context is optional free-text hints about the photo. Maximum 500 characters.
country_code=null
admin1=null
center_latitude=null
center_longitude=null
radius=null
context=null
top_k=3 # You can choose up to 10 GPS predictions. The default is 3
# Construct the JSON payload
echo '{
"TOKEN": "API_TOKEN",
"IMAGE": "'"$img_path"'",
"TOP_K": "'"$top_k"'",
"COUNTRY_CODE": "'"$country_code"'",
"ADMIN1": "'"$admin1"'",
"Center_LATITUDE": "'"$center_latitude"'",
"Center_LONGITUDE": "'"$center_longitude"'",
"RADIUS": "'"$radius"'",
"CONTEXT": "'"$context"'"
}' > payload.json
# Send the request using curl
curl --request POST \
--url https://api.picarta.ai/v1/geolocalize \
--header 'Content-Type: application/json' \
--data @payload.json
# For local image file
base64_image=$(base64 -w0 "/path/to/local/image.jpg")
# For image from a URL (comment out the above line and uncomment the next line)
#base64_image=$(base64 -w0 <(wget -qO- "https://upload.wikimedia.org/wikipedia/commons/8/83/San_Gimignano_03.jpg"))
# Optional parameters for a specific location search.
# If you want to search worldwide, keep these as null.
# country_code is a 2-letter country code (e.g., "US", "FR", "DE")
# admin1 is the region/state name (e.g., "California", "Niedersachsen", "Toscana")
# To get supported admin1 regions: GET https://api.picarta.ai/v1/admin1/{country_code}
# admin2 is the county/district name (only supported for some countries)
# To get supported admin2 regions: GET https://api.picarta.ai/v1/admin2/{country_code}/{admin1}
# center_latitude and center_longitude define the center of the search area.
# radius defines the search area around the center point in kilometers (max 25km).
# context is optional free-text hints about the photo. Maximum 500 characters.
country_code=null
admin1=null
center_latitude=null
center_longitude=null
radius=null
context=null
top_k=3 # You can choose up to 10 GPS predictions. The default is 3
# Construct the JSON payload
echo '{
"TOKEN": "API_TOKEN",
"IMAGE": "'"$base64_image"'",
"TOP_K": "'"$top_k"'",
"COUNTRY_CODE": "'"$country_code"'",
"ADMIN1": "'"$admin1"'",
"Center_LATITUDE": "'"$center_latitude"'",
"Center_LONGITUDE": "'"$center_longitude"'",
"RADIUS": "'"$radius"'",
"CONTEXT": "'"$context"'"
}' > payload.json
# Send the request using wget
wget --method=POST \
--header='Content-Type: application/json' \
--body-file=payload.json \
--output-document=picarta_output.json \
https://api.picarta.ai/v1/geolocalize
Picarta API is available to Enterprise accounts, with a free trial. To get access, email [email protected] with your company name and use case. See the full API reference.
API features
Image to GPS
Find the GPS location of any image, even without EXIF data. Get up to 10 ranked locations, each with a confidence score.
Focused search
Limit the search to a country, a region or a circle of up to 25 km, and add free-text context about the photo.
Image EXIF Data
We provide image EXIF data, including camera model, timestamps, and more.
Building something with image geolocation?
Tell us about your use case and volume. Enterprise plans include on-premise deployment and SLA.