|
POST
|
I've got a feature class that I am trying to remove the Global ID and editor information fields from. So far, the best way I can figure out is to create a new version of the feature class without the fields and append the data across. I've tried the following code I found online and tweaked, but am stuck on the field mapping. The input FC is "Prod_Temp" and I want the output to be "Prod_Sync". The fields listed in myfields are the fields in "Prod_Temp" that I want to retain. When I run the script, it complains about something around Line 10. I think I'm misunderstanding the input option for map.addInputField(existingFC, field). Any pointers? # feature class I want to copy from
existingFC = (r"W:\TEMP\Prod_Temp.gdb\Prod_Temp")
# list of fields I want to keep (capitalization counts!)
myfields = ['FPCBusinessArea', 'Location', 'OpType', 'OperationStatus', 'Contractor', 'ContractorSupervisor', 'SupervisorPhone', 'FPCOIC', 'FPCOICPhone', 'Machinery', 'Comments', ]
# create an empty field mapping object
mapS = arcpy.FieldMappings()
# for each field, create an individual field map, and add it to the field mapping object
for field in myfields :
map = arcpy.FieldMap()
map.addInputField(existingFC, field)
mapS.addFieldMap(map)
# copy the feature class using the fields you want
Prod_Sync = arcpy.FeatureClassToFeatureClass_conversion(existingFC, r"W:\TEMP\Prod_Sync.gdb", "Prod_Sync", "", mapS)
... View more
11-20-2019
12:24 AM
|
0
|
2
|
4676
|
|
POST
|
I have an ArcGIS Pro project with 2 maps and a layout. I have an ArcOnline feature service loaded in which has labels. I am attempting to convert those labels to Annotation so that I can move some of them off of the feature they are covering up (also tried doing this through the Maplex positioning functions and haven't had much luck there either). In the map window, I right-click the labelled layer and select "Convert Labels to Annotation...". I then check all the settings in the Geoprocessing window to be the correct map, convert Single Layer, reflect the correct layer, have the scale set to 1:10,000 (matches the map reference scale), I've selected an output GDB, changed the suffix (and tried leaving as default too), checked the Extent is the same as Current Display Extent and then "Run". It supposedly runs successfully but the output Annotation layer is empty - and I'm at a loss as to why!!! We had one run actually successful with 3 labels (by accident trying to show a colleague the issue) and now can't repeat it. Yes, ArcGIS Pro is the latest version too.
... View more
11-11-2019
05:59 PM
|
0
|
5
|
4058
|
|
POST
|
Sorry for the delayed response. Nope, I didn't really find a solution in ArcMap. I'm really trying to avoid ArcMap now and instead using ArcGIS Pro for anything related to AGOL editing. No downloading or synchronizing required so works much better with Model Builder and arcpy.
... View more
11-11-2019
05:30 PM
|
0
|
1
|
1750
|
|
POST
|
A handy trick from myself is if you open something and it doesn't appear (i.e. is hidden off the screen somewhere), press and hold the Windows button and press the Left or Right Arrow key. This will move the active Window to automatically fill half of the screen that it is on, making the window visible if it is hiding somewhere. Windows + Up will make the active window fill the whole screen.
... View more
09-25-2019
11:41 PM
|
25
|
8
|
12113
|
|
POST
|
That ol' chestnut. Thankfully, whoever wrote the sample code I used took that into consideration and they're filtered out!
... View more
03-07-2019
08:33 PM
|
0
|
0
|
1885
|
|
POST
|
Hi Dan. Not exactly. The GDB does contain a single feature class, though what this script is intended to do is zip all of the files within a gdb as if you were viewing it through windows explorer (i.e. below). A colleague has helped out and found the solution was with the Return call at the end being incomplete. It should have looked like this [Zipfgdb() as the last line]; #Close zipfile object
ZIP.close()
#Return zipfile full path
return zipfl
Zipfgdb() GDB; ZIP;
... View more
03-07-2019
04:44 PM
|
0
|
2
|
1885
|
|
POST
|
I have a basic python code that is intended to take the contents of a File GDB and ZIP them (not that actual .gdb itself though). When I test the code it says it's all good. When I run the code however, it goes straight to "Exit Code 0" and nothing happens. No new ZIP file, nothing. Any ideas where I'm going wrong? import os
import shutil
import zipfile
# Creates a zip file containing the input shapefile
# inFileGDB: Full path to FileGDB folder to be zipped
# Delete: Set to True to delete fileGDB files after zip
# Creates a zip file containing the contents of a filegeodatabase
def Zipfgdb(inFileGDB = r'\\my\data\pathway\MyData.gdb', Delete = 'False'):
print inFileGDB + " : Delete original files = " + Delete
#Directory of file geodatabase
inLocation = os.path.dirname (inFileGDB)
print "inLocation: " + inLocation
#Base name of shapefile
inName = os.path.basename (os.path.splitext(inFileGDB)[0])
print "inName: " + inName
#Create the zipfile name
zipfl = os.path.join (inLocation, inName + ".zip")
print "New ZIP file: " + zipfl
#Create zipfile object
ZIP = zipfile.ZipFile (zipfl, "w")
print "ZIP file created"
#Iterate files in shapefile directory
for fl in os.listdir (inFileGDB):
#Get full path of file
inFile = os.path.join (inFileGDB, fl)
#Add file to zipfile. exclude any lock files
if os.path.splitext(fl)[1][1:] <> 'lock':
ZIP.write(inFile,fl)
print "files added to ZIP file"
#Delete filegeodatabase if indicated
if Delete == True:
shutil.rmtree(inFileGDB)
print "Original file deleted"
#Close zipfile object
ZIP.close()
#Return zipfile full path
return zipfl
... View more
03-06-2019
09:04 PM
|
0
|
4
|
1991
|
|
POST
|
Can someone please explain to me what the perceived benefits of using Contingent Values are instead of using SubTypes? Contingent values—Geodatabases | ArcGIS Desktop I understand that by using Contingent values you essentially have 2 lists (Domains), with the 2nd list being filtered by the selection from the first list. This compares to Subtypes where the selection of the first list would determine which secondary list another field looks to (multiple lists to pick from). Also, what I can't find anywhere is if I setup data using Contingent Values and publish the layer as a service to ArcOnline, will the Contingent values be honoured (and be editable via the Data tab on the service overview page as you can with Domains)?
... View more
02-04-2019
07:00 PM
|
2
|
6
|
5598
|
|
POST
|
Thanks for the tip. Linkkey should be unique as well so this shouldn't be an issue for us. Good to know how to deal with it if this were the case though.
... View more
11-25-2018
04:33 PM
|
0
|
1
|
2608
|
|
POST
|
I have 2 dictionaries (A and B). A is a new list of keys which is being checked against B. If a key is in B but not A (is an old value), I'm attempting to get the first value from the associated key in the dictionary (in this case an OBJECTID). The issues I'm having are with line 32. As far as I can tell, this should iterate through all the keys in B, see if they're in A, and if not, write their value to a text file. As it happens, the text file is just getting the full list of old values (dictionary B) instead of only the ones not in both feature classes/dictionaries. Where are we going wrong? I've attached the output text file import arcpy
# Set environmental variables
arcpy.env.overwriteOutput = True
new = r"W:\Mapping\ArcGIS Online\ArcGIS Online Features.gdb\Collector_patch" #new feature class
old = r"W:\Mapping\ArcGIS Online\Upload.gdb\AGOL_Export" #old feature class
field = 'LinkKey', 'OBJECTID' #feature class fields to compare & return
fout = r"W:\Mapping\ArcGIS Online\FPC Plantations Features to Delete.txt" #output text file
a = {}
b = {}
#The old feature class is loaded into dictionary b
with arcpy.da.SearchCursor(old, (field)) as rows:
for row in rows:
if row[0] not in b:
b[row[0]] = [row[1]]
#The new feature class is loaded into dictionary a
with arcpy.da.SearchCursor(new, (field)) as rows:
for row in rows:
if row[0] not in a:
a[row[0]] = [row[1]]
#Below compares the dictionaries and extracts features with old Linkkeys"
fo = open(fout, "w")
for k, v in b.iteritems():
if k not in a.items()[0]:
print k
print v
fo.write(str(v[0]) + ',')
print "Linkkeys not in new feature class exported"
fo.close()
... View more
11-23-2018
12:13 AM
|
1
|
5
|
2831
|
|
POST
|
I think it must have been the pathway. It was meant to be a complete path but I think the "gis" part was an alternative to the actual path of "bun-gis-01". I tweaked it and it worked so hopefully it keeps working. Thanks!
... View more
10-10-2018
12:38 AM
|
0
|
0
|
1177
|
|
POST
|
I've got a pretty simple script that looks for the latest/newest file in a folder and copies it into a new location. The script works fine when run through a python GUI, but when run as a part of an Arc model, fails. Can someone translate the error for me? I don't understand why this is happening? import glob
import os
import shutil
import time
date = time.strftime("%Y-%m-%d")
dst = "//10.253.2.161/cddp/Bunbury Use Only/GeoMasterPatchArchives/" + date
list_of_files = glob.glob('//gis/Geomaster/*.bak') # * means all if need specific format then *.csv
latest_file = max(list_of_files, key=os.path.getctime)
shutil.copy(latest_file, dst)
print latest_file + " copied to backup folder"
... View more
10-09-2018
07:28 PM
|
0
|
2
|
1280
|
|
POST
|
Where did you change these settings? I can't see anything in our Organisations AGOL account on the web.
... View more
09-20-2018
05:23 PM
|
0
|
1
|
2573
|
|
POST
|
I found a solution. I had a niggling feeling that it was the comparisons between original and current extent that was not behaving the way I expected. I originally thought this would be the best indication of the map having moved/changed based on the features in the layers. After seeing the scale print statements and how fine they were (i.e. oldscale = 404659.559547) I figured it would be highly unlikely these would ever occur twice. Thus, I changed the code from comparing original and current extent to scales and now it works as expected. Can't thank you enough for your help with this!
... View more
09-18-2018
07:08 PM
|
0
|
0
|
893
|
|
POST
|
Thanks for your help. Glad we at least got the index issues sorted! I'll have to look into python 3. Anything in particular here that won't talk in the new version? I'm guessing the syntax has changed?
... View more
09-18-2018
07:03 PM
|
0
|
1
|
893
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | Thursday | |
| 1 | 08-24-2025 06:11 PM | |
| 1 | 3 weeks ago | |
| 1 | 10-08-2024 09:01 PM | |
| 1 | 06-05-2025 12:17 AM |
| Online Status |
Offline
|
| Date Last Visited |
Thursday
|