Select to view content in your preferred language

Can I use python to draw a polygon in ESRI Online?

589
4
04-05-2024 01:49 PM
robmerritt
Emerging Contributor

I attached an image of ESRI Online , where I have drawn a polygon with N points defining the polygon is there a programmatic way to interact with and ESRI online map via API and draw this

Tags (1)
0 Kudos
4 Replies
robmerritt
Emerging Contributor

hey Tiger I tried this but I was expecting this code to navigate to arcgis and draw on a map there...is that not the case?

from arcgis.gis import GIS
from arcgis.geocoding import geocode
from arcgis.geometry import lengths, areas_and_lengths, project
from arcgis.geometry import Point, Polyline, Polygon, Geometry
import pandas as pd

portal = GIS()  # anonymously

polygon = Polygon(
    {
        "rings": [
            [
                [-118.818984489994, 34.0137559967283],
                [-118.806796597377, 34.0215816298725],
                [-118.791432890735, 34.0163883241613],
                [-118.79596686535, 34.008564864635],
                [-118.808558110679, 34.0035027131376],
            ]
        ]
    }
)
polygon_attributes = {"name": "Polygon", "description": "I am a Polygon"}
simple_fill_symbol = {
    "type": "esriSFS",
    "color": [50, 100, 200, 125],
    "outline": {"color": [255, 255, 255], "width": 1},
}
map = portal.map()
map
map.draw(
    shape=polygon,
    symbol=simple_fill_symbol,
    attributes=polygon_attributes,
    popup={
        "title": polygon_attributes["name"],
        "content": polygon_attributes["description"],
    },
)


map.center = [34.0110, -118.8047]
map.zoom = 14
0 Kudos
robmerritt
Emerging Contributor

Cool that Tiger Ill give that a shot and report back

0 Kudos
robmerritt
Emerging Contributor

maybe I can add some context

I have a government web arcgis online site that I need to login to and then use python and arcgis to draw a pre designed polygon and then click some buttons to confirm that polygon choice. am I on the right track with the code above

 

0 Kudos