|
POST
|
My requirements pass. When i run that block of code in 2.7 and 3.6 i had the same stuff open. I restarted my PC and just run the script with python 2.7 the process took 10 secs. Then i closed python2.7 and opened python 3.6 and run the code it took 16 min 40 secs. Seem like the issue has to do with python 3.6 because i run the exactly same code. My python 2.7 is 32 bit, my 3.6 is 64 bit if that makes a difference.
... View more
02-05-2019
01:39 PM
|
0
|
3
|
2740
|
|
POST
|
Yes because the field mapping rearranges the fields which is linked to a reporting tool. Unless there is another way to rearrange the fields? All my data is on my local PC, i have noticed slowness with Pro 2.2. I haven't upgraded to Pro 2.3 yet.
... View more
02-05-2019
11:11 AM
|
0
|
6
|
2740
|
|
POST
|
With Dan Petterson suggestions it took 16 min 40 secs in Python 3.6.
... View more
02-05-2019
10:33 AM
|
0
|
8
|
2740
|
|
POST
|
Joshua, Yes very same computer. None of the code was changed.
... View more
02-05-2019
08:15 AM
|
0
|
0
|
2740
|
|
POST
|
It's always been the way i have done it. Thanks for the suggestion i will try it out.
... View more
02-05-2019
08:14 AM
|
0
|
0
|
2740
|
|
POST
|
I am trying to test some of my 2.7 python scripts on 3.6 python and i noticed a huge difference on amount of time it takes to run the FeatureClassToFeatureClass_conversion process. so with 3.6 python the process took 18 min 5 secs, with 2.6 python it took only 8 seconds. Does anyone know why the it take much longer in 3.6 Python? This is what i am using, there is more fields than this i just removed a lot of them. PT1 = "C:/Temp/Scratchworkspace.gdb/Drain"
def Layers15(PT1):
FieldMapString = "" \
+ """PIN "PIN" true true false 13 Text 0 0 ,First,#,""" + PT1 + """,Pin,-1,-1;"""\
+ """ACRES "ACRES" true true false 4 Double 0 0 ,First,#,""" + PT1+ """,ACRES,-1,-1;"""\
+ """Instrument "Instrument" true true false 10 Text 0 0 ,First,#,""" + PT1 + """,Instrument,-1,-1;"""\
+ """SiteAddres "SiteAddres" true true false 106 Text 0 0 ,First,#,""" + PT1 + """,SiteAddres,-1,-1;"""\
+ """SiteCity "SiteCity" true true false 32 Text 0 0 ,First,#,""" + PT1 + """,SiteCity,-1,-1;"""\
+ """SiteZip "SiteZip" true true false 10 Text 0 0 ,First,#,""" + PT1 + """,SiteZip,-1,-1;"""\
+ """SubName "SubName" true true false 20 Text 0 0 ,First,#,""" + PT1 + """,SubName,-1,-1;"""\
fieldmappings = arcpy.FieldMappings()
fieldmappings.loadFromString(FieldMapString)
return fieldmappings
def main(args=None):
if args is None:
args = sys.argv
# Process: Feature Class to Feature Class
arcpy.FeatureClassToFeatureClass_conversion(PT1, "C:/Temp/Scratchworkspace.gdb", "PT_ALL","", Layers15(PT1),"")
... View more
02-04-2019
12:11 PM
|
0
|
15
|
4106
|
|
POST
|
I got it to work the the following, thanks for the help. import arcpy, os, sys
p = arcpy.mp.ArcGISProject("CURRENT")
folder = os.path.dirname(p.filePath)
fullfilename = os.path.basename(p.filePath)
filename = os.path.splitext(fullfilename)
name = filename[0]
pdfname = name + '.pdf'
outpdf = folder + "/" + pdfname
l = p.listLayouts()[0]
l.exportToPDF(pdfname,resolution = 300)
... View more
01-29-2019
03:40 PM
|
0
|
1
|
2047
|
|
POST
|
I was trying to run it in Pro's Python window, is this not allowed? can you not set the os.path.dirname so you won't have to give the full path name?
... View more
01-29-2019
02:19 PM
|
0
|
0
|
2047
|
|
POST
|
I am trying to export a project to pdf. With arcpy.mapping i had the following and worked import arcpy, os, sys
mxd = arcpy.mapping.MapDocument("CURRENT")
folder = os.path.dirname(mxd.filePath) # H:/GIS_Data
fullfilename = os.path.basename(mxd.filePath) # junk.mxd
filename = os.path.splitext(fullfilename) # [junk, mxd]
name = filename[0] # junk
pdfname = name + '.pdf' # junk.pdf
outpdf = folder + "/" + pdfname # H:/GIS_Data/junk.pdf
arcpy.mapping.ExportToPDF(mxd, pdfname, "PAGE_LAYOUT",0 ,0 ,"210") I am attempting to do this with ArcGIS Pro arcpy.mp and have the following but having a hard time getting it started. I get AttributeError: 'str' object has no attribute 'listLayouts' with the following. import arcpy, os, sys
p = arcpy.mp.ArcGISProject("CURRENT").filePath
l = p.listLayouts()[0]
l.exportToPDF(R"C:\temp\Ex1_WA.pdf", 'CURRENT',0 ,0 ,"210")
... View more
01-29-2019
10:44 AM
|
0
|
5
|
2233
|
|
POST
|
So i tried two different approaches. I am not sure which one is correct but they seem to be working. Do these seem like reasonable approaches? 1st approach result = arcpy.GetCount_management(FcLyr)
count = int(result.getOutput(0))
print(count)
if count == 0:
arcpy.Append_management(FcLyr2, FcLyr)
print "Layer empty, appending features " + FcLyr
else:
print "layer has features " + FcLyr 2nd approach Count = int(arcpy.GetCount_management(FcLyr).getOutput(0))
if Count > 0:
print("Lyr has features")
else:
arcpy.Append_management(FcLyr2, FcLyr)
print("Lyr append completed successfully")
... View more
12-14-2018
08:18 AM
|
0
|
1
|
3778
|
|
POST
|
How do you check if a feature class is empty and if it's empty append features to that feature class, if it's not not empty it would just pass or ignore the append. Would it best to use count or arcpy.da.SearchCursor? with arcpy.da.SearchCursor(FcLyr, "SHAPE@")as cursor:
for row in cursor:
if row[0] is None:
arcpy.Append_management(FcLyr2, FcLyr)
else:
print 'Has features'
... View more
12-13-2018
01:35 PM
|
0
|
3
|
3894
|
|
POST
|
I took your guys recommendations and came up with the following, not sure if this correct or the best way but it seem to work. arcpy.CopyFeatures_management(Taxparcels, "in_memory\TaxPar")
arcpy.MakeFeatureLayer_management("in_memory\TaxPar", "TaxPar")
query = "DXF_TEXT LIKE 'Q%' or DXF_TEXT = ' ' or DXF_TEXT IS NULL"
with arcpy.da.SearchCursor("TaxPar", "DXF_TEXT") as cursor:
for row in cursor:
if row[0] in (""," ",None,"Q%"):
arcpy.SelectLayerByAttribute_management("TaxPar", "NEW_SELECTION", query)
if int(arcpy.GetCount_management("TaxPar").getOutput(0)) > 0:
arcpy.DeleteFeatures_management("TaxPar")
else:
pass
... View more
11-28-2018
08:32 AM
|
0
|
1
|
6526
|
|
POST
|
Ok, so after pulling my hair out with this issue. I noticed that it removed the blanks and nulls from the original dataset not the dataset in MakeFeautreLayer_management. Why is it working off the original dataset? Should i be checking to see if there are attributes with 'Q', ' ' & NULL first? If so how do check with arcpy.SelectLayerByAttribute_management?
... View more
11-28-2018
07:47 AM
|
0
|
2
|
6526
|
|
POST
|
I am not sure what you mean by change the layer name to "TAX1", i was trying to create a feature layer In_memory to work with which is why i have line 3. I was thinking my query syntx was wrong.
... View more
11-27-2018
03:18 PM
|
0
|
2
|
6526
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 10-27-2022 11:37 AM | |
| 1 | 10-31-2023 10:16 AM | |
| 1 | 02-16-2023 01:50 PM | |
| 1 | 08-11-2021 11:13 AM | |
| 1 | 01-06-2021 10:45 AM |
| Online Status |
Offline
|
| Date Last Visited |
09-10-2024
10:42 AM
|