|
POST
|
Quick hack to strip out any non-ascii characters: input = 'C:/temp/test.py'
output = 'C:/temp/test_edited.py'
input = open(input).read()
with open(output, 'w') as outf:
outf.write(input.encode('ascii', 'ignore').decode())
print(repr(input))
print(repr(open(output).read()))
Output: "tpk = r'‪C:\\Users\\jaburton\\Documents\\ArcGIS\\Projects\\VectorBasemap\\VectorTilePackage.vtpk'\n"
"tpk = r'C:\\Users\\jaburton\\Documents\\ArcGIS\\Projects\\VectorBasemap\\VectorTilePackage.vtpk'\n"
... View more
01-29-2019
04:50 PM
|
2
|
0
|
10462
|
|
POST
|
Once you get your environment back up and running... What problems were you having getting PyScripter working with Pro Python 3? I haven't used PyScripter for years, but I downloaded the 64bit version of PyScripter (v. 3.6), ran it and added the arcgispro-py3 python interpreter and could import arcpy fine. Note you must have both the 32bit and 64bit versions of PyScripter to work with Desktop (32bit) and ArcGIS Pro (64bit). You can also use the 64bit version with Desktop if you have the 64bit background geoprocessing python installed.
... View more
01-22-2019
04:00 PM
|
0
|
1
|
5957
|
|
POST
|
You can also try using the Polygon to Raster tool instead of the Feature To Raster tool and set the "Cell assignment type" parameter as "Maximum area" and specify a "Priority field". See my answer to a similar question: Feature to Raster Conversion: Missing Pixels Near Border - Geographic Information Systems Stack Exchange
... View more
12-10-2018
07:34 PM
|
1
|
0
|
3122
|
|
POST
|
If there's no errors then subprocess is working fine. It's your script that's the issue. What does `script_stdout_output` contain? Do you have any error handling that hiding any errors?
... View more
12-03-2018
08:26 PM
|
1
|
0
|
3920
|
|
POST
|
Try something like: script_stdout_output = subprocess.check_output([os.path.join(sys.exec_prefix, 'python.exe'),'your_2nd_script.py','arg1', 'arg2', '...', 'argN'])
... View more
12-01-2018
04:47 PM
|
1
|
3
|
3920
|
|
POST
|
os.system is not the best way to run another process, that's what the subprocess module is for. However, I wouldnt reccommend this for running python scripts, It's much easier and more flexible to turn your script into a module, i.e wrap your script in a function, import the module, then call the function. Can't go into detail as I'm typing this on my phone.
... View more
11-30-2018
08:04 PM
|
0
|
5
|
3920
|
|
POST
|
You haven't answered either of my questions about the toolbox properties, or the scheduled task security properties. You put the python filepath in the "Program/script:" section and the script filepath in the "Add arguments" section.
... View more
11-09-2018
12:36 PM
|
1
|
2
|
6611
|
|
POST
|
Can you also confirm that the Toolbox alias (when I said "name" previously, I meant alias) is really "CrimeTools" not "Crime". Your tbx file is "Crime.tbx" and the alias property defaults to the filename with no extension. Did you definitely change it to "CrimeTools"?
... View more
11-07-2018
05:30 PM
|
1
|
0
|
6611
|
|
POST
|
aprx = arcpy.mp.ArcGISProject(r"C:\Path\To\Project.aprx") The above changes the project .aprx file on disk. It can be used in jupyter, IDE, scripts, in a python interpreter, etc.... If you have ArcGIS Pro open with this project loaded and call "aprx.save()" externally from your jupyter/IDE/scripts/python interpreter, any changes you make will not be reflected in the open ArcGIS Pro project because Pro reads the project file into memory when it opens it. If you save the project from within Pro, any changes you have made externally with "aprx.save()" will be overwritten. aprx = arcpy.mp.ArcGISProject("CURRENT") The above will only work from within Pro in the Python Window as it references the in memory project, not the project .aprx file on disk. Basically, you can't control an open Pro project from outside Pro. It's the same with an ArcMap mxd.
... View more
11-07-2018
04:52 PM
|
2
|
1
|
5166
|
|
POST
|
Mark Rankin wrote: I'm using the models to run as scheduled tasks in the middle of the night. That's likely to be your problem. Can you post some details about the scheduled task, in particular the security options in the general tab. If you're not running the task as your user, either logged on or with stored password, you may not be able to access the \\UNC network path. E.g.
... View more
11-07-2018
04:37 PM
|
0
|
0
|
6611
|
|
POST
|
Works for me. arcpy.ImportToolbox(r"c:\Temp\test.tbx")
<module 'test'>
arcpy.test.testfunc
<function testfunc at 0x000000003BDC4268>
arcpy.testfunc_test
<function testfunc at 0x000000003BDC4268> Don't forget Python is case sensitive. You may have defined the tool and/or toolbox name property as something different to Step1CrimeDataPrep and/or CrimeTools Can you post a screenshot of the tool properties (general tab) and the toolbox (tbx) properties.
... View more
11-06-2018
08:22 PM
|
0
|
4
|
6611
|
|
POST
|
You don't have to use aprx.saveACopy(file_name), you can just use aprx.save() save method documentation save () Saves changes to an ArcGISProject (.aprx). saveACopy (file_name) Saves an ArcGISProject (.aprx) to a new file path or name.
... View more
11-06-2018
08:17 PM
|
1
|
6
|
5166
|
|
POST
|
If you just want a binary 1/0 True/False output, use: stream_raster = outFlowAccum >= 150
... View more
11-02-2018
04:14 AM
|
0
|
0
|
2349
|
|
POST
|
You're setting the parameter to outputPDF which is a geoprocessing Result object. Set it to outputPath instead.
... View more
11-02-2018
04:03 AM
|
0
|
1
|
2639
|
|
POST
|
'nom = "%s"' % country
# or
'nom = "{}"'.format(country)
Look up Python string formatting. Don't forget you need quotes around string values in where clauses.
... View more
11-01-2018
12:39 AM
|
2
|
1
|
1341
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 07-24-2022 03:08 PM | |
| 1 | 07-30-2025 03:00 PM | |
| 1 | 06-10-2025 08:06 PM | |
| 5 | 05-20-2025 07:56 PM | |
| 1 | 05-04-2025 10:34 PM |