|
POST
|
If you are running the script outside of ArcMap, I think your "out_table_name" should be something like "dbname.gdb\tablename". Try these changes: # add os to your includes:
include os
# change DomainToTable line to
arcpy.DomainToTable_management(gdb, domain_name, gdb + os.sep + out_table_name, "item", "descrip")
... View more
08-14-2015
08:20 PM
|
0
|
4
|
4094
|
|
POST
|
Here's another approach for you to consider. It involves three steps after you enter your points. Do a spatial join with the points and polygon features. Copy the fields from the join output to your point layer. Populate the Point_X and Point_Y fields in your point layer. I found a script (with some explanation) here that does part of the process. All that was needed was getting the x and y data. The script overwrites the spatial join each time it is run. If field names are the same in both point and polygon layers, you may need to append a "_1" to field names. I ran a spatial join to see how the field names were created and then adjusted the script. The script can be run outside of ArcMap; close the map/layers to avoid any schema locks. # Import arcpy module
import arcpy
# scratch spatial join feature
sjpoints = r"C:\path\to\geodatabase.gdb\test_join"
# define the field list from the spatial join to transfer
# you can add more field names such as: ["TARGET_FID", "Field", "AnoterField"]
sourceFieldsList = ["TARGET_FID", "Field"]
# point feature that will be updated
pointLayer = r"C:\path\to\geodatabase.gdb\point_fc"
# polygon feature that will be used
polygonLayer = r"C:\path\to\geodatabase.gdb\poly_fc"
# define the field list to the original points
updateFieldsList = ["OID@", "xferField"]
# Allow overwrite of join results
arcpy.env.overwriteOutput = True
#Run the Spatial Join tool, using the defaults for the join operation and join type
arcpy.SpatialJoin_analysis(pointLayer, polygonLayer, sjpoints)
# populate the dictionary from the polygon
valueDict = {r[0]:(r[1:]) for r in arcpy.da.SearchCursor(sjpoints, sourceFieldsList)}
with arcpy.da.UpdateCursor(pointLayer, updateFieldsList) as updateRows:
for updateRow in updateRows:
keyValue = updateRow[0]
if keyValue in valueDict:
for n in range (1,len(sourceFieldsList)):
updateRow = valueDict[keyValue][n-1]
updateRows.updateRow(updateRow)
del valueDict
# Use AddGeometryAttributes to set Point_X and Point_Y
# SpatialReference("WGS 1984") to display in Lat-Long
arcpy.AddGeometryAttributes_management(Input_Features = pointLayer,
Geometry_Properties="POINT_X_Y_Z_M",
Length_Unit="", Area_Unit="",
Coordinate_System=arcpy.SpatialReference("WGS 1984"))
... View more
08-10-2015
11:09 PM
|
2
|
2
|
1645
|
|
POST
|
To change to the admin directory for your feature layer, you should be able to insert /admin/ between /rest/ and /services/ in the URL. Then you should have an update link for the feature, probably at the bottom of the page. See this blog for more information: Updating Hosted Feature Services in ArcGIS Online. I can't answer the two questions re fixing this issue and dynamic workspace. Sorry.
... View more
08-07-2015
04:03 PM
|
0
|
2
|
1290
|
|
POST
|
I am not familiar with Portal's layout, but it may be similar to ArcGIS Online. Go to MyContent and click on the layer you are having issues with. There are sections for description, access, properties, etc. There should be a link in the Layers section that will take you to the Service URL (REST Services Directory). You should see a link near the top for the JSON file. This file describes your feature layer. Toward the bottom, you will see a section called "types" which works with the symbology of your feature. What you will probably find is the items in this section do not appear in order by the "id" - in your case, the crop ID codes. You can save this file and use the python code here to extract and sort the "types" list. Change the names of the input and output files in the code to suit your needs. Then you can use the administrator REST API to update the types section. IMPORTANT: Try this with a backup of your layer so you know how (and if) it works.
... View more
07-31-2015
06:58 PM
|
0
|
4
|
1290
|
|
POST
|
I've had similar problems. For some reason the "types" section gets out of order. See the discussion here to determine if this is the issue you're having.
... View more
07-31-2015
03:24 PM
|
2
|
6
|
1290
|
|
POST
|
You should be able to do this with a Python script using REST services. This blog explains "Using Python to push updates to a hosted feature service from an external source. Instead of the external source, you would query your own data. The process would go something like this: Log into your feature services rest URL and get a token. Query your feature for points containing null latitude/longitude fields (or where the edit date meets selection criteria) to get the points' geometry and ObjectID attribute. If the feature uses a projection other than WGS 84, you can use arcpy's PointGeometry().projectAs to get a latitude and longitude. Update the points by sending the ObjectID with related lat/lon data. You can set the script to run a preset times, or it can be run manually.
... View more
07-30-2015
09:56 AM
|
0
|
1
|
1404
|
|
POST
|
Looking at your feature layer properties (via My Content), does it indicate sync is enabled? If not, can you edit the property and check enable sync?
... View more
07-29-2015
11:44 AM
|
0
|
2
|
2070
|
|
POST
|
What about the properties of your feature layer? Under My Content, you should see a link with the feature's name that will take you to the service URL (REST API). On the next page near the top, you should find a link for JSON. Near the bottom of the JSON you should see a line like this: "capabilities" : "Create,Delete,Query,Update,Editing,Sync". It should include "sync". Also, could you briefly describe how you create the feature layer? Do you start in ArcMap and publish it from there?
... View more
07-29-2015
09:45 AM
|
0
|
8
|
2070
|
|
POST
|
First, check the properties of your layer. "Sync" should be enabled. Sounds like you have done this. Also check the properties of your map. There is a property called "Offline Mode" which also needs to be enabled.
... View more
07-28-2015
02:42 PM
|
0
|
10
|
2070
|
|
POST
|
Here is an example using projectAs: import arcpy
# From WGS 1984 : (4326)
x = -77.035286
y = 38.889469
# Into WGS 1984 Web Mercator (auxiliary sphere) : (3857)
ptGeometry = arcpy.PointGeometry(arcpy.Point(x,y),arcpy.SpatialReference(4326)).projectAs(arcpy.SpatialReference(3857))
print ptGeometry.JSON
print ptGeometry.firstPoint.X, ptGeometry.firstPoint.Y
... View more
07-27-2015
10:00 AM
|
2
|
1
|
965
|
|
POST
|
There should be a section for "fields" in the file somewhere that would give you some of the info you seek. You can use the REST API to update schema. Check out this blog: Updating Hosted Feature Services in ArcGIS Online. If you wish to do this, work with a copy of the feature for experimenting, make backups, etc. If you are using collector in offline mode, I would suggest that users sync all data, remove the map and reload it after successful changes made.
... View more
07-09-2015
01:18 PM
|
0
|
0
|
813
|
|
POST
|
Try taking a look at the REST API for the JSON file. In "My Content" click on the feature layer you're interested in. When the page loads, you will find a link under "Layers" that will take you into the rest api. Near the top of rest api page is a link for "JSON". That may have what you need.
... View more
07-09-2015
12:35 PM
|
1
|
2
|
813
|
|
POST
|
As I mentioned in a previous post, using the ArcREST package is the way to go. I also found some code in this blog that explains using the REST API to update a feature layer. With that, I came up with the following code. There are three basic steps, get a token, use the token to get the JSON for the feature, and extract the portion of data you are interested in. import urllib
import urllib2
import json
import sys
import time
import collections
# Credentials and feature service information
username = "<username>"
password = "<password>"
# Feature server url, change to your server url
fsURL = "http://services1.arcgis.com/<aaa123>/arcgis/rest/services/<feature>/FeatureServer/0"
# 1: obtain a token
referer = "http://www.arcgis.com/"
query_dict = { 'username': username, 'password': password, 'referer': referer }
query_string = urllib.urlencode(query_dict)
url = "https://www.arcgis.com/sharing/rest/generateToken"
token = json.loads(urllib.urlopen(url + "?f=json", query_string).read())
if "token" not in token:
print(token['error'])
sys.exit(1)
# 2: request the json data for the feature
query_dict = { "f": "json", "token": token['token'] }
jsonResponse = urllib.urlopen(fsURL, urllib.urlencode(query_dict))
# lastEditDate is in the editingInfo section of the json response
# to access other sections, change "editingInfo" to the section name ("types" for example)
# using OrderedDict keeps the file ordered as sent by server, but is not necessary
jsonOutput = json.loads(jsonResponse.read(),
object_pairs_hook=collections.OrderedDict)[u'editingInfo']
#3: extract the data required
editTime = int(jsonOutput['lastEditDate'])/1000
print "Last Edited: " + time.strftime('%c', time.localtime(editTime))
... View more
06-29-2015
12:40 PM
|
1
|
0
|
3237
|
|
POST
|
Hello Xander, I have included a sample json file below. While researching my question I came across the ArcREST package on github. In it's samples folder I found a script (query_agol_layer.py) that connects to a Feature Layer's json data. After some study of the python code, I was able to use the script to extract the lastEditDate information and convert it to a standard time format. The code also accesses other sections of the json data - the types section is one that I'm also interested in. Here's the json file. LastEditDate is on line 11. To save space, I've deleted most of the drawingInfo section at line 44 and some other parts. {
"currentVersion" : 10.3,
"id" : 0,
"name" : "<Name>",
"type" : "Feature Layer",
"displayField" : "<Display>",
"description" : "",
"copyrightText" : "",
"defaultVisibility" : true,
"editingInfo" : {
"lastEditDate" : 1433103130499
},
"relationships" : [],
"isDataVersioned" : false,
"supportsCalculate" : true,
"supportsAttachmentsByUploadId" : true,
"supportsRollbackOnFailureParameter" : true,
"supportsStatistics" : true,
"supportsAdvancedQueries" : true,
"supportsValidateSql" : true,
"supportsCoordinatesQuantization" : true,
"advancedQueryCapabilities" : {
"supportsPagination" : true,
"supportsQueryWithDistance" : true,
"supportsReturningQueryExtent" : true,
"supportsStatistics" : true,
"supportsOrderBy" : true,
"supportsDistinct" : true
},
"geometryType" : "esriGeometryPoint",
"minScale" : 0,
"maxScale" : 0,
"extent" : {
"xmin" : -20037507.842788249,
"ymin" : -30240971.458386172,
"xmax" : 20037507.842788249,
"ymax" : 30240971.458386205,
"spatialReference" : {
"wkid" : 102100,
"latestWkid" : 3857
}
},
"drawingInfo":{
.......
},
"allowGeometryUpdates" : true,
"hasAttachments" : false,
"htmlPopupType" : "esriServerHTMLPopupTypeAsHTMLText",
"hasM" : false,
"hasZ" : false,
"objectIdField" : "OBJECTID",
"globalIdField" : "GlobalID",
"typeIdField" : "Color",
"fields" : [
{
"name" : "OBJECTID",
"type" : "esriFieldTypeOID",
"alias" : "OBJECTID",
"sqlType" : "sqlTypeOther",
"nullable" : false,
"editable" : false,
"domain" : null,
"defaultValue" : null
},
{
"name" : "<FieldName>",
"type" : "esriFieldTypeInteger",
"alias" : "<FieldAlias>",
"sqlType" : "sqlTypeOther",
"nullable" : false,
"editable" : true,
"domain" :
{
"type" : "codedValue",
"name" : "Colors",
"codedValues" : [
{
"name" : "Red",
"code" : 1
},
{
"name" : "Yellow",
"code" : 2
}
]
},
"defaultValue" : null
}
],
"types" : [
{
"id" : 1,
"name" : "Red",
"domains" :
{
"Color" : {"type" : "inherited"}
},
"templates" : [
{
"name" : "Red",
"description" : "",
"drawingTool" : "esriFeatureEditToolPoint",
"prototype" : {
"attributes" : {
"Color" : 1,
"Note" : null
}
}
}
]
},
{
"id" : 2,
"name" : "Yellow",
"domains" :
{
"Color" : {"type" : "inherited"}
},
"templates" : [
{
"name" : "Yellow",
"description" : "",
"drawingTool" : "esriFeatureEditToolPoint",
"prototype" : {
"attributes" : {
"Color" : 2,
"Note" : null
}
}
}
]
}
],
"templates" : [],
"supportedQueryFormats" : "JSON",
"hasStaticData" : false,
"maxRecordCount" : 1000,
"capabilities" : "Create,Delete,Query,Update,Editing,Sync"
}
... View more
06-27-2015
07:32 PM
|
1
|
2
|
3237
|
|
POST
|
In the JSON file for a feature there is a property called "lastEditDate." Has anyone developed a python script to access this information they would be willing to share? Thanks.
... View more
06-26-2015
04:12 PM
|
1
|
6
|
9390
|
| 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 |
09-15-2025
02:54 PM
|