|
POST
|
I am running using localhost, I set up a virtual directory in IIS 6. Now that I think of it, JSAPI 3.16 probably requires 4.5 .NET, I am on 3.5. Would this cause the error? On Fri, Mar 11, 2016 at 9:56 AM, Robert Scheitlin, GISP <geonet@esri.com>
... View more
03-11-2016
10:00 AM
|
0
|
11
|
1617
|
|
POST
|
I have done so, and am still receiving the same errors. I am debugging now by stepping through the legend and scale bar functions. On Fri, Mar 11, 2016 at 9:37 AM, Robert Scheitlin, GISP <geonet@esri.com>
... View more
03-11-2016
09:42 AM
|
0
|
13
|
1617
|
|
POST
|
I have tried debugging it; removing the scale bar and changing the legend, it seems that it's getting hung up in either of these functions.
... View more
03-11-2016
08:56 AM
|
0
|
15
|
1617
|
|
POST
|
Hi Robert, Thanks for your response, I have configured this application on a local machine using the Chrome Add-On 200 OK to launch it and avoid cross origin domain errors. However, I have received the errors below in the console. What is the solution for this?
... View more
03-11-2016
07:57 AM
|
0
|
17
|
1617
|
|
POST
|
I would like to create a simple ArcGIS Online web-map or ArcGIS JSAPI application that contains one polygon layer with attributes and a locator. I would like to drop a pin or point on my geocode result and display the attributes of the polygon that it falls within. Are there any examples of this available? The best that I could do was the point in polygon selection, but I would like to create a feature layer from my geocoded location and give it the same attributes of the polygon it falls within. I am using this for voting districts. So if I am at 1000 N. Broadway Blvd. and geocode that then, the point that appears on the map should be given the attributes of District 1, for example.
... View more
03-10-2016
04:55 PM
|
0
|
20
|
5943
|
|
POST
|
@Adam Marinelli, that is correct, it should be mentioned that NUMBERCYLA and SRNumber are identical. But your example is correct, if I have one Service Request number repeated at different objectIDs, I would like to remove one.
... View more
08-13-2015
08:43 PM
|
0
|
2
|
2258
|
|
POST
|
I have a feature class where there are multiple values duplicated in a row, i.e. SRNumber and RESOLUTION_CODE. I would like to delete all rows where my SRNumber and RESOLUTION_CODE are found in multiple rows. I have got a good start with this script, everything works aside from actually deleting the rows. How can I fix this so that my duplicate rows are deleted? So if SRNumber = 1-23456 and Resolution_Code = 'A' and appears twice, I would like to delete one. I have taken this example for GIS Stackexchange, but the del rows does not work correctly. import arcpy
...
... in_table = r"ServiceRequest.DBO.SO_Dead_Animal"
... fields = ["NumberCYLA","RESOLUTION_CODE"] #replace with own
... curStrings = arcpy.da.SearchCursor(in_table,fields,"NumberCYLA is not null")
...
... stringsKeysList = []
... numbersValuesList = []
... tableDict = {}
...
... for row in curStrings:
... print row[0],row[1]
... stringsKeysList.append(row[0])
... del curStrings
... uniqueStringsList = list(set(stringsKeysList)) #only unique values from Strings field
...
... for uniqueString in uniqueStringsList:
... emptyTempValues = []
... curValues = arcpy.da.SearchCursor(in_table,fields,"""NumberCYLA = '{0}'""".format(str(uniqueString)))
... for row in curValues:
... print row[1]
... emptyTempValues.append(row[1])
... uniqueEmptyTempValues = list(set(emptyTempValues))
... tableDict[uniqueString] = uniqueEmptyTempValues
...
... print tableDict
...
... rowsToDelete = [k for k, v in tableDict.iteritems() if v == [-1]] #find which rows to delete
... print "list: ", rowsToDelete
... stringRows = ","
... updRows = stringRows.join(rowsToDelete)
... updRows = updRows.replace(",","','")
... print updRows #update the string to be used with proper syntax in where clause
...
... where_clause = """NumberCYLA in ('{0}')""".format(updRows)
... upd_cur = arcpy.da.UpdateCursor(in_table,fields,where_clause)
... for row in upd_cur:
... print row[0],row[1]
... del rowsToDelete
... View more
08-12-2015
05:06 PM
|
0
|
7
|
5698
|
|
POST
|
I was able to solve this with an inner loop of those items. Now I have another issue where the inner loop is not writing to the db. The inner loops read as; for sr in Manual:
for manualcount in Manual["La311ManualPickup":]:
countmanual = manualcount['ItemCount']
print countmanual
... View more
05-11-2015
07:01 AM
|
0
|
1
|
568
|
|
POST
|
This is more of a general Python question which will set me up to send this data from a NumPyArray to Feature Class. I am trying to parse through a web-service and retrieve certain records, however I am consistently receiving a KeyError for responses with more than one object. These records are returned in intervals, so sometimes I might receive one record and others I might receive 300. If I receive one record, the logic of my code works, if there are multiple items then the code doesn't work. Here is an example of an output with one object. I have posted to StackOverFlow and no luck, so this is cross-posted. {
"status": {
"code": 311,
"message": "Service Request Successfully Queried.",
"cause": ""
},
"Response": {
"NumOutputObjects": "1",
"ListOfServiceRequest": {
"ServiceRequest": [
{
"AddressVerified": "Y",
"SRNumber": "1-13967451",
"SRType": "Service Not Complete",
"CreatedDate": "05/08/2015 10:00:38",
"UpdatedDate": "05/08/2015 10:00:49",
"IntegrationId": "05082015100148678",
"Status": "Open",
"CreatedByUserLogin": "PROXYE",
"UpdatedByUserLogin": "PROXYE",
"Anonymous": "N",
"Zipcode": "90032",
"Latitude": "34.0843242531",
"Longitude": "-118.171015007",
"CustomerAccessNumber": "",
"LADWPAccountNo": "",
"NewContactFirstName": "jj",
"NewContactLastName": "rambo",
"NewContactPhone": "",
"NewContactEmail": "",
"ParentSRNumber": "1-10552271",
"Priority": "Normal",
"Language": "",
"ReasonCode": "",
"ServiceDate": "",
"Source": "",
"ClosedDate": "",
"Email": "",
"FirstName": "",
"HomePhone": "",
"LastName": "",
"LoginUser": "",
"ResolutionCode": "",
"SRUnitNumber": "",
"MobilOS": "",
"SRAddress": "5163 E TEMPLETON ST, 90032",
"SRAddressName": "",
"SRAreaPlanningCommission": "East Los Angeles APC",
"SRCommunityPoliceStation": "CENTRAL BUREAU",
"SRCouncilDistrictMember": "Jose Huizar",
"SRCouncilDistrictNo": "14",
"SRDirection": "E",
"SRNeighborhoodCouncilId": "48",
"SRNeighborhoodCouncilName": "LA-32 NC",
"SRStreetName": "TEMPLETON",
"SRSuffix": "ST",
"SRTBColumn": "F",
"SRTBMapGridPage": "595",
"SRTBRow": "6",
"SRXCoordinate": "6509897",
"SRYCoordinate": "1853117",
"AssignTo": "NC",
"Assignee": "NC eWaste Supervisor 01",
"Owner": "BOS",
"ParentSRStatus": "Open",
"ParentSRType": "Electronic Waste",
"ParentSRLinkDate": "05/08/2015 10:00:39",
"ParentSRLinkUser": "PROXYE",
"SRAreaPlanningCommissionId": "5",
"SRCommunityPoliceStationAPREC": "HOLLENBECK",
"SRCommunityPoliceStationPREC": "4",
"SRCrossStreet": "",
"ActionTaken": "",
"SRCity": "",
"RescheduleCounter": "",
"SRHouseNumber": "5163",
"SourceofRequestCouncil": "",
"CCBPremiseType": "",
"ContainerBlackCount": "",
"ContainerBrownCount": "",
"SRIntersectionDirection": "",
"SRApproximateAddress": "N",
"ContainerGreenCount": "",
"OtherBureauName": "",
"AssigneeName": "",
"AssigneeOrganization": "E-Waste, NC",
"AnotherBureauEmailId": "",
"ListOfLa311BarricadeRemoval": {},
"ListOfLa311BulkyItem": {},
"ListOfLa311DeadAnimalRemoval": {},
"ListOfLa311GraffitiRemoval": {},
"ListOfLa311InformationOnly": {},
"ListOfLa311MultipleStreetlightIssue": {},
"ListOfLa311SingleStreetlightIssue": {},
"ListOfLa311SrPhotoId": {
"La311SrPhotoId": []
},
"ListOfLa311BusPadLanding": {},
"ListOfLa311CurbRepair": {},
"ListOfLa311Flooding": {},
"ListOfLa311GeneralStreetInspection": {},
"ListOfLa311GuardWarningRailMaintenance": {},
"ListOfLa311GutterRepair": {},
"ListOfLa311LandMudSlide": {},
"ListOfLa311Pothole": {},
"ListOfLa311Resurfacing": {},
"ListOfLa311SidewalkRepair": {},
"ListOfLa311StreetSweeping": {},
"ListOfLa311BeesOrBeehive": {},
"ListOfLa311MedianIslandMaintenance": {},
"ListOfLa311OvergrownVegetationPlants": {},
"ListOfLa311PalmFrondsDown": {},
"ListOfLa311StreetTreeInspection": {},
"ListOfLa311StreetTreeViolations": {},
"ListOfLa311TreeEmergency": {},
"ListOfLa311TreeObstruction": {},
"ListOfLa311TreePermits": {},
"ListOfLa311BrushItemsPickup": {},
"ListOfLa311Containers": {},
"ListOfLa311ElectronicWaste": {},
"ListOfLa311IllegalDumpingPickup": {},
"ListOfLa311ManualPickup": {},
"ListOfLa311MetalHouseholdAppliancesPickup": {},
"ListOfLa311MoveInMoveOut": {},
"ListOfLa311HomelessEncampment": {},
"ListOfLa311IllegalAutoRepair": {},
"ListOfLa311IllegalConstruction": {},
"ListOfLa311IllegalConstructionFence": {},
"ListOfLa311IllegalDischargeOfWater": {},
"ListOfLa311IllegalDumpingInProgress": {},
"ListOfLa311IllegalExcavation": {},
"ListOfLa311IllegalSignRemoval": {},
"ListOfLa311IllegalVending": {},
"ListOfLa311LeafBlowerViolation": {},
"ListOfLa311NewsRackViolation": {},
"ListOfLa311Obstructions": {},
"ListOfLa311TablesAndChairsObstructing": {},
"ListOfLa311GisLayer": {
"La311GisLayer": [
{
"A_Call_No": "",
"Area": "0",
"Day": "MONDAY",
"DirectionSuffix": "",
"DistrictAbbr": "",
"DistrictName": "NC",
"DistrictNumber": "",
"DistrictOffice": "",
"Fraction": "",
"R_Call_No": "",
"SectionId": "",
"ShortDay": "",
"StreetFrom": "",
"StreetTo": "",
"StreetLightId": "",
"StreetLightStatus": "",
"Type": "GIS",
"Y_Call_No": "",
"Name": "05082015100148678100",
"CommunityPlanningArea": "",
"LastUpdatedBy": "",
"BOSRadioHolderName": ""
}
]
},
"ListOfLa311ServiceRequestNotes": {
"La311ServiceRequestNotes": [
{
"CreatedDate": "05/08/2015 10:00:39",
"Comment": "Materials have been out in a normal collection area, unsure why driver missed the e-waste items.",
"CreatedByUser": "PROXYE",
"IsSrNoAvailable": "",
"CommentType": "External",
"Notification": "N",
"FeedbackSRType": "",
"IntegrationId": "050820151001486782",
"Date1": "",
"Date2": "",
"Date3": "",
"Text1": "",
"AnotherBureau": "",
"EmailAddress": "",
"ListOfLa311SrNotesAuditTrail": {}
},
{
"CreatedDate": "05/08/2015 10:00:39",
"Comment": "",
"CreatedByUser": "PROXYE",
"IsSrNoAvailable": "",
"CommentType": "Address Comments",
"Notification": "N",
"FeedbackSRType": "",
"IntegrationId": "050820151001486781",
"Date1": "",
"Date2": "",
"Date3": "",
"Text1": "",
"AnotherBureau": "",
"EmailAddress": "",
"ListOfLa311SrNotesAuditTrail": {}
}
]
},
"ListOfLa311SubscribeDuplicateSr": {},
"ListOfChildServiceRequest": {},
"ListOfLa311BillingCsscAdjustment": {},
"ListOfLa311BillingEccAdjustment": {},
"ListOfLa311BillingRsscAdjustment": {},
"ListOfLa311BillingRsscExemption": {},
"ListOfLa311SanitationBillingBif": {},
"ListOfLa311SanitationBillingCssc": {},
"ListOfLa311SanitationBillingEcc": {},
"ListOfLa311SanitationBillingLifeline": {},
"ListOfLa311SanitationBillingRssc": {},
"ListOfLa311SanitationBillingSrf": {},
"ListOfLa311DocumentLog": {},
"ListOfAuditTrailItem2": {
"AuditTrailItem2": [
{
"Date": "05/08/2015 10:00:49",
"EmployeeLogin": "SADMIN",
"Field": "Assignee",
"NewValue": "NC eWaste Supervisor 01",
"OldValue": ""
}
]
},
"ListOfLa311GenericBc": {
"La311GenericBc": [
{
"ATTRIB_08": "",
"NAME": "05082015100148678100",
"PAR_ROW_ID": "1-8BDCR",
"ROW_ID": "1-8BOCG",
"TYPE": "GIS",
"ATTRIB_16": "",
"ListOfLa311GenericbcAuditTrail": {}
},
{
"ATTRIB_08": "",
"NAME": "05082015100148678",
"PAR_ROW_ID": "1-8BDCR",
"ROW_ID": "1-8BOCJ",
"TYPE": "Service Not Complete",
"ATTRIB_16": "",
"ListOfLa311GenericbcAuditTrail": {}
}
]
},
"ListOfLa311ServiceNotComplete": {
"La311ServiceNotComplete": [
{
"ContainerLocation": "",
"ContainerType": "",
"DriverFirstName": "",
"DriverLastName": "",
"MissedCollectionService": "Electronic Waste",
"OtherServiceMissedReason": "",
"ServiceDateRendered": "",
"ServiceMissedReason": "I'm not sure",
"TruckNo": "",
"Type": "Service Not Complete",
"WireBasketLocation": "",
"LastUpdatedBy": "",
"Name": "05082015100148678"
}
]
},
"ListOfLa311Other": {},
"ListOfLa311WeedAbatementForPrivateParcels": {},
"ListOfLa311SanitationBillingInquiry": {}
}
]
}
}
} The code is below;
data2 = jsonpickle.decode((f2.read()))
Start = datetime.datetime.now()
data2 = jsonpickle.encode(data2)
url2 = "myURL"
headers2 = {'Content-type': 'text/plain', 'Accept': '/'}
r2 = requests.post(url2, data=data2, headers=headers2)
decoded2 = json.loads(r2.text)
try:
r2
except requests.exceptions.ConnectTimeout as e:
print "Too slow Mojo!"
items = []
for sr in decoded2['Response']['ListOfServiceRequest']['ServiceRequest']:
SRAddress = sr['SRAddress']
Latitude = sr['Latitude']
Longitude = sr['Longitude']
ReasonCode = sr['ReasonCode']
SRNumber = sr['SRNumber']
FirstName = sr['FirstName']
LastName = sr['LastName']
ResolutionCode = sr['ResolutionCode']
HomePhone = sr['HomePhone']
CreatedDate = sr['CreatedDate']
UpdatedDate = sr['UpdatedDate']
CreatedDate = datetime.datetime.strptime(CreatedDate, "%m/%d/%Y %H:%M:%S")
UpdatedDate = datetime.datetime.strptime(UpdatedDate, "%m/%d/%Y %H:%M:%S")
print SRAddress
print SRNumber
ItemInfo = " "
for ew in sr["ListOfLa311ServiceRequestNotes"][u"La311ServiceRequestNotes"]:
Comment = ew['Comment']
print Comment
Output Materials have been out in a normal collection area, unsure why driver missed the e-waste items. If I use the logic above for a response with more than one object returned I receive a KeyError value and am unable to access the array that I want to parse. Example of code with multiple objects returned; Output when I use; I receive a key error if I attempt to do something along the lines of CommodityType = sr['ListOfLa311ElectronicWaste']['ElectronicWasteType'] below for sr in decoded2['Response']['ListOfServiceRequest']['ServiceRequest']:
CommodityType = sr['ListOfLa311ElectronicWaste']
# ItemType = sr['ElectronicWestType']
# DriverFirstName = sr ['DriverFirstName']
# DriverLastName = sr ['DriverLastName']
# ItemCount = sr['ItemCount']
# ItemInfo += '{0}, {1}, '.format(ItemType, ItemCount)
# ParentNumber = sr['Name']
#
print CommodityType
{u'La311ElectronicWaste': [{u'IllegallyDumped': u'N', u'OtherElectronicWestType': u'hash', u'ItemCount': u'5', u'Name': u'6a31f058-ece1-4e7d-b682-7d9052a512f4', u'MobileHomeSpace': u'', u'DriverLastName': u'', u'ActiveStatus': u'Y', u'DriverFirstName': u'', u'LastUpdatedBy': u'', u'GatedCommunityMultifamilyDwelling': u'Outside the main gate', u'IllegalDumpCollectionLoc': u'', u'ElectronicWestType': u'Other', u'CollectionLocation': u'Gated Community', u'Type': u'Electronic Waste', u'ServiceDateRendered': u'', u'TruckNo': u''}]}
{u'La311ElectronicWaste': [{u'IllegallyDumped': u'Y', u'OtherElectronicWestType': u'', u'ItemCount': u'5', u'Name': u'3f4d9d20-a712-4be3-822f-e6a45219c1cf', u'MobileHomeSpace': u'', u'DriverLastName': u'', u'ActiveStatus': u'Y', u'DriverFirstName': u'', u'LastUpdatedBy': u'', u'GatedCommunityMultifamilyDwelling': u'', u'IllegalDumpCollectionLoc': u'Cul De Sac', u'ElectronicWestType': u'Electronic Equipment', u'CollectionLocation': u'Alley', u'Type': u'Electronic Waste', u'ServiceDateRendered': u'', u'TruckNo': u''}]}
... View more
05-08-2015
11:22 PM
|
0
|
3
|
4020
|
|
POST
|
I am an admin user, this solution does not seem very viable as the table has to be hosted on ArcGIS Server, I would like to host a table in ArcGIS Online and consume it to a local file geodatabase with python.
... View more
04-28-2015
06:56 AM
|
0
|
1
|
4897
|
|
POST
|
I would like to consume hosted features from ArcGIS Online into a local file geodatabase. I am consistently receving a 498 error. I am generating a token but when passing into ArcGIS server it is invalid. A couple of questions. a.) Do I need to use my organization url, i.e. myorg.maps.arcgis.com for my referrer? b.) When I am creating a replica; should this data be hosted in arcgis.com? I am making some changes to the script linked below which I found on github that uses urllib2, it doesn't work and isn't as elegant as the Requests. And for my purposes I do not need to add attachments to the database, just consume a table locally. Python script to pull hosted features with attachments into a local file geodatabase. See ReadMe below. Here are my script and results url = 'https://www.arcgis.com/sharing/generateToken'
payload = {'username' : 'myUser,
'password' : 'myPass!',
'referer' : 'www.arcgis.com',
'f' : 'json' }
r = requests.post(url, data=payload)
token =json.loads (r.text)
aToken = token['token']
print aToken
# Create Replica ###
# Update service url HERE ###
url2 = 'http://myIP:6080/arcgis/rest/services/FeatureMapService/FeatureServer/CreateReplica'
# #
payload2 = {'f' : 'json',
'layers' : '1',
'returnAttachments' : 'false',
'token' : token }
r2 = requests.post(url2, data=payload2)
repLoad = json.loads (r2.text)
print repLoad
C:\Python27\ArcGIS10.2\python.exe C:/Users/GIS/Documents/ArcGIS/timequery.py
lOg8435-zLN8aeWknNveul8EzYlmbKb2h5GXVHCazEEbs0VgvyKH-0rr-iZ3RNwN_HP0BfykxtuzgZaw_Bm8LMZoOoJ9KtydsLze2mEX5qcFKBKltW_goPIH9w43jvgtCqHGAbotdyGMTAZZ217QEVTNqnW74rgBtjf1eB7XFMUb1miuJbU2YhPDnpbQB1S-9alNOrp6loXtBzJFEN-oAA..
{u'error': {u'message': u'Invalid Token', u'code': 498, u'details': []}}
... View more
04-23-2015
08:04 AM
|
2
|
4
|
19030
|
|
POST
|
This is a general python question, I would like to write a function that essentially states if data is available do this, if not raise an error, and a finally block which does something else. In another function I would like write another if statement that says if function 1 raised an error do this, if not then do this. My question is, how do I reference this raised user-defined exception from my first function? Here is a code-block that I am working with. For example, if there is a raised error for NoData, I would like to say in another function, if NoData is raised then do this.... This block returns: Traceback (most recent call last): File "C:/Users/Administrator/Desktop/DevSummitJSON_PySeminar.py", line 231, in <module> servicequery(CreatedDate, now_minus_10) File "C:/Users/Administrator/Desktop/DevSummitJSON_PySeminar.py", line 227, in servicequery raise DataError, "Exception: Data is older than 10 minutes" __main__.DataError: Exception: Data is older than 10 minutes # severely edited, since improper indentation etc, precludes providing a test environment
import arcpy # not in original
arr = ##### # not in original
fc = #### # not in original
sr = #### # not in original
NumPyArray = arcpy.da.NumPyArrayToFeatureClass(arr, fc, ['longitudeshape', 'latitudeshape'], sr)
i = 5
i2= 10
now_minus_5 = Start - datetime.timedelta(minutes =i)
now_minus_10 = Start - datetime.timedelta(minutes =i2)
class DataError(Exception):
pass
class NoDatainLast5(Exception):
message = '\nException: NumberTooBigError:\nYour number is too big. \nTry a smaller one!'
class NoDatainLast10(Exception):
message = '\nException: NumberTooBigError:\nYour number is too big. \nTry a smaller one!'
def checkData(CreatedDate):
if CreatedDate > now_minus_10:
raise NoDatainLast10
elif CreatedDate > now_minus_10:
raise NoDatainLast5
elif CreatedDate is NULL :
raise DataError
def servicequery(CreatedDate, now_minus_10):
if CreatedDate > now_minus_10:
NumPyArray #see at the top
elif CreatedDate < now_minus_10:
raise DataError, "Exception: Data is older than 10 minutes"
else:
print "test"
servicequery(CreatedDate, now_minus_10) Message was edited by: Dan Patterson
I had to reformat the whole script due either to an incorrect format selection or source code was wrong. Added lines at the top of the code to facilitate testing using the edited script.
... View more
04-03-2015
08:19 PM
|
0
|
5
|
29829
|
|
POST
|
There's a much more elegant and scalable approach to this. import json
import jsonpickle
import requests
import arcpy
import numpy as np #NOTE THIS
fc = "C:\MYLATesting.gdb\MYLA311"
if arcpy.Exists(fc):
arcpy.Delete_management(fc)
ListTable ="C:\MYLATesting.gdb\MYLA311Dissolve"
if arcpy.Exists(ListTable):
arcpy.Delete_management(ListTable)
f2 = open('C:\Users\Administrator\Desktop\DetailView.json', 'r')
data2 = jsonpickle.encode( jsonpickle.decode(f2.read()) )
url2 = "myURL"
headers2 = {'Content-type': 'text/plain', 'Accept': '/'}
r2 = requests.post(url2, data=data2, headers=headers2)
decoded2 = json.loads(r2.text)
dt = np.dtype([('SRAddress', 'U40'),
('latitude', '<f8'),
('longitude', '<f8'),
('Type', 'U40'),
('SRNumber', 'U40'),
('FirstName', 'U40'),
('LastName', 'U40'),
('HomePhone', 'U40'),
('Comment', 'U128'),
('ItemInfo', 'U128'),
])
items = []
for sr in decoded2['Response']['ListOfServiceRequest']['ServiceRequest']:
SRAddress = sr['SRAddress']
latitude = sr['Latitude']
longitude = sr['Longitude']
SRNumber = sr['SRNumber']
FirstName = sr['FirstName']
LastName = sr['LastName']
HomePhone = sr['HomePhone']
ItemInfo = " "
for ew in sr["ListOfLa311ElectronicWaste"][u"La311ElectronicWaste"]:
CommodityType = ew['Type']
ItemType = ew['ElectronicWestType']
ItemCount = ew['ItemCount']
ItemInfo += '{0},{1}'.format(ItemType, ItemCount)
comments = [ cl['Comment'] for cl in sr["ListOfLa311ServiceRequestNotes"][u"La311ServiceRequestNotes"]]
print comments
Comment = ' '.join(comments)
items.append((SRAddress,
latitude,
longitude,
CommodityType,
SRNumber,
FirstName,
LastName,
HomePhone,
Comment,
ItemInfo))
arr = np.array(items,dtype=dt)
sr = arcpy.SpatialReference(4326)
arcpy.da.NumPyArrayToFeatureClass(arr, fc, ['longitude', 'latitude'], sr )
print json.dumps(decoded2, sort_keys=True, indent=4)
... View more
03-09-2015
01:55 PM
|
0
|
1
|
472
|
|
POST
|
We use Collector on Android devices in the field and its proven to be a HUGE asset in our daily operations. We have considered using JSAPI, but with Collector's out of the box features that requires no development or configuration, it saves time and effort for the field staff using the application in addition to our our office GIS staff, i.e. no updating JSAPI and DOJO versions, etc. I guess it depends on your workflow and how important the UI/UX is for your field staff. Collector and ArcGIS Server really are definitive for a GIS field-to-office workflow IMO.
... View more
03-05-2015
12:03 PM
|
1
|
0
|
658
|
|
POST
|
Darren, A couple of questions, I would like to do the same for another field, but there is not always a guaranteed 1-1 relationship between items and comments. Is there a way to implement a loop for the rows instead of using the index? For instance, when I try to insert a comments field and concatenate all comments for the associated request, my output becomes truncated giving me only 1 itemcount and itemtype. "ListOfLa311ServiceRequestNotes": {
"La311ServiceRequestNotes": [
{
"Comment": "Out on the sidewalk near the curb. Hopefully it is still there.",
"CommentType": "Address Comments",
"CreatedByUser": "MYLATHREEONEONE",
"CreatedDate": "02/17/2015 16:53:26",
"Date1": "",
"Date2": "",
"Date3": "",
"FeedbackSRType": "",
"IntegrationId": "021720151654176661",
"IsSrNoAvailable": "",
"ListOfLa311SrNotesAuditTrail": {},
"Notification": "N",
"Text1": ""
},
{
"Comment": "So glad to get rid of this old junk. Thanks.",
"CommentType": "External",
"CreatedByUser": "MYLATHREEONEONE",
"CreatedDate": "02/17/2015 16:53:26",
"Date1": "",
"Date2": "",
"Date3": "",
"FeedbackSRType": "",
"IntegrationId": "021720151654176662",
"IsSrNoAvailable": "",
"ListOfLa311SrNotesAuditTrail": {},
"Notification": "N",
"Text1": ""
}
]
},
import json
import jsonpickle
import requests
import arcpy
fc = "C:\MYLATesting.gdb\MYLA311"
if arcpy.Exists(fc):
arcpy.Delete_management(fc)
ListTable ="C:\MYLATesting.gdb\MYLA311Dissolve"
if arcpy.Exists(ListTable):
arcpy.Delete_management(ListTable)
f2 = open('C:\Users\Administrator\Desktop\DetailView.json', 'r')
data2 = jsonpickle.encode( jsonpickle.decode(f2.read()) )
url2 = "myURL"
headers2 = {'Content-type': 'text/plain', 'Accept': '/'}
r2 = requests.post(url2, data=data2, headers=headers2)
decoded2 = json.loads(r2.text)
items = []
for sr in decoded2['Response']['ListOfServiceRequest']['ServiceRequest']:
SRAddress = sr['SRAddress']
latitude = sr['Latitude']
longitude = sr['Longitude']
SRNumber = sr['SRNumber']
FirstName = sr['FirstName']
LastName = sr['LastName']
HomePhone = sr['HomePhone']
for ew in sr["ListOfLa311ElectronicWaste"][u"La311ElectronicWaste"]:
CommodityType = ew['Type']
ItemType = ew['ElectronicWestType']
ItemCount = ew['ItemCount']
for comm in sr["ListOfLa311ServiceRequestNotes"][u"La311ServiceRequestNotes"]:
Comment = comm['Comment']
items.append((SRAddress,
latitude,
longitude,
CommodityType,
ItemType,
SRNumber,
ItemCount,
FirstName,
LastName,
Comment,
HomePhone))
import numpy as np #NOTE THIS
dt = np.dtype([('SRAddress', 'U40'),
('latitude', '<f8'),
('longitude', '<f8'),
('Type', 'U40'),
('ElectronicWestType', 'U40'),
('SRNumber', 'U40'),
('ItemCount', 'U40'),
('FirstName', 'U40'),
('LastName', 'U40'),
('Comment', 'U40'),
('HomePhone', 'U40')])
arr = np.array(items,dtype=dt)
sr = arcpy.SpatialReference(4326)
arcpy.da.NumPyArrayToFeatureClass(arr, fc, ['longitude', 'latitude'], sr )
arcpy.AddField_management(fc, "SRList", "TEXT", 255)
arcpy.AddField_management(fc, "Comments", "TEXT", 255)
valueList = [] # empty list
with arcpy.da.SearchCursor(fc,["SRAddress","SRNumber"]) as cursor:
for row in cursor:
# get all combinations of SRAddress & SRNumber
valueList.append(row[0]+str(row[1]))
# make unique value set
valueSet = set(valueList)
# convert set to dictionary keys
valueDict = dict.fromkeys(valueSet)
with arcpy.da.SearchCursor(fc,["SRAddress","SRNumber","ElectronicWestType","ItemCount", "Comment"]) as cursor:
for row in cursor:
# create comma-separated list of values matching each dictionary key
if not valueDict[row[0]+str(row[1])]:
valueDict[row[0]+str(row[1])] = str(row[2]) + ', ' + str(row[3])
else:
valueDict[row[0]+str(row[1])] = str(row[2]) + ', ' + str(row[3]) + ', ' + str(valueDict[row[0]+str(row[1])])
with arcpy.da.UpdateCursor(fc,["SRAddress","SRNumber","SRList"]) as cursor:
for row in cursor:
# write comma-separated list for each row, matching SRAddress & SRNumber
row[2] = valueDict[row[0]+str(row[1])]
cursor.updateRow(row)
arcpy.Dissolve_management(fc, "C:\MYLATesting.gdb\MYLA311Dissolve", ["SRNumber", "SRAddress", "Type", "SRList", "FirstName", "LastName", "HomePhone", "Comment"])
print json.dumps(decoded2, sort_keys=True, indent=4)
... View more
03-05-2015
09:22 AM
|
0
|
0
|
4002
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 03-16-2017 02:33 PM | |
| 1 | 01-18-2022 07:40 AM | |
| 1 | 04-28-2021 09:29 AM | |
| 1 | 10-24-2016 12:07 PM | |
| 1 | 04-28-2016 09:12 AM |
| Online Status |
Offline
|
| Date Last Visited |
01-18-2022
03:08 PM
|