POST
|
I need to call a python script from another script, and not wait (this is a script to start multiple other scripts). I have three different methods of calling the script - execfile(), os.system(), and subprocess.popen(). These all work - but, the first one forces the program to wait; and the other ones will fail when it tries to import arcpy. I suspect it is something to do with my 64-bit background geoprocessing, which I just reinstalled this morning. The error that occurs when importing arcpy is this: "Traceback (most recent call last): File "f:\scratch\test.py", line 5, in <module> import arcpy File "c:\program files (x86)\arcgis\desktop10.8\ArcPy\arcpy\__init__.py", line 22, in <module> from arcpy.geoprocessing import gp File "c:\program files (x86)\arcgis\desktop10.8\ArcPy\arcpy\geoprocessing\__init__.py", line 14, in <module> from _base import * File "c:\program files (x86)\arcgis\desktop10.8\ArcPy\arcpy\geoprocessing\_base.py", line 14, in <module> import arcgisscripting ImportError: DLL load failed: %1 is not a valid Win32 application." I only have one installation of Python. I'm attaching two scripts: test1.py will call test.py with the three different methods - if they are successful, they will write out text files indicating which method was used. I can't attach my scripts here, so they are pasted below: The called script is commented out. I'd sure appreciate any help with this! #MAIN SCRIPT import os import subprocess import sys #import arcpy #works whether or not this is commented ''' script that's called by 3 methods below: #script f:\\scratch\\test.py import sys import time outFile = sys.argv[1] print (outFile) import arcpy #if this is commented, all three methods work; otherwise only execfile works print ("writing file") newInputFile = "f:\\scratch\\" + outFile + ".txt" inputfile = open(newInputFile, "w") inputfile.close() print(sys.version) print("sleeping") time.sleep(5) ''' print ("execfile here:") sys.argv = ['test.py','file_from_execfile'] execfile("f:\\scratch\\test.py") print("") command = 'python f:\\scratch\\test.py file_from_command' print ("command here:") os.system(command) script = "f:\\scratch\\test.py" pythonExePath = r'C:\Python27\ArcGISx6410.8\python.exe' pid = subprocess.Popen([pythonExePath, script, 'file_from_subprocess'], shell=False) # Call subprocess print ("done")
... View more
12-03-2020
12:54 PM
|
0
|
1
|
1323
|
POST
|
This may be a bug in the function. I was experimenting with different time intervals, and I ran this with several different time increments for one day. All other parameters were the same. Below are the results showing the sum total radiation for the point over the course of the day using different time intervals: time (hrs): WH/m2 1: 4933.711117 0.5: 4932.43362 0.3333: 4932.708427 0.1 min: 4932.670403 0.016666667 min: 2884.326145 I don't really need the 1 minute interval, but thought it should be known that it should probably not be used. I thought it might be due to too many records in the output table - but then I tried it for only one hour, and got a much lower value for the 1 minute interval.
... View more
10-09-2020
05:05 PM
|
0
|
0
|
410
|
POST
|
I figured it out. Original points were generic type "point". webMercatorToGeographic did not work, but xyToLngLat did. Don't understand why, but for now my problem is solved: for (var i = 0; i < response.features.length; i++) { textSymbol.text = response.features.attributes.Origin var point = { type: "point", x: response.features.geometry.x, y: response.features.geometry.y } var newXY = webMercatorUtils.xyToLngLat(point.x, point.y) var point2 = { type: "point", x: newXY[0], y: newXY[1] } var pointGraphic = new Graphic({ geometry: point2, symbol: textSymbol }); GLCopy.graphics.add(pointGraphic); }; //after all graphics are added: map.add(GLCopy);
... View more
06-12-2018
11:04 AM
|
0
|
0
|
382
|
POST
|
I'm having the same exact problem. I am copying point geometries from a featurelayer in WebMercator, and putting the points into graphics and adding that to the map. The featurelayer points show up just fine. The graphic points only show up if I override the x/y values with lat-long coordinates. I've been trying to use this: var point2 = webMercatorUtils.webMercatorToGeographic(point.geometry), but that throws this error: "Cannot read property 'clone' of undefined".
... View more
06-11-2018
05:56 PM
|
0
|
1
|
382
|
POST
|
I figured it out. Need to have async=true, and add the updateDefinition parameter. This is the corrected line: data = { "f": "json", "token": token, "async": "true", "updateDefinition": {"multiScaleGeometryInfo": {"levels" : [7,9,11,13,15]}}}
... View more
02-14-2018
03:07 PM
|
2
|
0
|
820
|
POST
|
Hi, using the REST API, I'm attempting to update multiScaleGeometryInfo for my feature layers, but I'm having trouble getting into the updateDefinition URL. Here's the error I get: {u'error': {u'message': u'Unable to update feature service layer definition.', u'code': 400, u'details': [u'Value cannot be null. Parameter name: input']}} Here's my Python script. Thanks for any help! import sys import ntpath import os, sys, json, urllib, urllib2, httplib, urlparse, mimetools, mimetypes from cStringIO import StringIO username = "un" password = "pw" tokenURL = "https://www.arcgis.com/sharing/generateToken" params = {'f': 'pjson', 'username': username, 'password': password, 'referer': 'https://services7.arcgis.com'} req = urllib2.Request(tokenURL, urllib.urlencode(params)) try: response = urllib2.urlopen(req) except: gcontext = ssl.SSLContext(ssl.PROTOCOL_TLSv1) response = urllib2.urlopen(req, context=gcontext) data = json.load(response) token = data['token'] print(token) requesturl = "https://services7.arcgis.com/[ID]/ArcGIS/rest/admin/services/example/FeatureServer/0/updateDefinition" #data = {'f': 'json', 'token': sh.token, "multiScaleGeometryInfo" : {"levels" : [7,9,11,13,15]}} #this is what I'll eventually do data = { "f": "json", "token": token} query_string = urllib.urlencode(data) print query_string response = urllib.urlopen(requesturl, query_string) resp_json = json.loads(response.read()) print resp_json
... View more
02-14-2018
12:53 PM
|
0
|
1
|
1387
|
POST
|
Hi, I'm working on an application with the latest (4.4) API. I user a REST QueryTask to generate a FeatureLayer, which gets added to the map, and a SimpleRenderer is generated using the range of values for whatever attribute the user has selected. The legend is added to the map. An example is shown in screenshot1. When I use the Print function, the legend shows up as individual entries for each feature, with a caption that says Override 1, Override 2, etc. for each feature that is visible in the map view. Screenshot2 shows the output from Print. Any clue what I could be doing wrong? Thanks!
... View more
09-07-2017
03:48 PM
|
0
|
0
|
584
|
POST
|
Thanks for the responses. I have done Optimize Layer Drawing in the Feature Layer (Hosted) Settings,with no effect. I've given it plenty of time to draw, as well. I've made some attempts at using the REST API to pass in a URL with a query (Query - Feature Service (Operation)). So far I have not been able to make it work. My idea is to pass the stream size query as well as the map envelope as a geometry spatial query. I can build those queries and get back a limited number of features on the FeatureServer/0/query page, but I don't know how (or if it's possible) to retrieve a feature layer on my map. If that would work, it would certainly be faster than drawing a huge number of features.
... View more
11-18-2016
09:22 AM
|
0
|
0
|
323
|
POST
|
Hi, I am using the ArcGIS Javascript API 4.0 to display a Feature Layer hosted by AGOL. It is a river network with 13,000 lines. In the REST admin services, I have set the Max Record Count to 100,000 and the standardMaxRecordCount to 20,000. I am using a definitionExpression to limit the number of lines that are drawn at any time. The definitionExpression uses an attribute that is a measure of river size (stream order), so when you zoom out, only high-order streams are show, and when you zoom in to level 16, it will show all of the streams. At the highest level of zoom, there should only be a few hundred lines visible. When the query yields more than 4000 results, any features beyond the first 4000 results are not drawn. 4000, coincidentally (?) is the same number that was initially set as the maxRecordCount. There's a popup window that works on the lines and shows the OBJECTID. The numbering order is a little strange, but the easy way to replicate the behavior is to set both sliders to zero, zoom in to the west side, and as you zoom in, the definition query changes, some lines start disappearing, even though they are included in the definition query. Here's a link to the map. Thanks for any help! Map here
... View more
11-17-2016
05:26 PM
|
0
|
3
|
680
|
POST
|
OK, I figured it out. ArcMap was failing to save rasters (it was trying to write to C:\Windows\System32\!), so I set up (as described in another forum topic on this site) a Windows environment variable ARCTMPDIR as C:\Windows\Temp\. Here's how I figured out what was happening: When I opened up the SingleOutput interface (that says it succeeded but didn't), I replaced the .flt grids with an actual ESRI grid in the expression, and then I got some real errors: Messages Executing: SingleOutputMapAlgebra Int(SetNull(E:\NetMapData\app\elev_app EQ 0, E:\NetMapData\app\elev_app)) c:\temp\XSCXT # Start Time: Thu Jun 13 10:28:32 2013 ERROR 010429: Error in GRID IO: CellLyrCreateInternal: Unable to create info directory for c:\windows\temp\ras649 . ERROR 010302: Unable to create the output raster: C:\WINDOWS\TEMP\RAS649 Unable to create INFO directory C:\WINDOWS\TEMP\INFO ERROR 010067: Error in executing grid expression. Failed to execute (SingleOutputMapAlgebra). Failed at Thu Jun 13 10:28:32 2013 (Elapsed Time: 0.00 seconds) I looked in C:\Windows\Temp\ and it was full of hundreds of g_g### folders, and an info folder. I deleted everything in there, and then the next time I ran my code, a new info folder was created, and everything worked just fine. So, I guess the info folder was corrupt? I will now look for a way to purge that directory if needed, or perhaps on start-up of my add-in. Hope this helps someone else with this kind of problem!
... View more
06-13-2013
09:50 AM
|
0
|
0
|
372
|
POST
|
This just happened to a second computer in our office. (I'm the same guy who posted all of the above, just different log-in.) I had a batch run to do this operation for 7 grids - the first one worked fine, and the next 6 all failed in the exact same mode as the other computer. Using ArcToolbox Raster calculator to do the operation works, but using SingleOutputMapAlgebra says it works, 0.0 seconds, no output. Ack. Any more suggestions, or a potential work-around? Thanks!
... View more
06-13-2013
09:22 AM
|
0
|
0
|
372
|
POST
|
I'm using code similar to the "Show Progress Dialog Snippet", which is inside a Try - Catch - End Try block. When there's an error, the code exits the subroutine, which is what I want it to do, but the progress dialog is still up, and I can't get it to go away, and nothing else can be done until I force ArcMap to shut down. Does anybody know how to hide the progress dialog when there's an error? I suppose I could make it a public variable, so the error handler can see it, but that seems pretty roundabout. Thanks!
... View more
01-03-2013
11:07 AM
|
0
|
5
|
840
|
POST
|
Well, this works: Dim workspaceFactory As IWorkspaceFactory workspaceFactory = New DataSourcesOleDB.TextFileWorkspaceFactory ' Open a directory of CSV files using its path. Dim workspace As IWorkspace = workspaceFactory.OpenFromFile(pPath, 0) ' Open a CSV file as a table. Dim featureWorkspace As IFeatureWorkspace = CType(workspace, IFeatureWorkspace) pTable = featureWorkspace.OpenTable(pTableName) Return pTable
... View more
12-10-2012
01:44 PM
|
0
|
0
|
207
|
POST
|
This code, directly from ArcObjects API Reference for .NET, causes an error ( I replaced pathname and filename with my file): Dim factoryType As Type = Type.GetTypeFromProgID("esriDataSourcesOleDB.TextFileWorkspaceFactory") Dim workspaceFactory As IWorkspaceFactory = CType(Activator.CreateInstance(factoryType), IWorkspaceFactory) ' Open a directory of CSV files using its path. Dim workspace As IWorkspace = workspaceFactory.OpenFromFile("C:\Data\CSV", 0) ' Open a CSV file as a table. Dim featureWorkspace As IFeatureWorkspace = CType(workspace, IFeatureWorkspace) Dim table As ITable = featureWorkspace.OpenTable("Levee.csv") Error comes on the 2nd line, as "factoryType = nothing" System.ArgumentNullException was caught Message=Value cannot be null. Parameter name: type ParamName=type Source=mscorlib StackTrace: at System.Activator.CreateInstance(Type type, Boolean nonPublic) at System.Activator.CreateInstance(Type type) at NetMap2.modGeneral.OpenCSV(String pPath, String pTableName) InnerException:
... View more
12-10-2012
01:25 PM
|
0
|
0
|
207
|
Title | Kudos | Posted |
---|---|---|
2 | 02-14-2018 03:07 PM |
Online Status |
Offline
|
Date Last Visited |
a month ago
|