TransWikia.com

Adding features with attribution to Feature Service using Jupyter Notebooks and ArcGIS Python API?

Geographic Information Systems Asked by fpolig01 on February 24, 2021

I want to have a user add points by clicking on a map in a Jupyter Notebook and those points get pushed to a feature service.

I’m able to accomplish that task, but I would like the user to be able to customize the attribution for the points they just added.

I’m envisioning a pop up with the various fields that appears when the user adds a point on the map and they just type in a string. I’ve tried using input(), as well as ipywidgets.

Is there another way to accomplish this?

Most of the examples I see online are for the ArcGIS JavaScript API.

def create_feature(_map, location):

    try:
        object_id = 1
        point = geometry.Point(location)
        feature = features.Feature(
            geometry=point,
            attributes={
                'OBJECTID': object_id,
                'PARK_NAME': 'My Park',
                'TRL_NAME': 'Foobar Trail',
                'ELEV_FT': '5000'
            }
        )

        trailheads_layer.edit_features(adds=[feature])
        _map.draw(point)

    except Exception as e:
        print("Couldn't create the feature. {}".format(str(e)))

m.on_click(create_feature)

One Answer

You can use the ArcGIS API for Python to create a new webmap and add the service that you would like to edit.

Following documentation explains how to create webmap: https://developers.arcgis.com/python/sample-notebooks/publishing-web-maps-and-web-scenes/

Then get the URL of the webmap and use webbrowser module to open the webmap in new tab.

Example:

import webbrowser

# generate an URL
url = 'https://' + <URL_of_webmap>
webbrowser.open(url)

Currently, there is no way of having an editing session in jupyter notebook with a user interface that includes popups.

However, you can go to ESRI's ideas page: https://community.esri.com/community/arcgis-ideas/content

This page is reviewed by ESRI's developer's department if the idea has enough potential they will implement the module to achieve your requirement in the next release of the ArcGIS API for Python product.

Answered by Gurminder Bharani on February 24, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP