POST
|
Ok, I'm stumped! I have a list "xys" that if I do this: xys.sort() for i in xys: print i I get this: (id, xFrom, yFrom, xTo, yTo) [225351, 1858897, 889223, 1883031, 882436] [225396, 1908393, 871758, 1908090, 871791] [225405, 1899127, 884235, 1885213, 861191] [225423, 1891186, 878961, 1885811, 881262] [225435, 1887101, 888042, 1894165, 884325] [225438, 1888139, 885803, 1888050, 885319] [225438, 1888139, 885803, 1888081, 884837] [225441, 1885023, 888542, 1884356, 888364] [225351, 1858897, 889223, 1883031, 882436] and then i do this: for j in xys: print j myList = [] myList.append(arcpy.Point(j[1], j[2])) myList.append(arcpy.Point(j[3], j[4])) array = arcpy.Array(myList) polyline = arcpy.Polyline(array) cursor = arcpy.da.InsertCursor(output, ("SHAPE@")) cursor.insertRow((polyline,)) print 'inserted row' I get an empty table... I had this working at one point. Any obvious blunders here?
... View more
12-29-2014
10:35 AM
|
0
|
16
|
5589
|
POST
|
Your 2.jpg is really close. I think you need quotes around "FAIL" and "PASS", but not around 1 or 0. You probably need to wrap your field names with ! as well.
... View more
12-11-2014
12:02 PM
|
0
|
7
|
1129
|
POST
|
the split method on strings in python should do it: s = 'hello world' a,b = s.split(' ') a hello b world I'm splitting on a single whitespace here, but you could use a comma or another delimter the same.
... View more
12-09-2014
12:50 PM
|
1
|
0
|
1107
|
POST
|
https://c.na9.visual.force.com/apex/ideaView?id=08730000000brslAAA I posted this to the esri idea submission site in 2011, so go vote for it!
... View more
12-02-2014
09:16 AM
|
0
|
2
|
635
|
POST
|
Thanks for testing. I'm failing on a 10.1 server, but my 10.2 server succeeds!
... View more
12-01-2014
02:57 PM
|
0
|
1
|
1518
|
POST
|
FAILED... I just want to let my web developer get back 'Hello world' when calling this Job Messages: esriJobMessageTypeInformative: Submitted. esriJobMessageTypeInformative: Executing... esriJobMessageTypeError: ERROR 000816: The tool is not valid. esriJobMessageTypeError: Failed. Here's the code. Not much happening here. import arcpy
import os
class Toolbox(object):
def __init__(self):
self.label = "Get Nearby Addresses"
self.alias = ""
# List of tool classes associated with this toolbox
self.tools = [GetNearbyAddresses]
class GetNearbyAddresses(object):
def __init__(self):
self.label = "Get Nearby Addresses"
self.description = "Get Nearby Addresses within a buffer."
self.canRunInBackground = False
def getParameterInfo(self):
params = []
param0 = arcpy.Parameter(
displayName = "Latitude",
name = "lat",
datatype = "Double",
parameterType = "Required",
direction = "Input")
params.append(param0)
param1 = arcpy.Parameter(
displayName = "Longitude",
name = "lon",
datatype = "Double",
parameterType = "Required",
direction = "Input")
params.append(param1)
param2 = arcpy.Parameter(
displayName = "Buffer Distance",
name = "distance",
datatype = "Long",
parameterType = "Required",
direction = "Input")
params.append(param2)
param3 = arcpy.Parameter(
displayName = "Address List",
name = "addresses",
datatype = "GPString",
parameterType = "Derived",
direction = "Output")
params.append(param3)
return params
def execute(self, parameters, messages):
try:
#arcpy.env.workspace = r'E:\gis\ims\20141028_getAddressesWithinBuffer\default.gdb'
#arcpy.env.overwriteOutput = True
lat = parameters[0].valueAsText
lon = parameters[1].valueAsText
distance = parameters[2].valueAsText
#inpoint = arcpy.Point(X=lon, Y=lat)
#ptGeometry = arcpy.PointGeometry(inpoint, arcpy.SpatialReference(4326))
#arcpy.Buffer_analysis(ptGeometry, 'buffer', distance + ' FEET', \
#"FULL", "ROUND", "NONE", "")
#print 'made the buffer.'
#get intersecting addresses
#parameters[3].value = 'laksdjflaskdjflksajdf'
arcpy.SetParameter(3,'Hello World!')
return
except Exception, ErrorDesc:
sErr = "ERROR:\n" + str(ErrorDesc)
messages.addErrorMessage(sErr)
return
... View more
12-01-2014
02:18 PM
|
0
|
1
|
1518
|
POST
|
When I do that I see my output correctly in the results window in arcmap, but after publishing as a gp service I'm not sure how to get the results in from the rest directory. I get an error FAILED from the submit job screen on the rest directory.
... View more
12-01-2014
01:39 PM
|
1
|
3
|
1518
|
POST
|
from the google: http://stackoverflow.com/questions/23428660/python-locale-currency-to-0-decimals Hopefully helpful?
... View more
11-26-2014
09:14 AM
|
0
|
0
|
1466
|
POST
|
hmmm.... submitting the job via the rest directory fails still. The tool succeeds in ArcMap though.
... View more
11-26-2014
08:00 AM
|
0
|
0
|
1314
|
POST
|
I have web developers that would like to consume the results as a web service, so I'm not too clear on the best way to set the output, but I don't think adding to the tool message is it. I don't really need to persist the data to a text file either. It's a quick call to get some temp data, then it's tossed.
... View more
11-26-2014
07:29 AM
|
0
|
0
|
1314
|
POST
|
def makeMoney(n): import locale locale.setlocale(locale.LC_ALL, '') S = locale.currency(float(n), grouping=True) return S
... View more
11-25-2014
02:49 PM
|
0
|
2
|
1466
|
POST
|
It would be tremendously helpful if someone could post a sample python toolbox (pyt) that accepts a dummy input parameter or two, and returns "hello world of pyt gp services!" I figure with that template, I could do my own gp routines during the execution, and replace the "hello world" with the results of my gp work. I don't need any geometry returned, just text. The use case here is to return nearby addresses from an input lat/long. This code fails: import arcpy import os class Toolbox(object): def __init__(self): self.label = "Get Nearby Addresses" self.alias = "" # List of tool classes associated with this toolbox self.tools = [GetNearbyAddresses] class GetNearbyAddresses(object): def __init__(self): self.label = "Get Nearby Addresses" self.description = "Get Nearby Addresses within a buffer." self.canRunInBackground = False def getParameterInfo(self): params = [] param0 = arcpy.Parameter( displayName = "Latitude", name = "lat", datatype = "Double", parameterType = "Required", direction = "Input") params.append(param0) param1 = arcpy.Parameter( displayName = "Longitude", name = "lon", datatype = "Double", parameterType = "Required", direction = "Input") params.append(param1) param2 = arcpy.Parameter( displayName = "Buffer Distance", name = "distance", datatype = "Long", parameterType = "Required", direction = "Input") params.append(param2) param3 = arcpy.Parameter( displayName = "Address List", name = "addresses", datatype = "GPString", parameterType = "Derived", direction = "Output") params.append(param3) return params def execute(self, parameters, messages): try: arcpy.env.workspace = r'E:\gis\default.gdb' arcpy.env.overwriteOutput = True lat = parameters[0].valueAsText lon = parameters[1].valueAsText distance = parameters[2].valueAsText #inpoint = arcpy.Point(X=lon, Y=lat) #ptGeometry = arcpy.PointGeometry(inpoint, arcpy.SpatialReference(4326)) #arcpy.Buffer_analysis(ptGeometry, 'buffer', distance + ' FEET', \ # "FULL", "ROUND", "NONE", "") #get intersecting addresses here parameters[3].value = 'a nice list of addresses!' # I need this from a gp service! return except Exception, ErrorDesc: sErr = "ERROR:\n" + str(ErrorDesc) messages.addErrorMessage(sErr) return
... View more
11-25-2014
10:40 AM
|
0
|
6
|
3418
|
POST
|
You are the coolest! I normally am only reading these tables, so now I can go have some fun!
... View more
10-31-2014
11:23 AM
|
0
|
0
|
2813
|
POST
|
Hi all! HELP! : ) I'm able to read rows from SQL Server just fine with pyodbc, but I can't seem to update a row. Any ideas? At this point there's no gis involvement here, but there will be once I can modify the table. import pyodbc cstring = 'DRIVER={SQL Server};SERVER=aServer;DATABASE=aDatabase;UID=aUN;PWD=aPassword' con = pyodbc.connect(cstring) cur = con.cursor() sql = """UPDATE Stats SET myColumn = 'TEST' WHERE case_number = 'case9999'""" rows = cur.execute(sql).fetchall() con.commit() cur.close() del cur, con >>>pyodbc.ProgrammingError: No results. Previous SQL was not a query.
... View more
10-31-2014
10:24 AM
|
0
|
2
|
12112
|
Title | Kudos | Posted |
---|---|---|
1 | 02-03-2014 12:02 PM | |
1 | 09-11-2012 12:51 PM | |
1 | 12-09-2014 12:50 PM | |
1 | 12-28-2012 08:28 AM | |
1 | 12-01-2014 01:39 PM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:22 AM
|