Showing posts with label Esri. Show all posts
Showing posts with label Esri. Show all posts

Thursday, February 8, 2018

Esri Developer Summit 2018

See me live and in-person at the Esri DevSummit 2018!

Tomato's optional.


Like Pokemon, you gotta catch them all.




Monday, July 10, 2017

ArcGIS API for Python

Sorry for not posting folks, but I've been busy working on the ArcGIS API for Python.

For those who don't know I wrote ArcREST with another colleague of mine, Mike.  Since the announcement of the ArcGIS API for Python, we have decided to retire ArcREST, though if pull requests are submitted to fix critical issues, we will do our best to merge them.  

So what does that leave the people with to work with the REST API?  There is a great package from Esri, the ArcGIS API for Python.  Get it here (https://developers.arcgis.com/python/guide/install-and-set-up/).  

It has tons of great features for everyday users, content producers and administrators.  Another benefits is that you get the new Spatial DataFrame!  

The Spatial DataFrame (SDF) is built on top of the Panda's DataFrame to display 2-D data with labelled columns.  The SDF can pull data from services and local feature classes. It is a quick way to merge your online content to local content, and republish it out in a new service or save as a feature class.

At v1.2 of the API, we added support for ArcGIS Server, and enhance the Enterprise ArcGIS and ArcGIS Online support.  

I highly recommend you start moving the ArcGIS API for Python.  
I look forward to seeing and hearing what you do with the Python API.  

If you want to see me at Esri User Conference 2017, I will be presenting the following sessions:

Session  Location  Date/Time 
 Administering ArcGIS Enterprise and ArcGIS Online with Python SDCC - Ballroom 06 D   07/11/2017 - 8:30 am - 9:45 am
 Automating Enterprise GIS Administration using Python SDCC - Demo Theater 11   07/11/2017 - 4:30 pm - 5:15 pm
 Administering ArcGIS Enterprise and ArcGIS Online with Python  SDCC - Ballroom 06 C   07/13/2017 - 8:30 am - 9:45 am


Tomato throwing is optional.


See ya there

Tuesday, June 9, 2015

ArcREST Publishing Part 2 - SD Files

The easiest and quickest way to get data into AGOL/Portal is to publish from a service definition file, or SD file.  SD files are compressed files using 7-zip.  They contain all sorts of information about how your service behaves, what it's name is, the service's data, etc...  It's a complete package or all in one file for publishing services.

You can automate the creation of service using Python or AO, but I am not going to dive into that topic.  Instead I am going to show how you can easily publish the SD file using ArcREST to your site (AGS, AGOL or Portal).

This example is going to focus on solely the publishing of SD files to AGOL.

import arcrest
import json
import time
#--------------------------------------------------------------------------
if __name__ == "__main__":
    username = "someadminuser"
    password = "reallysecurepassword"
    sd_file = r"C:\temp\1\DemoPublishing.sd"
    proxy_port = None
    proxy_url = None

    #   Connect to the site
    #
    sh = arcrest.AGOLTokenSecurityHandler(username, password)
    admin = arcrest.manageorg.Administration(securityHandler=sh,
                                             initialize=True)
    content = admin.content

    uc = content.usercontent(username)
    ip = arcrest.manageorg.ItemParameter()
    ip.title = "DemoPublishing"
    ip.type = "Service Definition"
    ip.tags = "SD, publishing, example"
    ip.typeKeywords = "Data, Service, Service Definition"

    res = uc.addItem(itemParameters=ip, filePath=sd_file)
    itemId = res['id']
    # Publish the SD File
    #
    resPublish = uc.publishItem(fileType="serviceDefinition",
                                publishParameters=None, itemId=itemId)
    jobId = resPublish['services'][0]['jobId']
    serviceItemId = resPublish['services'][0]['serviceItemId']
    flUrl = resPublish['services'][0]['serviceurl']
    status = uc.status(itemId=serviceItemId, jobId=jobId)
    while status['status'].lower() == "processing":
        time.sleep(2)
        status = uc.status(itemId=serviceItemId, jobId=jobId)
    print 'service published.'
    print 'Bonus Demo - update some additional properties on a feature service'
    flAdmin = arcrest.agol.FeatureService(url=flUrl, securityHandler=sh).administration
    # Bonus 1- Enable edits Only
    updateDefinition = """{"hasStaticData":false,"capabilities":"Query,Editing,Create,Update,Delete","allowGeometryUpdates":true,"editorTrackingInfo":{"enableEditorTracking":false,"enableOwnershipAccessControl":false,"allowOthersToUpdate":true,"allowOthersToDelete":true}}"""
    print flAdmin.updateDefinition(json_dict=json.loads(updateDefinition))
    # Bonus 2- Enable edits with export data - adds 'Extract' to capabilities
    updateDefinition2 = """{"hasStaticData":false,"capabilities":"Query,Editing,Create,Update,Delete,Extract","editorTrackingInfo":{"enableEditorTracking":false,"enableOwnershipAccessControl":false,"allowOthersToUpdate":true,"allowOthersToDelete":true}}"""
    print flAdmin.updateDefinition(json_dict=json.loads(updateDefinition2))
    # Bonus 3- Enable Sync on services - Adds 'Sync' to capabilities
    updateDefinition3 = """{"hasStaticData":false,"capabilities":"Query,Editing,Create,Update,Delete,Sync,Extract","editorTrackingInfo":{"enableEditorTracking":false,"enableOwnershipAccessControl":false,"allowOthersToUpdate":true,"allowOthersToDelete":true}}"""
    print flAdmin.updateDefinition(json_dict=json.loads(updateDefinition3))
    # Bonus 4- Enable editor tracking on service - set enableEditorTracking = True
    updateDefinition4 = """{"hasStaticData":false,"capabilities":"Query,Editing,Create,Update,Delete,Sync,Extract","editorTrackingInfo":{"enableEditorTracking":true,"enableOwnershipAccessControl":false,"allowOthersToUpdate":true,"allowOthersToDelete":true}}"""
    print flAdmin.updateDefinition(json_dict=json.loads(updateDefinition4))
    print 'finished!'





I added some additional information to the example here.  The basic example ends at the print 'service published' part.  The additional code below shows how to enable the editing, export data, sync or track edits.  You can do this all in call, but I wanted to show how you enable each one at a time because you may only want to enable one function over another.  Notice how I get the feature service URL from the publish() then I take that URL and create a Feature Service object from the agol.FeatureService Class.  Since my user is an administrator and owner of the service, I can access the back end function to enable the additional properties.  On the Feature Service class, there is a property called administration which takes you to the hostingservice.AdminFeatureService class which allows users to update the service definitions on a hosted feature service.

I threw a lot out there, and I hope it helps!

Previous posts on publishing:
Part 1 - Publish CSV files can be found here.

Wednesday, May 27, 2015

See me at Esri's User Conference 2015

I'm going to be at UC 2015 presenting about ArcREST in the demo theater.

12:30 PM - 01:15 PM : Using the ArcREST Python Package on Tuesday 7/21/2015.

Hope to see you all there!