|
POST
|
I am getting the attribute value ( 1, 2,3 ....) but not the actual value(PMT,GMT...)
... View more
10-24-2017
09:07 PM
|
0
|
0
|
2622
|
|
POST
|
Following is my complete code. I am using Arcgis 10.2.In log sub-domain is showing undefined. <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"> <title>Query distinct values without map</title> <script src="https://js.arcgis.com/3.22/"></script> <script> require([ "esri/layers/CodedValueDomain", "esri/InfoTemplate","dojo/_base/array", "esri/layers/FeatureLayer", "esri/layers/Field", "esri/tasks/QueryTask", "esri/tasks/query", "dojo/_base/lang", "dojo/dom", "dojo/on", "dojo/domReady!" ], function( CodedValueDomain, InfoTemplate,array, FeatureLayer, Field, QueryTask, Query, lang, dom, on ) { var queryTask = new QueryTask("http://localhost:6080/arcgis/rest/services/mydata/MapServer/1"); var query = new Query(); query.returnGeometry = false; query.returnDistinctValues = true; query.outFields = [ "SubtypeCD" ]; on(dom.byId("execute"), "click", execute); function execute () { query.where = '1=1'; queryTask.execute(query, showResults); } function showResults (results) { var resultItems = []; var resultCount = results.features.length; for (var i = 0; i < resultCount; i++) { var featureAttributes = results.features.attributes; for (var attr in featureAttributes) { var test=getSubtypeDomain(queryTask,featureAttributes[attr] ,"SubtypeCD"); //var codedValue = _getCodedValue(queryTask,"SubtypeCD",featureAttributes[attr]) // resultItems.push("<b>" + attr + ":</b> " + featureAttributes[attr] + "<br>"); resultItems.push("<b>" + attr + ":</b> " + test+ "<br>"); } resultItems.push("<br>"); } dom.byId("info").innerHTML = resultItems.join(""); } var subTypeVal; function getSubtypeDomain (featureLayer,fieldVal, fieldName){ if (featureLayer.typeIdField!=null) { console.log("Have Subtypes"); if (fieldName==featureLayer.typeIdField) { array.forEach(featureLayer.types, lang.hitch(this, function (lsf) { if (fieldVal==lsf.id){ fieldVal=lsf.name; subTypeVal=lsf.id; } })); } else { array.forEach(featureLayer.types, lang.hitch(this, function (lsf) { if (lsf.id==subTypeVal){ array.forEach(lsf.domains[fieldName].codedValues, lang.hitch(this, function (domain) { if (fieldVal==domain.code){ fieldVal=domain.name; } })); } })); } } else { console.log("No Subtypes"); subTypeVal=null; array.forEach(featureLayer.fields, lang.hitch(this, function (ldf) { if (ldf.name==fieldName){ if (ldf.domain){ array.forEach(ldf.domain.codedValues, lang.hitch(this, function(domain){ if (fieldVal==domain.code){ fieldVal=domain.name; } })); } } })); } console.log( fieldVal); return fieldVal; }; }); </script> </head> <body> <input id="execute" type="button" value="Get Details"> <br /> <br /> <div id="info" style="padding:5px; margin:5px; background-color:#eee;"> </div> </body> </html>
... View more
10-22-2017
10:12 PM
|
0
|
0
|
2622
|
|
POST
|
i have tried this https://community.esri.com/docs/DOC-8721-coded-domains-in-infotemplate but still no success.
... View more
10-22-2017
09:34 AM
|
0
|
0
|
2622
|
|
POST
|
I have written my code for unique values and get the count for each layer.The problem which i am getting is that my field "SubtypeCD" is domain coded value. Following code is for unique value : var unique = new QueryTask("http://localhost:6080/arcgis/rest/services/mydata/MapServer/1"); var query = new Query(); query.returnGeometry = false; query.returnDistinctValues = true; query.outFields = [ "SubtypeCD" ]; execute(); function execute () { query.where = '1=1'; unique.execute(query, showResults); } var resultItems = []; function showResults (results) { var resultCount = results.features.length; for (var i = 0; i < resultCount; i++) { var featureAttributes = results.features.attributes; for (var attr in featureAttributes) { resultItems.push( featureAttributes[attr] ); } } console.log(resultItems); } The output i am getting in resultItems are 1,2 as my field is domain coded. What i need is to read the value name description which is PMT and GMT.
... View more
10-22-2017
01:11 AM
|
0
|
6
|
4488
|
|
POST
|
thank you very much for the code but i am not using pandas.
... View more
10-12-2017
11:25 PM
|
0
|
0
|
2823
|
|
POST
|
Thank you for your help. Actually i am not using Summary Statisticsas i want to this for multiple layers and export results to csv. I am using arcgis 10.2 and dont have pandas installed.I have searched for pandas installation on 10.2 but could not find solution. Once my script is ready i have to publish GP service and use it in JavaScript API Application.
... View more
10-12-2017
11:24 PM
|
0
|
1
|
2823
|
|
POST
|
I missed desc_Domain in If statement... if not desc_Domain[row[0]] in CountUnique.keys(): I am getting the unique values but i want sum. CountUnique[desc_Domain[row[1]]] += 1 this one is for count not sum.
... View more
10-12-2017
02:26 AM
|
0
|
0
|
2823
|
|
POST
|
when i am using desc_Domain[row[0]]] it is only showing description but not count..if i use only row[0] then it is showing count.
... View more
10-12-2017
12:47 AM
|
0
|
0
|
2823
|
|
POST
|
I am writing a code for count and sum unique values and exporting results to csv. I want that to be done in a quick way.I am getting the unique values count on Field "SubtypeCD" and exporting them to csv using following code,but i need sum also on shapelength().Please guide import arcpy
import csv
import os
import io
from arcpy import env
env.overwriteOutput = True
mxd=arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "")[0]
count=0
field = ['SubtypeCD']
with open(r'D:\result.csv','wb') as resultFile:
wr = csv.writer(resultFile, dialect='excel')
for lyr in arcpy.mapping.ListLayers(mxd,"",df):
if lyr.name=="LV UG Electric Line Segment":
flds = [f.name for f in arcpy.ListFields(lyr)]
s = set(flds)
print lyr.name
if 'SubtypeCD' in s :
wr.writerow([lyr.name])
CountUnique = {}
sumUnique={}
desc_Domain = {key: value['Name'] for (key, value) in arcpy.da.ListSubtypes(arcpy.Describe(lyr).catalogPath).iteritems()}
with arcpy.da.SearchCursor (lyr,[ "SubtypeCD","Shape.STLength()"]) as cursor:
for row in cursor:
if not row[0] in CountUnique.keys():
CountUnique[desc_Domain[row[0]]] = 1
else:
CountUnique[desc_Domain[row[0]]] += 1 sumUnique+=row[1] for key in CountUnique.keys(): print str(key) + ":", CountUnique[key], "features" tr(key) ,CountUnique[key],"Features" wr.writerow(total)
... View more
10-11-2017
10:23 PM
|
0
|
8
|
7432
|
|
POST
|
Dear FC, I have created a new python addin containg 3 buttons.first my script runs to convert lines ,Construct polygon tool and then spatial join script. Can you just tell me where Construct polygon tool is located in arcgis folder??so that i can run that tool in button 1 script.
... View more
05-24-2017
02:54 AM
|
0
|
1
|
1935
|
|
POST
|
Dear Dan Patters, construct polygon using advanced editing tool or Polygon Feature class from Lines any python code or help is highly appreciated.
... View more
05-23-2017
03:40 AM
|
0
|
4
|
1935
|
|
POST
|
sorry for the broken link.Please see below: How To: Access the Polygon Feature Class From Lines command in ArcGIS 10
... View more
05-22-2017
11:42 PM
|
0
|
0
|
1935
|
|
POST
|
is it possible to create Polygon Feature class from Lines through python code?
... View more
05-22-2017
09:38 PM
|
0
|
9
|
3641
|
|
POST
|
Dear Luke, Actually my client dont have advanced license.yes i was storing only vertices coordinates and drawing a new polygon. Is it possible to construct polygon using python script? any suggestion https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fdesktop.arcgis.com%2Fen%2Farcmap%2F10.3%2Fmanage-data%2Fcrea…
... View more
05-22-2017
06:49 AM
|
0
|
1
|
477
|
|
POST
|
import arcpy
import os
from arcpy import env
env.overwriteOutput = True
starttime = time.time()
localtime = time.asctime( time.localtime(time.time()) )
# Create a value table that will hold the input feature classes for Merge
mxd=arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "")[0]
for lyr in arcpy.mapping.ListLayers(mxd,"",df):
if not lyr.isGroupLayer:
arcpy.AddMessage(lyr.name)
if "Export" in lyr.name :
break
desc = arcpy.Describe(lyr)
shapefieldname = desc.ShapeFieldName
outPolys=r'C:\RAECGIStoCAD\test.gdb\temp'
arcpy.DeleteFeatures_management(r'C:\RAECGIStoCAD\test.gdb\temp')
joinoutput=r'C:\RAECGIStoCAD\test.gdb\join'
spatialRef = arcpy.Describe(lyr).spatialReference
featureList = []
#array = arcpy.Array()
cursor = arcpy.da.InsertCursor(outPolys, ['SHAPE@'])
rows = arcpy.SearchCursor(lyr)
for row in rows:
# Create the geometry object
feat = row.getValue(shapefieldname)
#print "Feature %i: " % row.getValue(desc.OIDFieldName)
partnum = 0
part_list = []
# Step through each part of the feature
for part in feat:
polygonArray = arcpy.Array()
for pnt in feat.getPart(partnum):
if pnt:
# Add to list
part_list.append([pnt.X, pnt.Y])
polygonArray.add(arcpy.Point(pnt.X,pnt.Y))
partnum += 1
print partnum
print part_list
polygon = arcpy.Polygon(polygonArray)
featureList.append(polygon)
cursor.insertRow([polygon])
del cursor
endtime = time.time()
totaltime = endtime-starttime
print "\nScript took " + str(totaltime/60) + " minutes to run"
... View more
05-22-2017
04:23 AM
|
0
|
0
|
2576
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 12-11-2016 05:30 AM | |
| 1 | 07-11-2020 02:38 AM | |
| 1 | 12-11-2016 01:16 AM | |
| 3 | 08-29-2018 01:30 AM | |
| 1 | 12-18-2017 04:49 AM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:24 AM
|