Wednesday, November 21, 2018

ArcGIS Server SOI - HandleRESTRequest Parameter limitations

Be The First To Comment
The SOI Rest request handler method -

public byte[] HandleRESTRequest(string Capabilities, string resourceName, string operationName,
            string operationInput, string outputFormat, string requestProperties, out string responseProperties)

HandleRESTRequest paramater provides following information inside the method

capabilities Map,Query,Data
 resourceName layers/0
operationName query, 
operationInput {"returnZ":false,"returnIdsOnly":false,
"spatialRel":"esriSpatialRelIntersects","geometryType":"esriGeometryEnvelope"}, outputFormat json, 
requestProperties {"computeETag":true,"ETag":"\"c429a59c\""}, 
responseProperties {"Content-Type":"text/plain"}

But it has no way of telling service name and layer name ...other than using layer index from resourceName if you want to perform layer specific operation in layers.

Sunday, August 5, 2018

[Code snippet]: Planet API Image Download Url

Be The First To Comment

from requests.auth import HTTPBasicAuth
import os
import requests

item_id = "20161109_173041_0e0e"
item_type = "PSScene3Band"

os.environ['PLANET_API_KEY'] = '3b711bededf6485a0' #not a real id
asset_type = "visual"
item_url = '{}/items/{}/assets'.format(item_type, item_id)

# Request a new download URL
result = requests.get(item_url, auth=HTTPBasicAuth(os.environ['PLANET_API_KEY'], ''))
download_url = result.json()[asset_type]['location']


Thursday, June 14, 2018

Monday, June 11, 2018

[Snippet]: Fetch User Name and Email Address from Windows AD Group using Powershell script.

Be The First To Comment

#Store users' info in CSV

Get-ADGroupMember -Identity GROUPNAME -Recursive|Get-ADUser -Properties Mail, MemberOf | Select-Object GivenName, Surname, SamAccountName, Mail  | Export-csv -path GROUPNAME .csv -NoTypeInformation

Wednesday, May 30, 2018

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

Be The First To Comment
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

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 example
status = newUser.update_role(role=allRoles[0]

If role assigned success, the value of status will be True.


Friday, May 25, 2018

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

Be The First To Comment
from arcgis.gis import *

self.portalInfo = GIS(self.portalUrl, self.userName, self.password)

self.portalUsers ='')

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):


Remote debug environment setup for ArcGIS server extensions- SOE and SOI

In order to debug the ArcGIS server extension SOE/SOI from your development machine, you have to follow 3 steps:
           1.       Enable remote debug ( Presumption is your development machine and GIS server are different machines)
           2.       Enable sever extension for debug
           3.       Attach debugger to the process running the service

Download and install the remote debuggin tools from - 

      A.  Enable remote debug
1.       Download and configure Remote tools on the development
a.       Find msvsmon.exe in the directory matching your version of Visual Studio. For Visual Studio 2015:

Program Files\Microsoft Visual Studio 14.0\Common7\IDE\Remote Debugger\x64\msvsmon.exe
(x64 can debug both x86 and x64 but x86 can only debugs x86)

2.       On the remote computer,  copy Remote Debugger folder from development machine and put in C:\ drive. Then, run msvsmon.exe
3.       The msvsmon.exe output terminal shows

Wednesday, April 11, 2018

Code snippet: Get DateTime from UTC timestamp in ArcGIS Online

Be The First To Comment
 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)

output: 2016-08-26 09:34:12.855000

Thursday, April 5, 2018

Override Default Location of Jupyter Notebook file

Be The First To Comment
This post is continue of  ArcGIS Pro, Conda, Jupyter Setup post. The default location of Jupter Notebook IronPython (*.ipynb) file is   C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3 - 
               import os
               print (os.getcwd())

To change the default location of Jypyter notebook script file(*ipynb) you need to configure

Tuesday, April 3, 2018

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

Be The First To Comment
     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

Tuesday, February 6, 2018

ArcGIS Server Rest End Point POST parameters for Create Replica for ArcGIS collector

Be The First To Comment

Post Params list -
  1. replicaName:
  2. layers:
  3. layerQueries:
  4. geometry:
    {"rings": [[[-9074894.9, 3341138.1], [-9045657.8, 3341176.3], [-9045657.8, 3320500.1], [-9074818.5, 3320538.3], [-9074894.9, 3341138.1]]], "spatialReference": {"wkid": 3857}}
  5. geometryType:
  6. inSR:
  7. replicaSR:
  8. transportType:
  9. returnAttachments:
  10. returnAttachmentsDataByUrl:
  11. attachmentsSyncDirection:
  12. async:
  13. syncModel:
  14. dataFormat:
  15. replicaOptions:
  16. f:

Monday, February 5, 2018

Git Workflow- The picture speaks for itself

Be The First To Comment

Friday, February 2, 2018

[Code snippet] Extract Feature Layer Fields from Map Document (Mxd) using ArcPy

Be The First To Comment
This code snippet is for getting a list of fields in a feature layer from a map document in ArcPy 10.4.

1:  #Import arcpy mapping library  
2:  import arcpy.mapping;  
4:  # Map doc path  
5:  mxdPath =r"C:\MyMxd.mxd"  
7:  #Open map document  
8:  document = arcpy.mapping.MapDocument(mxdPath)  
10:  #Extract all dataframes inside a map document  
11:  dataFrameList = arcpy.mapping.ListDataFrames(document)  
13:  #Loop through all DF   
14:  for dataFrame in dataFrameList:  
15:  #Extact all layers in a dataframe   
16:    layerList = arcpy.mapping.ListLayers(document, None, dataFrame)  
18:    #Loop through all Layers     
19:    for layer in layerList:  
20:      print ("--" +"--"+layer.dataSource)  
22:      #Extract all fields in a layer   
23:      fieldList = arcpy.ListFields(layer.dataSource, None, None)  
25:      #Loop through and print field properties       
26:      for field in fieldList:  
27:         print(,field.aliasName,field.type,field.length,field.required,field.precision)  

Code Snippet: Read ArcGIS Offline Geodatabase into ArcGIS Runtime in WPF

Be The First To Comment
Here is an quick code snippet for loading ArcGIS runtime database ( offline database) in .NET in ESRI Runtime version 100. The OverlayFeatureLayers() reads the layers from runtime geodatabase and overlayes on runtime environment map in Web Mercator Projection (EPSG: 3857)

 using System;  
 using System.Collections.Generic;  
 using System.Linq;  
 using System.Text;  
 using System.Threading.Tasks;  
 using System.IO;  
 using System.Runtime.CompilerServices;  
 using System.Windows.Input;  
 using Esri.ArcGISRuntime.Data;  
 using Esri.ArcGISRuntime.Geometry;  
 using Esri.ArcGISRuntime.Location;  
 using Esri.ArcGISRuntime.Mapping;  
 using Esri.ArcGISRuntime.Security;  
 using Esri.ArcGISRuntime.Symbology;  
 using Esri.ArcGISRuntime.Tasks;  
 using Esri.ArcGISRuntime.UI;  
 using ReadRuntimeGeodatabase.CustomViewModelBase;  
 namespace ReadRuntimeGeodatabase  
   public class MapViewModel : ViewModelBase  
     public MapViewModel()  
     private Map _map = new Map(SpatialReference.Create(3857));  
     public Map Map  
       get { return this._map; }  
         if (value != this._map)  
           this._map = value;  
     private async void OverlayFeatureLayers()  
       Basemap basemap = Basemap.CreateStreets();  
       _map.Basemap = basemap;  
       string gdbsPath = @"C:\RuntimeToFileGeodatabase;  
       DirectoryInfo dirInfo = new DirectoryInfo(gdbsPath);  
       String[] files = dirInfo.GetFiles("*.geodatabase").Select(file => file.FullName).ToArray<string>();  
       foreach (var gdbFile in files)  
         // open a geodatabase on the local device  
         var gdb = await Esri.ArcGISRuntime.Data.Geodatabase.OpenAsync(gdbFile);  
         // loop thru all tables in the geodatabase  
         foreach (var table in gdb.GeodatabaseFeatureTables.ToList())  
           table.UseAdvancedSymbology = true;  
           var layer = new FeatureLayer(table);  
           await table.LoadAsync();  
           if (table.LoadStatus == Esri.ArcGISRuntime.LoadStatus.Loaded && table.GeometryType.ToString() != "Unknown")  
             await layer.LoadAsync();  
             if (layer.Name == "River_line")  
               // Defaul renderer comes with geodatabase doesn't show up  
               SimpleRenderer customrenderer = new SimpleRenderer();  
               customrenderer.Symbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, System.Windows.Media.Colors.Black, 2);  
               layer.Renderer = customrenderer;  
               Envelope envelope = layer.FullExtent;  
               _map.InitialViewpoint = new Viewpoint(envelope);  
             else {  
               if (table.GeometryType.ToString() == "Polyline")  
                 SimpleRenderer customrenderer = new SimpleRenderer();  
                 customrenderer.Symbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, System.Windows.Media.Colors.Green, 2);  
                 layer.Renderer = customrenderer;  
             System.Diagnostics.Debug.WriteLine(layer.LoadStatus + "---" + layer.Name + "--" + layer.FullExtent + "--" + table.GeometryType + "--" + layer.IsVisibleAtScale(100) + "--" + layer.IsVisible + "--" + layer.MaxScale + "--" + layer.MinScale);  
             if (layer.LoadStatus == Esri.ArcGISRuntime.LoadStatus.Loaded)  
             System.Diagnostics.Debug.WriteLine("No Geom -->" + table.TableName);  

Git SSL certificate problem: self signed certificate [Solution]

Be The First To Comment
git clone https://......./data.git

throws ssl error resembling to following:
Cloning into 'data'...
fatal: unable to access 'https://*/data.git/': SSL certificate problem: self signed certificate in certifica                                                       te chain

Solution - disable sslVerify and clone it

git -c http.sslVerify=false clone https://......./data.git


© 2011 GIS and Remote Sensing Tools, Tips and more .. ToS | Privacy Policy | Sitemap

About Me