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:
    test_02_32_Feb6_2018
  2. layers:
    26
  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:
    esriGeometryPolygon
  6. inSR:
  7. replicaSR:
  8. transportType:
    esriTransportTypeUrl
  9. returnAttachments:
    false
  10. returnAttachmentsDataByUrl:
    true
  11. attachmentsSyncDirection:
    none
  12. async:
    false
  13. syncModel:
    perLayer
  14. dataFormat:
    sqlite
  15. replicaOptions:
  16. f:
    pjson

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;  
3:    
4:  # Map doc path  
5:  mxdPath =r"C:\MyMxd.mxd"  
6:    
7:  #Open map document  
8:  document = arcpy.mapping.MapDocument(mxdPath)  
9:    
10:  #Extract all dataframes inside a map document  
11:  dataFrameList = arcpy.mapping.ListDataFrames(document)  
12:    
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)  
17:      
18:    #Loop through all Layers     
19:    for layer in layerList:  
20:      print (dataFrame.name+"--"+layer.name +"--"+layer.dataSource)  
21:        
22:      #Extract all fields in a layer   
23:      fieldList = arcpy.ListFields(layer.dataSource, None, None)  
24:        
25:      #Loop through and print field properties       
26:      for field in fieldList:  
27:         print(field.name,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()  
     {  
       OverlayFeatureLayers();  
     }  
     private Map _map = new Map(SpatialReference.Create(3857));  
     public Map Map  
     {  
       get { return this._map; }  
       set  
       {  
         if (value != this._map)  
         {  
           this._map = value;  
           NotifyPropertyChanged("Map");  
         }  
       }  
     }  
     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)  
             {  
               _map.OperationalLayers.Add(layer);  
             }  
           }  
           else  
           {  
             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


Monday, October 23, 2017

Upgrade or Install Python PIP in ArcGIS Desktop 10.4.1

Be The First To Comment
ArcGIS  Desktop 10.4.1’s default pip, C:\Program Files (x86)\Python27\ArcGIS10.4\Scripts  failed to install the packages throwing following error –

Fatal error in launcher: Unable to create process using '"C:\Python27\ArcGIS10.4
\python.exe" "C:\Python27\ArcGISx6410.4\Scripts\pip.exe" 
The following steps to make the pip to work

Step 1. Open command terminal as Administrator and see if pip works
      Make sure 
            C:\Program Files (x86)\Python27\ArcGIS10.4\Lib;
            C:\Program Files (x86)\Python27\ArcGIS10.4\Scripts;

            C:\Program Files (x86)\Python27\ArcGIS10.4
      are in path            
  
           pip install <package_name> , no luck [ You can Jump directly to #4]
        
Step 2. Check the pip version
            pip --version
            (pip9.0.1 as of today)

Step 3. Try to upgrade pip

            pip install --upgrade pip

            The command run successfully, but did not upgrade pip. Every time terminal complains –
You are using pip version 7.0.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

Step 4. Installing pip from beginning although it ships automatically in Python 2.7 ( Arcgis 10.)
To install pip, securely download get-pip.py.
Then run the following:

python get-pip.py
or
python get-pip.py --trusted-host pypi.python.org ( if SSL certification error occurs)

Step 5. Check pip version

pip --version

pip 9.0.1 from C:\Python27\ArcGIS10.4\lib\site-packages (python 2.7)
( You should have latest version of pip)

Step 6. Now use pip to install packages

pip install <package_name> --trusted-host pypi.python.org

           

Monday, September 18, 2017

Descriptions of the Gradle build structure

Be The First To Comment
Descriptions of the build gradle file’s parts

Build Java code

apply plugin: ‘java’
apply plugin: ‘war’

This task compiles, tests, and assembles the code into a JAR or WAR file, 
when you run - gradle build

Specify project folder structure

sourceSets{
                main.java.srcDir “src/main”
                test.java.srcDir “src/test”
}

Build with Gradle Wrapper

task wrapper(type: Wrapper) {
    gradleVersion = '2.7'
}

The Gradle Wrapper is the preferred way of starting a Gradle build. It consists of a batch 
script for Windows and a shell script for OS X and Linux. These scripts allow you to run 
a Gradle build without requiring that Gradle be installed on your system.

Friday, September 15, 2017

Tutorial: Sharing Data Between Angular Components - Parent to Child, Child to Parent, and between siblings

Be The First To Comment
Great video talking about sharing Data Between Angular Components - Parent to Child, Child to Parent, and between siblings by Jeff Delaney, AngularFirebase. 



Wednesday, September 13, 2017

Wiring Leaflet, ESRI-leaflet, and Angular for a web map

Be The First To Comment
Basic prototype wiring to map geospatial information using Leaflet, ESRI-leaflet, Angular 4.  There are several nice examples out there, but it is a quick and dirty way of putting all things together and display the map using Angular/Cli.

Step 1. Generate an angular project from angular/cli
                ng new leafletPrototype

Step2. Install all dependencies
a.     Npm install leaflet --save
b.     Nmp install esri-leaflet --save
c.      Npm install @types/leaflet –save

Your pacakage.json will looks like –
"dependencies": {
    "@angular/common": "^4.0.0",
    "@angular/compiler": "^4.0.0",
    "@angular/core": "^4.0.0",
    "@angular/forms": "^4.0.0",
    "@angular/http": "^4.0.0",
    "@angular/platform-browser": "^4.0.0",
    "@angular/platform-browser-dynamic": "^4.0.0",
    "@angular/router": "^4.0.0",
    "@types/leaflet": "^1.0.69",
    "core-js": "^2.4.1",
    "esri-leaflet": "^2.1.1",
    "leaflet": "^1.2.0",
    "rxjs": "^5.1.0",
    "zone.js": "^0.8.4"
  },


Step 3. Configure .angular-cli.json
Add leaflet and esri-leaflet styles and scripts in .angular-cli.json
"styles": [
        "styles.scss",
        "../node_modules/leaflet/dist/leaflet.css",
        "../node_modules/leaflet-draw/dist/leaflet.draw.css"
      ],


      "scripts": ["../node_modules/leaflet/dist/leaflet.js",
        "../node_modules/esri-leaflet/dist/esri-leaflet.js"
      ],

Step 4. Now, run “ng serve” and see if any errors while importing leaflet libraries.

Compute zonal statistics on area of interest polygon on fly

Be The First To Comment
Draft to compute zonal statistics on area of interest polygon or shape draw on leaflet using PostgreSql and Java -

Geometry extracted from leaflet as GeoJson.

Polygon-
{"type":"Feature","properties":{"desc":null,"image":null},"geometry":{"type":"Polygon","coordinates":[[[-117.103271484375,34.264026473152875],[-117.1142578125,34.14818102254435],[-117.03186035156251,34.10498222546687],[-116.91925048828124,34.14363482031264],[-116.94946289062499,34.25494631082515],[-117.0867919921875,34.252676117101515],[-117.103271484375,34.264026473152875]]]}}


{"type":"Feature","properties":{"desc":null,"image":null},"geometry":{"type":"Polygon","coordinates":[[[-116.86981201171875,34.11407854333859],[-116.86981201171875,34.24132422972854],[-116.71874999999999,34.24132422972854],[-116.71874999999999,34.11407854333859],[-116.86981201171875,34.11407854333859]]]}}

Point-
{"type":"Feature","properties":{"desc":null,"image":null},"geometry":{"type":"Point","coordinates":[-116.9879150390625,34.048108084909835]}}


Area of GeoJson
Select (ST_Area(ST_GeomFromText
('POLYGON ((-117.16918945312501 34.27083595165,-117.1307373046875 34.166363384737892,-117.00988769531251 34.161818161230386,-116.93298339843751 34.239053668516412,-116.98516845703126 34.27083595165,-117.16918945312501 34.27083595165))',4326)))



Zonal statistics for each raster tile -

SELECT rid, (ST_SummaryStats (ST_Clip(rast,ST_GeomFromText('POLYGON ((-117.16918945312501 34.27083595165,-117.1307373046875 34.166363384737892,-117.00988769531251 34.161818161230386,-116.93298339843751 34.239053668516412,-116.98516845703126 34.27083595165,-117.16918945312501 34.27083595165))',4326),true))).*
FROM public.biodiv_ssolnw_wgs84
WHERE ST_Intersects
(rast,ST_GeomFromText
('POLYGON ((-117.16918945312501 34.27083595165,-117.1307373046875 34.166363384737892,-117.00988769531251 34.161818161230386,-116.93298339843751 34.239053668516412,-116.98516845703126 34.27083595165,-117.16918945312501 34.27083595165))',4326))
Group By rid

 

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

About Me