|
POST
|
To add Point_X and Point_Y attribute fields to a feature to export to csv or excel table, I like to use: spatial_reference = arcpy.SpatialReference("WGS 1984")
# AddGeometryAttributes_management (Input_Features, Geometry_Properties, {Length_Unit}, {Area_Unit}, {Coordinate_System})
arcpy.AddGeometryAttributes_management(featurename,"POINT_X_Y_Z_M","#","#",spatial_reference)
... View more
04-28-2017
09:32 AM
|
2
|
0
|
1129
|
|
POST
|
I would suggest looking at the ArcGIS REST API. (To query, see the Query (Feature Service/Layer) in the Your Services >> Feature Service section.) You may also find the github ArcREST files helpful. This thread may also be of help: ArcREST vs ArcGIS Python API.
... View more
04-27-2017
01:08 PM
|
1
|
0
|
2571
|
|
POST
|
I've been experimenting with the following code to assist with symbology using layer files. It might give you some ideas. # list of layer names to work with
names = ['MyLayer']
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]
layers = arcpy.mapping.ListLayers(mxd, "*", df)
for layer in layers:
if layer.name in names:
print layer.name, layer.dataSource
# may want to check this value to see if symbology can be used
print layer.symbologyType
# save as a layer file
# http://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/save-to-layer-file.htm
# SaveToLayerFile_management (in_layer, out_layer, {is_relative_path}, {version})
arcpy.SaveToLayerFile_management(layer.name,"C:/Path/"+layer.name+".lyr")
# apply symbology (if symbology is not too complex)
# http://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/apply-symbology-from-layer.htm
# ApplySymbologyFromLayer_management (in_layer, in_symbology_layer)
arcpy.ApplySymbologyFromLayer_management(layer.name,"C:/Path/"+layer.name+".lyr")
arcpy.RefreshTOC()
arcpy.RefreshActiveView()
... View more
04-27-2017
11:02 AM
|
0
|
0
|
3520
|
|
POST
|
After running the tool in ArcMap, if you go to Geoprocessing > Results and right-click on Calculate Field and select Copy As Python Snippet, it produces the following code: # ArcMap 10.2.1 - Fails, doesn't like """"aaa""""
arcpy.CalculateField_management("DemandPoints1","from1",""""aaa"""","PYTHON_9.3","#")
# ArcMap 10.5 - Success
arcpy.CalculateField_management(in_table="DemandPoints1", field="from1", expression="'aaa'", expression_type="PYTHON_9.3", code_block="") Here are other variations I have tried: arcpy.CalculateField_management("DemandPoints1","from1","{}".format("aaa"),"PYTHON_9.3","#") # fails
arcpy.CalculateField_management("DemandPoints1","from1","{}".format("'aaa'"),"PYTHON_9.3","#") # success
arcpy.CalculateField_management("DemandPoints1","from1",'aaa',"PYTHON_9.3","#") # fails
arcpy.CalculateField_management("DemandPoints1","from1","aaa","PYTHON_9.3","#") # fails
arcpy.CalculateField_management("DemandPoints1","from1","'aaa'","PYTHON_9.3","#") # success
... View more
04-25-2017
10:36 AM
|
0
|
0
|
2453
|
|
POST
|
In your case, since you are using Server, you might be able to use the Add Geometry tool to populate latitude and longitude fields named POINT_X and POINT_Y. If you are not "collecting" features, but working with an existing set of point features, this is the method I would suggest. In my testing, I was using AGOL. I would query the geometry of each point and use ".projectAs" to obtain the latitude and longitude and then update the appropriate fields. A python script would automate this process and use the REST API.
... View more
04-25-2017
09:50 AM
|
0
|
0
|
2264
|
|
POST
|
If you have the fields in your feature to collect the GPS metadata (for example, the ESRIGNSS_LATITUDE and ESRIGNSS_LONGITUDE fields), Collector will pull this data from your internal/external GPS receiver. You can configure these fields to be displayed in Collector's pop-up, and you might be able use these fields to construct your link for Survey123. This would be an option for new points that you are adding to your feature. For existing data, you would need to extract the latitude/longitude from the geometry using a tool like Add Geometry Attributes. You can also do this using a python script with "projectAs" (see example script in this thread). Edit: I have been experimenting with Collector and GPS metadata and have used the latitude/longitude fields to create a hyperlink to another ESRI app called Trek2There. The link looks like: arcgis-trek2there://?stop={ESRIGNSS_LATITUDE},{ESRIGNSS_LONGITUDE} If you "Collect Here" instead of collecting at the GPS location, the latitude/longitude metadata will be missing because the fix is invalid. In these situations, I have been able to update the latitude/longitude fields. So, you should be able to hyperlink from Collector to Survey123.
... View more
04-19-2017
10:33 AM
|
1
|
2
|
2264
|
|
POST
|
If you are using Collector to "collect" new points, you could set-up your feature layer to capture GPS metadata fields which include latitude and longitude fields. For an existing feature, you could use the REST API to populate latitude and longitude fields from the point's geometry. Are you using AGOL or server/portal?
... View more
04-18-2017
12:32 PM
|
0
|
4
|
2264
|
|
POST
|
Most of the arcpy versioning tools require the standard or advanced license as well.
... View more
04-18-2017
11:53 AM
|
0
|
0
|
612
|
|
POST
|
It helps to format your code when posting to Geonet; see Code Formatting... the basics++ I like to use arcpy's TableToExcel function. # TableToExcel_conversion (Input_Table, Output_Excel_File, {Use_field_alias_as_column_header}, {Use_domain_and_subtype_description})
# NAME/ALIAS and CODE/DESCRIPTION
arcpy.TableToExcel_conversion(featurename,xlsfile,"NAME","CODE")
arcpy.TableToExcel_conversion(featurename,xlsfile2,"ALIAS","DESCRIPTION")
... View more
04-18-2017
11:45 AM
|
0
|
0
|
2404
|
|
POST
|
From Layer Help: print lyr.name, lyr.dataSource, lyr.datasetName Also, you may have an indentation error on line 20-21.
... View more
04-17-2017
02:50 PM
|
2
|
0
|
3779
|
|
POST
|
You can use the REST API to edit the feature's json file. Domains are listed in the fields section, and looks something like (in the case of a field named "Informed"): {
"name" : "Informed",
"type" : "esriFieldTypeString",
"alias" : "2 Employees informed of laws",
"sqlType" : "sqlTypeOther",
"length" : 1,
"nullable" : false,
"editable" : true,
"domain" :
{
"type" : "codedValue",
"name" : "YN",
"codedValues" : [
{
"name" : "?",
"code" : "?"
},
{
"name" : "No",
"code" : "N"
},
{
"name" : "Yes",
"code" : "Y"
}
]
},
"defaultValue" : null
},
If you decide to edit the json, I would also suggest looking at the "types" section in case the field needing modification is used in symbology. This section may also require editing. To get to the json file, in My Content, click on the feature layer. From the layer's Overview tab, look in the Layers section and click on "Service URL". You should get a page with a link indicating "JSON". To update the json you need to be in the Administration directory. Use the API Reference link for additional help. If you haven't edited a json file, do some testing with a backup.
... View more
04-07-2017
01:11 PM
|
0
|
0
|
1524
|
|
POST
|
I noticed "Arrow Size". If this will become a field name, don't forget to remove/replace the space.
... View more
04-03-2017
10:13 AM
|
1
|
0
|
2266
|
|
POST
|
My suggestions. # Third double quote in this line should be a colon
jData = json.loads('{ "features" " ' + fp.read().decode("utf-8-sig").encode("utf-8") + '}')
# Corrected
jData = json.loads('{ "features" : ' + fp.read().decode("utf-8-sig").encode("utf-8") + '}')
# An alternative, which may actually be better ....
# create an empty dictionary of features
jData = { "features" : None }
with open(filename, 'r') as fp:
# read json and insert data into jData features dictionary
jData["features"] = json.loads(fp.read())
# I also deleted the utf-8 decode/encode which may not be needed
... View more
04-03-2017
10:10 AM
|
1
|
2
|
2266
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 10-27-2016 02:23 PM | |
| 1 | 09-09-2017 08:27 PM | |
| 2 | 08-20-2020 06:15 PM | |
| 1 | 10-21-2021 09:15 PM | |
| 1 | 07-19-2018 12:33 PM |
| Online Status |
Offline
|
| Date Last Visited |
02-12-2026
07:13 PM
|