Posts

Showing posts with the label ArcGIS for Python

[Code Snippet] How to a create user in arcgis portal with a custom role?

Create a user or add member in ArcGIS portal with a custom role - 1. Get all custom roles from the portal, I presumed that the portal already has custom roles other than (org_user, org_publisher, org_admin) from arcgis.gis import * gis= GIS(portalUrl, userName, password) allRoles = gis.users.roles.all(max_roles=50) 2. Create a User with Default Role username="test" password='' firstname='test_name' lastname='test_last' email='test@test.com' description = 'Test Account' role = 'org_publisher' provider = 'enterprise' idp_username = 'test' level = 2 thumbnail = None newUser = gis.users.create(username, password,firstname,                lastname, email, description, role, provider,                 idp_username, level, thumbnail) 3. Update  the defualt role to Custom Role - Assign the role object not role name #Assigning the first role out of many portal roles, as an examp...

[Code Snippet] Find Custom Role of users that are in ArcGIS portal - ArcGIS

from arcgis.gis import * self.portalInfo = GIS(self.portalUrl, self.userName, self.password) self.portalUsers = self.portalInfo.users.search('') users = self.portalUsers roleManager = arcgis.gis.RoleManager(self.portalInfo) roles = roleManager.all() for user in users: if hasattr(user,'roleId'): for role in roles: if(user.roleId == role.role_id): print(user.username,user.role,role.name)

Code snippet: Get DateTime from UTC timestamp in ArcGIS Online

  ArcGIS Online  stores all date values in  UTC.  A short snippet to convert UTC timestamp to DateTime using Python.       from datetime import datetime       utcTimeStamp = 1472218452855       date = datetime.fromtimestamp( utcTimeStamp / 1e3)              print( date ) output: 2016-08-26 09:34:12.855000

ArcGIS Pro, Conda, Jupyter, and ArcGIS for Python setup

Image
A. Download and install the ArcGIS pro as described http://pro.arcgis.com/en/pro-app/get-started/install-and-sign-in-to-arcgis-pro.htm          B. Installation of Jupyter and ArcGIS for Python API can be done in two ways.  1.        Using  ArcGIS Pro’s Python Package Manager Graphical User Interface ( uses Conda under the hood) 2.        Using Conda via Python Command Prompt 1. Using ArcGIS Pro's Python Pacakge Manager  i.     Click  About ArcGIS Pro ii. Select packages you would like to install