API Integration
Copy
# 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://picarta.ai/admin1/{country_code}
# 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).
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)
print(result)
const fs = require('fs');
const url = "https://picarta.ai/classify";
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://picarta.ai/admin1/{country_code}
// 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).
let country_code = null;
let admin1 = null;
let center_latitude = null;
let center_longitude = null;
let radius = 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
};
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://picarta.ai/admin1/{country_code}
# 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).
country_code=null
admin1=null
center_latitude=null
center_longitude=null
radius=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"'"
}' > payload.json
# Send the request using curl
curl --request POST \
--url https://picarta.ai/classify \
--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://picarta.ai/admin1/{country_code}
# 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).
country_code=null
admin1=null
center_latitude=null
center_longitude=null
radius=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"'"
}' > 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://picarta.ai/classify
Available Services
Image to GPS
In the absence of GPS EXIF data, our AI system provides GPS estimation.
Image EXIF Data
We provide image EXIF data, including camera model, timestamps, and more..
Aerial imagery
Our system accurately georeferences aerial imagery captured by aircraft, drones, and satellites.
Landmarks detection
Our system excels with landmark images. The service will be provided soon.