Metadata-Version: 2.1
Name: earth_api
Version: 0.0.5
Summary: ArcGIS Earth Automation API
Home-page: UNKNOWN
Author-email: 
License: UNKNOWN
Keywords: Swagger,ArcGIS Earth Automation API
Platform: UNKNOWN
Description-Content-Type: text/markdown

This python package is the [ArcGIS Earth Automation API](https://doc.arcgis.com/en/arcgis-earth/automation-api/get-started.htm). You can use this package to call some functions of ArcGIS Earth.

## Dependencies

* urllib3 (1.15 or greater)
* six (1.10 or greater)
* certifi
* python-dateutil
* requests
* od
  
## Installation

This package can be installed from the Python Package Index.

```
$ pip install earth-api
```

## Usage

### Import

You can use the following command to import the package.

```python
>>> from earth_api import EarthAPI
```

### Examples

#### Get the current camera information

```python
>>> from earth_api import EarthAPI
>>> earth = EarthAPI()
>>> status_code, camera = earth.get_camera()
>>> status_code
200
>>> camera
{'position': {'x': -92.0, 'y': 41.0, 'z': 11000000.0, 'spatial_reference': {'wkid': 4326}}, 'heading': 0.0, 'tilt': 0.0, 'roll': 0.0}
```

#### Set the camera position

The following codes are an example of the camera position.

```python
camera_dict = {
            "position": {
                "x": 113.59647525051167,
                "y": 32.464715999412107,
                "z": 2213290.0751730204,
                "spatialReference": {
                    "wkid": 4326
                },
                "heading": 354.04823651174161,
                "tilt": 19.96239543740441
            }
        }
```

Then, you can set the camera position.

```python
>>> from earth_api import EarthAPI
>>> earth = EarthAPI()
>>> earth.set_camera(camera_dict)
(200, {'result': 'Success'})
```

#### Set the flight target

The following codes are an example of flight information.

```python
flight_dict = {
            "camera":{
            "position":{
                "x":-92,
                "y":41,
                "z":11000000,
                "spatialReference":{
                    "wkid":4326
                }
            },
            "heading":0.0,
            "tilt":0.099999999996554886
        },
        "duration":2
    }
```

Then, you can set the flight.

```python
>>> from earth_api import EarthAPI
>>> earth = EarthAPI()
>>> earth.set_flight(flight_dict)
(200, {'result': 'Success'})
```

#### Add a layer

The following codes are an example of layer information.

```python
layer_dict = {
                "type":"MapService",
                "URI" :"https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
                "target" :"OperationalLayers"
            }
```

Then, you can add the layer to ArcGIS Earth.

```python
>>> from earth_api import EarthAPI
>>> earth = EarthAPI()
>>> status_code, layer_infor = earth.add_layer(layer_dict)
>>> status_code
200
>>> layer_infor
{'id': '91713d46-45f3-4bc4-9c82-38384905f1e1', 'opacity': 1.0, 'displayName': 'World_Imagery', 'isVisible': True, 'classType': 'Tiled_Layer', 'sourceURI': 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer', 'brightness': 0.0, 'contrast': 0.0, 'gamma': 0.0, 'lastTilingScheme': 'WebMercator', 'surfacePlacement': 'DrapedBillboarded', 'elevationOffset': 0.0, 'loadStatus': 'Loaded'}
```

#### Get the target layer information

You can get the target layer information according to the layer id.

```python
>>> from earth_api import EarthAPI
>>> earth = EarthAPI()
>>> status_code, layer_infor = earth.get_layer("91713d46-45f3-4bc4-9c82-38384905f1e1")
>>> status_code
200
>>> layer_infor
{'id': '91713d46-45f3-4bc4-9c82-38384905f1e1', 'opacity': 1.0, 'displayName': 'World_Imagery', 'isVisible': True, 'classType': 'Tiled_Layer', 'sourceURI': 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer', 'brightness': 0.0, 'contrast': 0.0, 'gamma': 0.0, 'lastTilingScheme': 'WebMercator', 'surfacePlacement': 'DrapedBillboarded', 'elevationOffset': 0.0, 'loadStatus': 'Loaded'}
```

#### Remove the target layer

You can remove the target layer according to the layer id.

```python
>>> from earth_api import EarthAPI
>>> earth = EarthAPI()
>>> earth.remove_layer("91713d46-45f3-4bc4-9c82-38384905f1e1")
(200, {'result': 'Success'})
```

#### Clear layers

You can clear all layers according to the following command.

```python
>>> from earth_api import EarthAPI
>>> earth = EarthAPI()
>>> earth.clear_layers()
(200, {})
```

#### Add the target graphic

The following codes are an example of a graphic.

```python
graphic_dict = {
                "id": "point-picture-marker-graphic-js",
                "geometry": {
                    "type": "point",
                    "x": -100,
                    "y": 40
                },
                "symbol": {
                    "type": "picture-marker",
                    "url": "https://static.arcgis.com/images/Symbols/Shapes/BlackStarLargeB.png",
                    "width": "64px",
                    "height": "64px",
                    "angle": 0,
                    "xoffset": "10px",
                    "yoffset": "10px"
                }
            }
```

Then, you can add the graphic to ArcGIS Earth.

```python
>>> from earth_api import EarthAPI
>>> earth = EarthAPI()
>>> status_code, graphic_infor = earth.add_graphic(graphic_dict)
>>> status_code
201
>>> graphic_infor
{'id': 'point-picture-marker-graphic-js', 'geometry': {'x': -100, 'y': 40, 'type': 'point'}, 'symbol': {'angle': 0, 'height': 48, 'type': 'picture-marker', 'url': 'https://static.arcgis.com/images/Symbols/Shapes/BlackStarLargeB.png', 'width': 48, 'xoffset': 7.5, 'yoffset': 7.5}}
```

#### Get the target graphic information

You can get the graphic information according to the graphic id.

```python
>>> from earth_api import EarthAPI
>>> earth = EarthAPI()
>>> status_code, graphic_infor = earth.get_graphic('point-picture-marker-graphic-js')
>>> status_code
200
>>> graphic_infor
{'id': 'point-picture-marker-graphic-js', 'geometry': {'x': -100, 'y': 40, 'type': 'point'}, 'symbol': {'angle': 0, 'contentType': 'image/png', 'height': 48, 'type': 'picture-marker', 'url': 'https://static.arcgis.com/images/Symbols/Shapes/BlackStarLargeB.png', 'width': 48, 'xoffset': 7.5, 'yoffset': 7.5}}
```

#### Update the graphic

You can update the graphic according to the new graphic information.

```python
>>> from earth_api import EarthAPI
>>> earth = EarthAPI()
>>> earth.update_graphic(new_graphic_dict)
(204, {})
```

#### Remove the target graghic

You can remove the graphic according to the graphic id.

```python
>>> from earth_api import EarthAPI
>>> earth = EarthAPI()
>>> earth.remove_graphic("point-picture-marker-graphic-js")
(204, {})
```

#### Clear graghics

You can clear graphics according to the following codes.

```python
>>> from earth_api import EarthAPI
>>> earth = EarthAPI()
>>> earth.clear_graphics()
(204, {})
```

#### Add a drawing

The following codes are a drawing example.

```python
drawing_dic = {
                "id": "point graphic sample",
                "title": "point graphic sample",
                "geometry": {
                    "x": -100,
                    "y": 40,
                    "spatialReference": {
                        "wkid": 4326
                    }
                },
                "symbol": {
                    "type": "picture-marker",
                    "url": "https://static.arcgis.com/images/Symbols/Shapes/BlackStarLargeB.png",
                    "width": "30px",
                    "height": "30px"
                },
                "labelSymbol": {
                    "type": "text",
                    "color": [
                        100,
                        100,
                        100,
                        255
                    ],
                    "font": {
                        "size": 24
                    }
                }
            }
```

Then, you can add a drawing to ArcGIS Earth.

```python
>>> from earth_api import EarthAPI
>>> earth = EarthAPI()
>>> status_code, drawing_infor = earth.add_drawing(drawing_dic)
>>> status_code
201
>>> drawing_infor
{'id': 'point graphic sample', 'result': 'Success'}
```

#### Remove the target drawing

You can remove the target drawing according to the drawing id.

```python
>>> from earth_api import EarthAPI
>>> earth = EarthAPI()
>>> earth.remove_drawing('point graphic sample')
(204, {})
```

#### Clear drawings

You can clear all drawings according to the following codes:

```python
>>> from earth_api import EarthAPI
>>> earth = EarthAPI()
>>> earth.clear_drawings()
(204, {})
```

#### Get the current workspace

You can get the current workspace of ArcGIS Earth.

```python
>>> from earth_api import EarthAPI
>>> earth = EarthAPI()
>>> status_code, workspace_infor = earth.get_workspace()
>>> status_code
200
>>> workspace_infor
{'url': 'http://localhost:8000/workspaces/f47b11cf-5dee-4f92-a528-6bc870b87874.zip', 'path': 'C:\\Users\\username\\Documents\\ArcGISEarth\\automation\\workspaces\\f47b11cf-5dee-4f92-a528-6bc870b87874.zip'}
```

#### Import the target workspace

You can import the target workspace according to the workspace information.

```python
>>> from earth_api import EarthAPI
>>> earth = EarthAPI()
>>> workspace_dict = {
                "url":"http://localhost:6080/workspace.zip",
                "path":"C:\\Users\\Administrator\\Desktop\\workspace.zip",
            }
>>> earth.import_workspace(workspace_dict)
(200, {'result': 'Success'})
```

#### Clear the current workspace

You can clear the current workspace.

```python
>>> from earth_api import EarthAPI
>>> earth = EarthAPI()
>>> earth.clear_workspace()
(200, {'result': 'Success'})
```

#### Get  the snapshot

You can get the current snapshot of ArcGIS Earth.

```python
>>> from earth_api import EarthAPI
>>> earth = EarthAPI()
>>> earth.get_snapshot()
(200, <urllib3.response.HTTPResponse object at 0x0000027BB2FBB190>)
```

