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")
    # center_latitude and center_longitude define the center of the search area.    
    # radius defines the search area around the center point in kilometers.

    result = localizer.localize(
    img_path="https://upload.wikimedia.org/wikipedia/commons/8/83/San_Gimignano_03.jpg",
    top_k=10,
    country_code="IT",
    center_latitude=43.464, 
    center_longitude=11.038,
    radius=100)

    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")
    // center_latitude and center_longitude define the center of the search area.
    // radius defines the search area around the center point in kilometers.
    let country_code = 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


    // Prepare the payload
    const payload = {
        "TOKEN": apiToken,
        "IMAGE": imgPath,
        "TOP_K": top_k,
        "COUNTRY_CODE": country_code,
        "Center_LATITUDE": center_latitude,
        "Center_LONGITUDE": center_longitude,
        "RADIUS": radius,
    };

    // Send the POST request with the payload as JSON data
    fetch(url, {
        method: "POST",
        headers: headers,
        body: JSON.stringify(payload)
    })
    .then(response => {
        if (response.ok) {
            return response.json();
        } else {
            throw new Error("Request failed with status code: " + response.status);
        }
    })
    .then(result => {
        console.log(result);
    })
    .catch(error => {
        console.error("Request failed with error:", error);
        console.error(response.text);
    });                                
                                            
                                        
                                            
    # 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")
    # center_latitude and center_longitude define the center of the search area.
    # radius defines the search area around the center point in kilometers.
    country_code=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"'",
        "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")
    # center_latitude and center_longitude define the center of the search area.
    # radius defines the search area around the center point in kilometers.
    country_code=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"'",
        "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..

satellite in orbit

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.