|
POST
|
Sounds a bit like COGO (Coordinate Geometry). There is a tool available with Standard or Advanced license. An overview of COGO When surveyors or civil engineers need to record the location of human-made features, such as land parcels, road centerlines, utility easements containing transmission lines, and oil and gas leases, they typically provide the results on a survey plan that describes the location of features relative to each other.
... View more
01-21-2018
04:35 PM
|
0
|
1
|
2882
|
|
POST
|
A dictionary version would also work: import arcpy
from arcpy import env
env.workspace = r"Path\to\filedatabase.gdb"
intable = "ElectionResults_Nov2016"
# outtable will be named Results##
# you can manually create a dictionary
tblDict = {'BALLOTS CAST - TOTAL': 'Results1',
'BALLOTS CAST - DISTRICT': 'Results2' }
for k, v in tblDict.iteritems():
print k, v
# or automatically create one by scanning the intable
tblDict = {} # empty dictionary
results = 1 # counter for output tables
for row in arcpy.da.SearchCursor(intable, "ContestTitle"):
if row[0] not in tblDict.keys():
tblDict[row[0]] = "Results{}".format(results)
results += 1 # increment results counter
# create the new tables
for k, v in tblDict.iteritems():
where_clause = "ContestTitle = '{}'".format(k)
print "Processing table '{}' where: {}".format(v, where_clause)
arcpy.TableSelect_analysis(intable, v, where_clause)
... View more
01-19-2018
06:23 PM
|
1
|
5
|
3333
|
|
POST
|
Perhaps something like: tbList = []
for row in arcpy.da.SearchCursor(intable, "ContestTitle"):
if row[0] not in tbList:
tbList.append(row[0])
for tbls in tbList:
where_clause = "ContestTitle = '{}'".format(tbls)
# Note - you will need to adjust "tbls" to be a legal table name
# no spaces, symbols, length, etc
tbls_fmt = #something to format table name here#
arcpy.TableSelect_analysis(intable, tbls_fmt, where_clause)
... View more
01-19-2018
05:00 PM
|
1
|
0
|
3333
|
|
POST
|
Is this the type of comparison you are attempting? Will you be matching the terms in parenthesis? Example: aita (gjerde) Just match "aita"? Or "gjerde" as well? Is a term like "grunnen" always at the end of the location's name?
... View more
01-17-2018
08:30 PM
|
0
|
0
|
3088
|
|
POST
|
If it is a simple rename all "earthquake_PHI" to "earthquake_PHL", then this may give you an idea. If it is a bunch of renames, you may need to use a dictionary in the renaming. import arcpy
import os
from arcpy import env
# path to search for mxd
path = r'C:\Path\To\Use"
oldShp = "earthquake_PHI" # old shapefile name without extension
newShp = "earthquake_PHL" # for replaceDataSource - does not use ".shp"
# iterates through folder searching for mxds
for fileName in os.listdir(path):
fullPath = os.path.join(path,fileName)
if os.path.isfile(fullPath) and fileName[-3:].lower() == 'mxd':
mxd = arcpy.mapping.MapDocument(fullPath)
print fullPath
for lyr in arcpy.mapping.ListLayers(mxd):
if lyr.supports("DATASOURCE"):
if oldShp in lyr.dataSource:
print "\t" + lyr.dataSource
shpPath = os.path.dirname(lyr.dataSource)
print "\t" + shpPath
shpFile = os.path.basename(lyr.dataSource)
print "\t" + shpFile
# this will replace the data source in the mxd
lyr.replaceDataSource(shpPath, "SHAPEFILE_WORKSPACE", newShp)
# if layer needs to be renamed
lyr.name = newShp
mxd.save() # save mxd changes, perhaps use: mxd.saveACopy(r"C:\Project\Output\\" + newname + ".mxd")
del mxd
... View more
01-15-2018
09:56 PM
|
2
|
1
|
3819
|
|
POST
|
As Dan Patterson mentioned, with whatever script you find, you will need to some modifications. It sounds like you will want to start with a loop to find all your MXDs, and then loop through the feature layers in each file. Here's a code example that might be of interest: Write Broken Source List to Text File. Can you explain a bit more about your situation. I am assuming that you are working with shape files (ending in .shp) and not a feature in a geodatabase. Were the shape files moved, renamed or both? If they were renamed, was there a logic/process to the renaming that can be written with code? If the files were moved, again, was there specific process used?
... View more
01-14-2018
08:42 PM
|
2
|
3
|
3819
|
|
POST
|
I don't think AddJoin likes to join shape files. The code is hard to read, but it looked like you created the shape files from feature layers created by MakeFeatureLayer. Try using these feature layers instead of the saved shape files in the AddJoin. Also see code formatting as it will help make your code easier to read. # feature "Earlier"/"EarlierFC" created at line 28
# feature "Later"/"LaterFC" created at line 35
arcpy.AddJoin_management("Later", "APN", "Earlier", "APN", "KEEP_ALL")
... View more
01-05-2018
12:07 PM
|
2
|
0
|
580
|
|
POST
|
I would suggest using a script similar to those that find broken layer files. Something like: import arcpy
import os
from arcpy import env
lyrFiles = {}
# set variables
path = r'C:\Path\to\mxds'
# iterates through folder and lists feature layers
for fileName in os.listdir(path):
fullPath = os.path.join(path,fileName)
if os.path.isfile(fullPath) and fileName[-3:].lower() == 'mxd':
mxd = arcpy.mapping.MapDocument(fullPath)
print fullPath
for lyr in arcpy.mapping.ListLayers(mxd):
if lyr.isFeatureLayer:
print "\t " + lyr.dataSource
# count layer files using dictionary
if lyr.dataSource not in lyrFiles.keys():
lyrFiles[lyr.dataSource] = 1
else:
lyrFiles[lyr.dataSource] += 1
print
for k, v in lyrFiles.items():
print k, v
... View more
01-03-2018
08:53 PM
|
2
|
1
|
3848
|
|
POST
|
I notice you have single quotes around the field names in your where clause. I think this is causing the tool to select all features because you are comparing two strings that are not equal. Try: arcpy.SelectLayerByAttribute_management("Parcel_8_Layer2", "ADD_TO_SELECTION", "Parcel_8.P_OWNER_NM = Parcel_6.P_OWNER_NM")
# no single quotes around fields in where_clause And as Rebecca Strauch, GISP suggested, you may wish to use "NEW_SELECTION".
... View more
01-03-2018
08:10 PM
|
0
|
0
|
4462
|
|
POST
|
When you get the results you want with the tool, I would suggest looking at Geoprocessing > Results. You can copy the successful run of the tool as a python snippet by right clicking on the last result. Paste this into your editor and examine the code. This will show you what the tool is actually using for the first parameter.
... View more
01-03-2018
04:33 PM
|
1
|
0
|
4462
|
|
POST
|
"NEW_SELECTION" with "INVERT" is probably the setting you would want. When you "remove it" and get an error, are you selecting another option, like "ADD_TO_SELECTION" (this defaults to new selection when omitted)? Have you tried to set the search distance to something other than 0? Or just omitting it? Also, can you elaborate on the inaccurate results. Thanks.
... View more
01-02-2018
07:51 PM
|
0
|
0
|
2239
|
|
POST
|
When you join a feature to another feature or table, the header names will be concatenations of feature/table's name, a dot, and the field's name. I suspect the naming issue you are experiencing is with the aliases of the fields. You may wish to experiment with the following code in ArcMap's python window to see the joined field names after you run the AddJoin tool. mxd = arcpy.mapping.MapDocument("CURRENT")
for f in arcpy.mapping.ListLayers(mxd):
field_info = arcpy.Describe(f).fieldInfo
for i in xrange(0,field_info.count):
print field_info.getfieldname(i) You should see something like this: Feature1.OBJECTID
Feature1.fldname1
Feature1.fldname2
Table1.OBJECTID
Table1.fldname1
Table1.fldname2
... View more
01-02-2018
07:18 PM
|
1
|
4
|
4462
|
|
POST
|
Are you using AGOL or your own server/service? Are you using an HTML form, or are you using another method for your query? In the meantime, I would suggest the following: "where" : "1=1",
"outFields" : "*",
"orderByFields" : "SellDate DESC",
"resultRecordCount" : "1"
... View more
01-02-2018
11:48 AM
|
1
|
0
|
2137
|
|
POST
|
The procedure is to log on with a username and password to get a token. Then you add the token to your query, not the username/password. I use the following for AGOL. Server/Portal is slightly different - mostly in the URLs used; I would suggest looking at Jake Skinner's Show Attachments in Web Map Popup as his script covers both versions. import urllib
import urllib2
import json
# Credentials and feature service information
username = "username"
password = "password"
URL = "https://services2.arcgis.com/abc123/arcgis/rest/services/"
# 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)
query_dict = { "f": "json", "token": token['token'] }
... View more
12-22-2017
09:39 AM
|
1
|
0
|
11034
|
|
POST
|
And actually the Spatial Reference should be Web Mercator (3857) - I didn't pay attention to the coordinates being greater/less than 180. Geojson is only supposed to use lat/lon as the crs type has been depreciated.
... View more
12-21-2017
03:34 PM
|
0
|
1
|
3452
|
| 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
|