#!/usr/bin/env python3 from pprint import pprint from picterra import APIClient # Set the PICTERRA_API_KEY environment variable to define your API key client = APIClient() # The Id of a folder/project you own folder_id = "7ec40c11-f181-436a-9d33-d7b3f63e0e0f" raster_id = client.upload_raster('data/raster1.tif', name='A nice raster') print('Uploaded raster=', raster_id) for raster in client.list_rasters(): pprint('raster %s' % "\n".join(["%s=%s" % item for item in raster.items()])) raster_id = client.upload_raster( 'data/raster1.tif', name='Another nice raster in a nice folder', folder_id=folder_id, captured_at="2020-01-01T12:34:56.789Z" ) print('Uploaded raster=', raster_id) for raster in client.list_rasters(folder_id): pprint('raster %s' % "\n".join(["%s=%s" % item for item in raster.items()])) client.delete_raster(raster_id) print('Deleted raster=', raster_id)
from picterra import APIClient # Replace this with the id of one of your detectors detector_id = 'd552605b-6972-4a68-8d51-91e6cb531c24' # Set the PICTERRA_API_KEY environment variable to define your API key client = APIClient() print('Uploading raster...') raster_id = client.upload_raster('data/raster1.tif', name='a nice raster') print('Upload finished, starting detector...') result_id = client.run_detector(detector_id, raster_id) client.download_result_to_file(result_id, 'result.geojson') print('Detection finished, results are in result.geojson')
from picterra import APIClient client = APIClient(api_key='1234') raster_id = client.upload_raster('data/raster1.tif', name='a nice raster') print('Uploaded raster=', raster_id)
def _client(max_retries=0, timeout=1): return APIClient(api_key='1234', base_url=TEST_API_URL, max_retries=max_retries, timeout=timeout)
import logging import sys from picterra import APIClient logging.basicConfig(stream=sys.stdout, level=logging.DEBUG) raster = 'f9abc42b-73d4-429c-9e44-f095a1949df4' detector = '21cd315d-5795-4559-afa0-5a4e9498f064' pic = APIClient() result_id = pic.run_detector(detector, raster) pic.download_result_to_file(result_id, 'result.geojson')
def _client(): return APIClient(api_key='1234', base_url=TEST_API_URL)
#!/usr/bin/env python3 import json from picterra import APIClient # Set the PICTERRA_API_KEY environment variable to define your API key client = APIClient() # Create a new detector (its type is 'count' by default) detector_id = client.create_detector('My first detector') # Upload a training raster for the detector above raster_id = client.upload_raster('data/raster1.tif', name='a nice raster') client.add_raster_to_detector(raster_id, detector_id) # Add annotations with open('data/outline.geojson') as f: outlines = json.load(f) client.set_annotations(detector_id, raster_id, 'outline', outlines) with open('data/training_area.geojson') as f: training_areas = json.load(f) client.set_annotations(detector_id, raster_id, 'training_area', training_areas) with open('data/validation_area.geojson') as f: validation_areas = json.load(f) client.set_annotations(detector_id, raster_id, 'validation_area', validation_areas) # Train the detector client.train_detector(detector_id) # At this point your detector is ready to predict: see upload_and_detect.py in order # to launch a prediction on a raster; you can also use one of the raster already added above.
from picterra import APIClient # Replace this with the id of one of your detectors detector_id = 'd552605b-6972-4a68-8d51-91e6cb531c24' # Replace this with the id of a folder in which the # raster should be uploaded. folder_id = '63207fe9-32b8-410f-a72d-00803cca7bf3' # Set the PICTERRA_API_KEY environment variable to define your API key client = APIClient() print('Uploading raster...') raster_id = client.upload_raster('data/raster1.tif', name='a nice raster', folder_id=folder_id, captured_at='2020-01-01T12:34:45.789Z') print('Upload finished, starting detector...') result_id = client.run_detector(detector_id, raster_id) client.download_result_to_feature_collection(result_id, 'result.geojson') print('Detection finished, results are in result.geojson')
#!/usr/bin/env python3 import json from picterra import APIClient # Set the PICTERRA_API_KEY environment variable to define your API key client = APIClient() # Create a new detector (its type is 'count' by default) detector_id = client.create_detector('My first detector') # Edit the above detector client.edit_detector(detector_id, 'Renamed detector', 'segmentation', 'bbox', 1000) # List existing detectors for d in client.list_detectors(): print( 'detector id=%s, name=%s, detection_type=%s, output_type=%s, training_steps=%d' % (d['id'], d['name'], d['configuration']['detection_type'], d['configuration']['output_type'], d['configuration']['training_steps']))
from picterra import APIClient client = APIClient(api_key='1234') for raster in client.list_rasters(): print('raster id=%s, name=%s, status=%s' % (raster['id'], raster['name'], raster['status']))
#!/usr/bin/env python3 # -*- coding: utf-8 -*- from pprint import pprint from picterra import APIClient # Set the PICTERRA_API_KEY environment variable to define your API key client = APIClient() # The Id of a folder/project you own folder_id = "7ec40c11-f181-436a-9d33-d7b3f63e0e0f" local_raster_id = client.upload_raster('data/raster1.tif', name='A nice raster') print('Uploaded local raster=', local_raster_id) for raster in client.list_rasters(): pprint('raster %s' % "\n".join(["%s=%s" % item for item in raster.items()])) wms_raster_id = client.upload_remote_raster( 'wms', 'http://wms.zh.ch/OrthoZHWMS?LAYERS=OrthoZHWMS', 0.3, footprint={ "type": "Polygon", "coordinates": [[[8.531441688537598, 47.3669375756445], [8.555259704589844, 47.3669375756445], [8.555259704589844, 47.37530808909385], [8.531441688537598, 47.37530808909385], [8.531441688537598, 47.3669375756445]]]