|
POST
|
Shouldn't be an issue with data stores, where are the service definitions generally found?
... View more
02-17-2015
01:22 PM
|
0
|
1
|
1026
|
|
POST
|
Our production box has too many processes running on it causing our map services to not publish, thus we are moving a few development services to another box. What is the best way to do this? Both are running Server 10.2.
... View more
02-17-2015
01:09 PM
|
0
|
7
|
4551
|
|
POST
|
Hi Dan, The above solution works, thank you so much for your assistance. Finally, in line 15 above, what does [key] refer to? How are each of the individuals keys referenced to this item?
... View more
02-16-2015
11:12 PM
|
0
|
1
|
4087
|
|
POST
|
Thanks Dan, I have tested the block above. How would this be implemented in my code to solve my error? I receive multiple keys from my items dictionary. Dictionary output item SRAddress: 1200 W TEMPLE ST, 90026 longitude: -118.252968 latitude: 34.064937 List comprehension output With the decoder ring (u'34.064937', u'1200 W TEMPLE ST, 90026', u'-118.252968') items ={'SRAddress': SRAddress, 'Longitude': longitude, 'Latitude': latitude}
... View more
02-15-2015
08:18 PM
|
0
|
0
|
4087
|
|
POST
|
vehicles = [] for item in a['items']: vehicles.append(tuple(unicode(item for k in ndtype.names))) print vehicles
... View more
02-15-2015
02:33 PM
|
0
|
2
|
4087
|
|
POST
|
When I print vehicles I receive [(u'<', u'g', u'e', u'n', u'e', u'r', u'a', u't', u'o', u'r', u' ', u'o', u'b', u'j', u'e', u'c', u't', u' ', u'<', u'g', u'e', u'n', u'e', u'x', u'p', u'r', u'>', u' ', u'a', u't', u' ', u'0', u'x', u'0', u'D', u'5', u'A', u'3', u'D', u'0', u'0', u'>')] What does this indicate??
... View more
02-14-2015
02:18 PM
|
0
|
4
|
4087
|
|
POST
|
I have a script which parses an json web-service and uses parses the fields to add to a file geodatabase, towards the end of my script I receive the error. I receive the error File "C:/Python27/ArcGIS10.2/websocket-client-0.23.0/websocket-client-0.23.0/examples/JSONSerializer.py", line 43, in narr = numpy.array([vehicles], ndtype) ValueError: size of tuple must match number of fields. import json
import jsonpickle
import requests
import arcpy
import numpy
fc = "C:\MYLATesting.gdb\MYLA311"
if arcpy.Exists(fc):
arcpy.Delete_management(fc)
f = open('C:\Users\Administrator\Desktop\myla311.json', 'r')
data = jsonpickle.encode( jsonpickle.decode(f.read()) )
url = "https://myla311test.lacity.org/myla311router/mylasrbe/1/QuerySR"
headers = {'Content-type': 'text/plain', 'Accept': '/'}
r = requests.post(url, data=data, headers=headers)
sr = arcpy.SpatialReference(4326)
decoded = json.loads(r.text)
SRAddress = decoded['Response']['ListOfServiceRequest']['ServiceRequest'][0]['SRAddress']
latitude = decoded['Response']['ListOfServiceRequest']['ServiceRequest'][0]['Latitude']
longitude = decoded['Response']['ListOfServiceRequest']['ServiceRequest'][0]['Longitude']
a = {"items":[{SRAddress, latitude, longitude}]}
ndtype = numpy.dtype([
('SRAddress', 'S16'),
('latitude', 'F48'),
('longitude', 'F48')
])
vehicles = []
for item in a['items']:
vehicles.append(tuple(unicode(item for k in ndtype.names)))
#
narr = numpy.array([vehicles], ndtype)
arcpy.da.NumPyArrayToFeatureClass(narr, fc, ['longitude', 'latitude'], sr)
print a.keys()
# parsed_json = json.dumps(decoded, sort_keys=True, indent=4)
# print json.dumps(decoded, sort_keys=True, indent=4)
... View more
02-14-2015
01:23 PM
|
0
|
9
|
9801
|
|
POST
|
I have a JSON web-service that I would like to parse data from and write to a feature class. I have a proof of concept script for a more robust and user friendly API. Taking most pieces from this script, I would like to use in the same way, however, due to the structure of the JSON I am having difficulty grabbing the key/value pairs. Here is the original script which Joshua Bixby has offered great assistance with. My print decoded.items and .keys function in the 2nd script returns identical outputs. I would like to be able to successfully parse out key/values in the output to write to a feature class, i.e. lat/lng, address, name SR type, etc. Are there ever instances when JSON files do not have key/value pairs?? And if so, what is an elegant solution to handle this? import arcpy
import json
import numpy
import requests
fc = "C:\MYLATesting.gdb\MYLA311"
if arcpy.Exists(fc):
arcpy.Delete_management(fc)
url = "http://api.metro.net/agencies/lametro/vehicles/"
r = requests.get(url)
parsed_json = r.json()
sr = arcpy.SpatialReference(4326) #assuming wgs84 coords but didn't verify
r.json()
ndtype = numpy.dtype([
('id', 'S12'),
('route_id', 'S12'),
('latitude', 'f8'),
('longitude', 'f8'),
('heading', 'f8'),
('seconds_since_report', 'i4'),
('predictable', '?')
])
vehicles = []
for item in parsed_json['items']:
vehicles.append(tuple(item for k in ndtype.names))
narr = numpy.array([vehicles], ndtype)
arcpy.da.NumPyArrayToFeatureClass(narr, fc, ['longitude', 'latitude'], sr)
Here is the script that I am having difficulties with. import jsonpickle
import arcpy
import json
import numpy
import requests
fc = "C:\MYLATesting.gdb\MYLA311"
if arcpy.Exists(fc):
arcpy.Delete_management(fc)
f = open('C:\Users\Administrator\Desktop\myla311.json', 'r')
data = jsonpickle.encode( jsonpickle.decode(f.read()) )
url = "https://myla311test.lacity.org/myla311router/mylasrbe/1/QuerySR"
headers = {'Content-type': 'text/plain', 'Accept': '/'}
r = requests.post(url, data=data, headers=headers)
sr = arcpy.SpatialReference(4326)
decoded = json.loads(r.text)
print json.dumps(decoded, sort_keys=True, indent=4)
print decoded
print decoded.keys()
print decoded.items()
f.close()
Input JSON { "RequestSpecificDetail": { "ParentSRNumberForLink": "" }, "MetaData": { "appVersion": "1.34", "deviceModel": "x86_64", "dateAndTime": "01/15/2015 12:46:36", "deviceToken": "A2C1DD9D-D17D-4031-BA3E-977C250BFD58", "osVersion": "8.1" }, "SRData": { "SRNumber": "1-1080871" } } Output { "Response": { "ListOfServiceRequest": { "ServiceRequest": [ { "ActionTaken": "", "AddressVerified": "Y", "Anonymous": "N", "AssignTo": "North Central - 104 - IED", "Assignee": "Siebel Administrator", "CreatedByUserLogin": "PRASAD89", "CreatedDate": "12/31/2014 13:49:23", "CustomerAccessNumber": "", "Email": "prasadpotale@gmail.com", "FirstName": "Prasad", "HomePhone": "3123123123", "IntegrationId": "1420033765921", "LADWPAccountNo": "", "Language": "English", "LastName": "Pp", "Latitude": "34.064937", "ListOfAuditTrailItem2": {}, "ListOfChildServiceRequest": {}, "ListOfLa311BarricadeRemoval": {}, "ListOfLa311BeesOrBeehive": {}, "ListOfLa311BillingCsscAdjustment": {}, "ListOfLa311BillingEccAdjustment": {}, "ListOfLa311BillingRsscAdjustment": {}, "ListOfLa311BillingRsscExemption": {}, "ListOfLa311BrushItemsPickup": {}, "ListOfLa311BulkyItem": {}, "ListOfLa311BusPadLanding": {}, "ListOfLa311Containers": {}, "ListOfLa311CurbRepair": {}, "ListOfLa311DeadAnimalRemoval": {}, "ListOfLa311DocumentLog": {}, "ListOfLa311ElectronicWaste": {}, "ListOfLa311Flooding": {}, "ListOfLa311GeneralStreetInspection": {}, "ListOfLa311GenericBc": { "La311GenericBc": [ { "ATTRIB_08": "", "ListOfLa311GenericbcAuditTrail": {}, "NAME": "41572025-3803-49c4-8561-6e7ef41775df", "PAR_ROW_ID": "1-N607", "ROW_ID": "1-N60A", "TYPE": "GIS" }, { "ATTRIB_08": "", "ListOfLa311GenericbcAuditTrail": {}, "NAME": "a5b5b2b9-d2e7-400a-bf75-1138ff013caa", "PAR_ROW_ID": "1-N607", "ROW_ID": "1-N609", "TYPE": "Homeless Encampment" }, { "ATTRIB_08": "", "ListOfLa311GenericbcAuditTrail": {}, "NAME": "010420150405", "PAR_ROW_ID": "1-N607", "ROW_ID": "1-RN2D", "TYPE": "Subscription" } ] }, "ListOfLa311GisLayer": { "La311GisLayer": [ { "A_Call_No": "", "Area": "", "BOSRadioHolderName": "", "CommunityPlanningArea": "Westlake", "Day": "", "DirectionSuffix": "", "DistrictAbbr": "", "DistrictName": "Central", "DistrictNumber": "104", "DistrictOffice": "North Central", "Fraction": "", "LastUpdatedBy": "", "Name": "41572025-3803-49c4-8561-6e7ef41775df", "R_Call_No": "", "SectionId": "5279800", "ShortDay": "", "StreetFrom": "BOYLSTON ST", "StreetLightId": "", "StreetLightStatus": "", "StreetTo": "FIRMIN ST", "Type": "GIS", "Y_Call_No": "" } ] }, "ListOfLa311GraffitiRemoval": {}, "ListOfLa311GuardWarningRailMaintenance": {}, "ListOfLa311GutterRepair": {}, "ListOfLa311HomelessEncampment": { "La311HomelessEncampment": [ { "ApprovedBy": "", "AssignedTo": "", "CompletedBy": "", "Contact": "", "ContactDate": "", "Crew": "", "DateCompleted": "12/31/2014 00:00:00", "InspectedBy": "", "InspectionDate": "", "LastUpdatedBy": "", "Location": "Alley", "Name": "a5b5b2b9-d2e7-400a-bf75-1138ff013caa", "OptionalTrackingCode": "", "Type": "Homeless Encampment" } ] }, "ListOfLa311IllegalAutoRepair": {}, "ListOfLa311IllegalConstruction": {}, "ListOfLa311IllegalConstructionFence": {}, "ListOfLa311IllegalDischargeOfWater": {}, "ListOfLa311IllegalDumpingInProgress": {}, "ListOfLa311IllegalDumpingPickup": {}, "ListOfLa311IllegalExcavation": {}, "ListOfLa311IllegalSignRemoval": {}, "ListOfLa311IllegalVending": {}, "ListOfLa311InformationOnly": {}, "ListOfLa311LandMudSlide": {}, "ListOfLa311LeafBlowerViolation": {}, "ListOfLa311ManualPickup": {}, "ListOfLa311MedianIslandMaintenance": {}, "ListOfLa311MetalHouseholdAppliancesPickup": {}, "ListOfLa311MoveInMoveOut": {}, "ListOfLa311MultipleStreetlightIssue": {}, "ListOfLa311NewsRackViolation": {}, "ListOfLa311Obstructions": {}, "ListOfLa311Other": {}, "ListOfLa311OvergrownVegetationPlants": {}, "ListOfLa311PalmFrondsDown": {}, "ListOfLa311Pothole": {}, "ListOfLa311Resurfacing": {}, "ListOfLa311SanitationBillingBif": {}, "ListOfLa311SanitationBillingCssc": {}, "ListOfLa311SanitationBillingEcc": {}, "ListOfLa311SanitationBillingInquiry": {}, "ListOfLa311SanitationBillingLifeline": {}, "ListOfLa311SanitationBillingRssc": {}, "ListOfLa311SanitationBillingSrf": {}, "ListOfLa311ServiceNotComplete": {}, "ListOfLa311ServiceRequestNotes": { "La311ServiceRequestNotes": [ { "Comment": "", "CommentType": "External", "CreatedByUser": "PRASAD89", "CreatedDate": "12/31/2014 13:49:23", "Date1": "", "Date2": "", "Date3": "", "FeedbackSRType": "", "IntegrationId": "1420033765921", "IsSrNoAvailable": "N", "ListOfLa311SrNotesAuditTrail": {}, "Notification": "N", "Text1": "" } ] }, "ListOfLa311SidewalkRepair": {}, "ListOfLa311SingleStreetlightIssue": {}, "ListOfLa311SrPhotoId": { "La311SrPhotoId": [] }, "ListOfLa311StreetSweeping": {}, "ListOfLa311StreetTreeInspection": {}, "ListOfLa311StreetTreeViolations": {}, "ListOfLa311SubscribeDuplicateSr": { "La311SubscribeDuplicateSr": [ { "Activeflag": "Y", "EmailId": "pratik.desai@yoopmail.com", "LastUpdatedBy": "", "Name": "010420150405", "Type": "Subscription" } ] }, "ListOfLa311TablesAndChairsObstructing": {}, "ListOfLa311TreeEmergency": {}, "ListOfLa311TreeObstruction": {}, "ListOfLa311TreePermits": {}, "ListOfLa311WeedAbatementForPrivateParcels": {}, "LoginUser": "", "Longitude": "-118.252968", "MobilOS": "iOS", "NewContactEmail": "", "NewContactFirstName": "", "NewContactLastName": "", "NewContactPhone": "", "Owner": "BSS", "ParentSRLinkDate": "", "ParentSRLinkUser": "", "ParentSRNumber": "", "ParentSRStatus": "", "ParentSRType": "", "Priority": "Normal", "ReasonCode": "", "RescheduleCounter": "", "ResolutionCode": "", "SRAddress": "1200 W TEMPLE ST, 90026", "SRAddressName": "", "SRAreaPlanningCommission": "Central APC", "SRAreaPlanningCommissionId": "4", "SRCity": "", "SRCommunityPoliceStation": "", "SRCommunityPoliceStationAPREC": "RAMPART", "SRCommunityPoliceStationPREC": "2", "SRCouncilDistrictMember": "Gilbert Cedillo", "SRCouncilDistrictNo": "1", "SRCrossStreet": "", "SRDirection": "W", "SRHouseNumber": "", "SRNeighborhoodCouncilId": "44", "SRNeighborhoodCouncilName": "GREATER ECHO PARK ELYSIAN NC", "SRNumber": "1-1080871", "SRStreetName": "TEMPLE", "SRSuffix": "ST", "SRTBColumn": "E", "SRTBMapGridPage": "634", "SRTBRow": "2", "SRType": "Homeless Encampment", "SRUnitNumber": "", "SRXCoordinate": "6485064", "SRYCoordinate": "1846114", "ServiceDate": "12/31/2014 00:00:00", "Source": "311", "Status": "Open", "UpdatedByUserLogin": "PRASAD89", "UpdatedDate": "12/31/2014 13:49:23", "Zipcode": "90026" } ] }, "NumOutputObjects": "1" }, "status": { "cause": "", "code": 311, "message": "Service Request Successfully Queried." } } {u'status': {u'message': u'Service Request Successfully Queried.', u'code': 311, u'cause': u''}, u'Response': {u'NumOutputObjects': u'1', u'ListOfServiceRequest': {u'ServiceRequest': [{u'ListOfLa311StreetSweeping': {}, u'SRCouncilDistrictMember': u'Gilbert Cedillo', u'ListOfLa311IllegalConstructionFence': {}, u'UpdatedDate': u'12/31/2014 13:49:23', u'ListOfLa311ServiceNotComplete': {}, u'ListOfChildServiceRequest': {}, u'ListOfLa311ElectronicWaste': {}, u'SRAddress': u'1200 W TEMPLE ST, 90026', u'ListOfLa311MetalHouseholdAppliancesPickup': {}, u'ListOfLa311SubscribeDuplicateSr': {u'La311SubscribeDuplicateSr': [{u'EmailId': u'pratik.desai@yoopmail.com', u'LastUpdatedBy': u'', u'Type': u'Subscription', u'Name': u'010420150405', u'Activeflag': u'Y'}]}, u'ListOfLa311IllegalSignRemoval': {}, u'CustomerAccessNumber': u'', u'ListOfLa311IllegalDumpingInProgress': {}, u'Anonymous': u'N', u'SRDirection': u'W', u'ListOfLa311NewsRackViolation': {}, u'SRXCoordinate': u'6485064', u'ListOfLa311GenericBc': {u'La311GenericBc': [{u'ATTRIB_08': u'', u'NAME': u'41572025-3803-49c4-8561-6e7ef41775df', u'PAR_ROW_ID': u'1-N607', u'ROW_ID': u'1-N60A', u'TYPE': u'GIS', u'ListOfLa311GenericbcAuditTrail': {}}, {u'ATTRIB_08': u'', u'NAME': u'a5b5b2b9-d2e7-400a-bf75-1138ff013caa', u'PAR_ROW_ID': u'1-N607', u'ROW_ID': u'1-N609', u'TYPE': u'Homeless Encampment', u'ListOfLa311GenericbcAuditTrail': {}}, {u'ATTRIB_08': u'', u'NAME': u'010420150405', u'PAR_ROW_ID': u'1-N607', u'ROW_ID': u'1-RN2D', u'TYPE': u'Subscription', u'ListOfLa311GenericbcAuditTrail': {}}]}, u'ListOfLa311TreePermits': {}, u'Longitude': u'-118.252968', u'ListOfLa311SanitationBillingCssc': {}, u'ListOfLa311SanitationBillingSrf': {}, u'ListOfLa311HomelessEncampment': {u'La311HomelessEncampment': [{u'DateCompleted': u'12/31/2014 00:00:00', u'ContactDate': u'', u'ApprovedBy': u'', u'Name': u'a5b5b2b9-d2e7-400a-bf75-1138ff013caa', u'Contact': u'', u'LastUpdatedBy': u'', u'InspectionDate': u'', u'Crew': u'', u'AssignedTo': u'', u'CompletedBy': u'', u'Location': u'Alley', u'InspectedBy': u'', u'OptionalTrackingCode': u'', u'Type': u'Homeless Encampment'}]}, u'ListOfLa311ServiceRequestNotes': {u'La311ServiceRequestNotes': [{u'Comment': u'', u'FeedbackSRType': u'', u'Date3': u'', u'Date2': u'', u'Notification': u'N', u'Date1': u'', u'Text1': u'', u'IntegrationId': u'1420033765921', u'CreatedByUser': u'PRASAD89', u'CommentType': u'External', u'ListOfLa311SrNotesAuditTrail': {}, u'CreatedDate': u'12/31/2014 13:49:23', u'IsSrNoAvailable': u'N'}]}, u'ListOfLa311SingleStreetlightIssue': {}, u'SRYCoordinate': u'1846114', u'ListOfLa311Pothole': {}, u'ParentSRLinkDate': u'', u'ListOfLa311TreeEmergency': {}, u'ListOfLa311GeneralStreetInspection': {}, u'ListOfLa311MedianIslandMaintenance': {}, u'ListOfLa311StreetTreeInspection': {}, u'SRNumber': u'1-1080871', u'ListOfLa311InformationOnly': {}, u'ListOfLa311ManualPickup': {}, u'ListOfLa311Obstructions': {}, u'SRSuffix': u'ST', u'Zipcode': u'90026', u'Priority': u'Normal', u'Source': u'311', u'SRCity': u'', u'Latitude': u'34.064937', u'SRNeighborhoodCouncilName': u'GREATER ECHO PARK ELYSIAN NC', u'Email': u'prasadpotale@gmail.com', u'RescheduleCounter': u'', u'AssignTo': u'North Central - 104 - IED', u'ListOfLa311Resurfacing': {}, u'SRCommunityPoliceStation': u'', u'ListOfLa311GuardWarningRailMaintenance': {}, u'SRAreaPlanningCommissionId': u'4', u'ListOfLa311BusPadLanding': {}, u'ListOfLa311SanitationBillingInquiry': {}, u'SRTBMapGridPage': u'634', u'ListOfLa311SanitationBillingBif': {}, u'AddressVerified': u'Y', u'MobilOS': u'iOS', u'ParentSRLinkUser': u'', u'SRAddressName': u'', u'ListOfLa311Other': {}, u'ListOfLa311SanitationBillingLifeline': {}, u'SRUnitNumber': u'', u'UpdatedByUserLogin': u'PRASAD89', u'ListOfLa311SanitationBillingRssc': {}, u'SRHouseNumber': u'', u'ListOfLa311IllegalAutoRepair': {}, u'CreatedDate': u'12/31/2014 13:49:23', u'Owner': u'BSS', u'SRCrossStreet': u'', u'FirstName': u'Prasad', u'CreatedByUserLogin': u'PRASAD89', u'LastName': u'Pp', u'SRCouncilDistrictNo': u'1', u'ListOfLa311DocumentLog': {}, u'SRTBColumn': u'E', u'Status': u'Open', u'SRCommunityPoliceStationPREC': u'2', u'ListOfLa311IllegalConstruction': {}, u'ListOfLa311BarricadeRemoval': {}, u'ParentSRStatus': u'', u'NewContactEmail': u'', u'ListOfLa311SanitationBillingEcc': {}, u'ListOfLa311StreetTreeViolations': {}, u'Language': u'English', u'ListOfLa311DeadAnimalRemoval': {}, u'ListOfLa311PalmFrondsDown': {}, u'ListOfLa311IllegalExcavation': {}, u'ServiceDate': u'12/31/2014 00:00:00', u'LoginUser': u'', u'ParentSRNumber': u'', u'SRAreaPlanningCommission': u'Central APC', u'ListOfLa311IllegalDumpingPickup': {}, u'ListOfLa311SidewalkRepair': {}, u'LADWPAccountNo': u'', u'ListOfLa311BillingCsscAdjustment': {}, u'ListOfAuditTrailItem2': {}, u'ListOfLa311IllegalDischargeOfWater': {}, u'SRCommunityPoliceStationAPREC': u'RAMPART', u'ParentSRType': u'', u'Assignee': u'Siebel Administrator', u'ListOfLa311Containers': {}, u'ListOfLa311BeesOrBeehive': {}, u'ListOfLa311BulkyItem': {}, u'SRType': u'Homeless Encampment', u'SRStreetName': u'TEMPLE', u'ListOfLa311WeedAbatementForPrivateParcels': {}, u'ResolutionCode': u'', u'ListOfLa311GraffitiRemoval': {}, u'ListOfLa311Flooding': {}, u'ListOfLa311IllegalVending': {}, u'ListOfLa311TablesAndChairsObstructing': {}, u'ListOfLa311MoveInMoveOut': {}, u'ListOfLa311BillingEccAdjustment': {}, u'ListOfLa311OvergrownVegetationPlants': {}, u'NewContactFirstName': u'', u'ListOfLa311BrushItemsPickup': {}, u'IntegrationId': u'1420033765921', u'ReasonCode': u'', u'ListOfLa311CurbRepair': {}, u'ListOfLa311LeafBlowerViolation': {}, u'ListOfLa311MultipleStreetlightIssue': {}, u'ListOfLa311TreeObstruction': {}, u'ActionTaken': u'', u'ListOfLa311BillingRsscAdjustment': {}, u'ListOfLa311GisLayer': {u'La311GisLayer': [{u'DistrictOffice': u'North Central', u'Area': u'', u'Y_Call_No': u'', u'Fraction': u'', u'StreetLightId': u'', u'Type': u'GIS', u'DistrictAbbr': u'', u'R_Call_No': u'', u'CommunityPlanningArea': u'Westlake', u'LastUpdatedBy': u'', u'DistrictName': u'Central', u'BOSRadioHolderName': u'', u'A_Call_No': u'', u'Day': u'', u'DistrictNumber': u'104', u'Name': u'41572025-3803-49c4-8561-6e7ef41775df', u'StreetTo': u'FIRMIN ST', u'StreetLightStatus': u'', u'DirectionSuffix': u'', u'ShortDay': u'', u'SectionId': u'5279800', u'StreetFrom': u'BOYLSTON ST'}]}, u'ListOfLa311SrPhotoId': {u'La311SrPhotoId': []}, u'ListOfLa311LandMudSlide': {}, u'SRNeighborhoodCouncilId': u'44', u'ListOfLa311BillingRsscExemption': {}, u'SRTBRow': u'2', u'NewContactLastName': u'', u'NewContactPhone': u'', u'ListOfLa311GutterRepair': {}, u'HomePhone': u'3123123123'}]}}} [u'status', u'Response'] [(u'status', {u'message': u'Service Request Successfully Queried.', u'code': 311, u'cause': u''}), (u'Response', {u'NumOutputObjects': u'1', u'ListOfServiceRequest': {u'ServiceRequest': [{u'ListOfLa311StreetSweeping': {}, u'SRCouncilDistrictMember': u'Gilbert Cedillo', u'ListOfLa311IllegalConstructionFence': {}, u'UpdatedDate': u'12/31/2014 13:49:23', u'ListOfLa311ServiceNotComplete': {}, u'ListOfChildServiceRequest': {}, u'ListOfLa311ElectronicWaste': {}, u'SRAddress': u'1200 W TEMPLE ST, 90026', u'ListOfLa311MetalHouseholdAppliancesPickup': {}, u'ListOfLa311SubscribeDuplicateSr': {u'La311SubscribeDuplicateSr': [{u'EmailId': u'pratik.desai@yoopmail.com', u'LastUpdatedBy': u'', u'Type': u'Subscription', u'Name': u'010420150405', u'Activeflag': u'Y'}]}, u'ListOfLa311IllegalSignRemoval': {}, u'CustomerAccessNumber': u'', u'ListOfLa311IllegalDumpingInProgress': {}, u'Anonymous': u'N', u'SRDirection': u'W', u'ListOfLa311NewsRackViolation': {}, u'SRXCoordinate': u'6485064', u'ListOfLa311GenericBc': {u'La311GenericBc': [{u'ATTRIB_08': u'', u'NAME': u'41572025-3803-49c4-8561-6e7ef41775df', u'PAR_ROW_ID': u'1-N607', u'ROW_ID': u'1-N60A', u'TYPE': u'GIS', u'ListOfLa311GenericbcAuditTrail': {}}, {u'ATTRIB_08': u'', u'NAME': u'a5b5b2b9-d2e7-400a-bf75-1138ff013caa', u'PAR_ROW_ID': u'1-N607', u'ROW_ID': u'1-N609', u'TYPE': u'Homeless Encampment', u'ListOfLa311GenericbcAuditTrail': {}}, {u'ATTRIB_08': u'', u'NAME': u'010420150405', u'PAR_ROW_ID': u'1-N607', u'ROW_ID': u'1-RN2D', u'TYPE': u'Subscription', u'ListOfLa311GenericbcAuditTrail': {}}]}, u'ListOfLa311TreePermits': {}, u'Longitude': u'-118.252968', u'ListOfLa311SanitationBillingCssc': {}, u'ListOfLa311SanitationBillingSrf': {}, u'ListOfLa311HomelessEncampment': {u'La311HomelessEncampment': [{u'DateCompleted': u'12/31/2014 00:00:00', u'ContactDate': u'', u'ApprovedBy': u'', u'Name': u'a5b5b2b9-d2e7-400a-bf75-1138ff013caa', u'Contact': u'', u'LastUpdatedBy': u'', u'InspectionDate': u'', u'Crew': u'', u'AssignedTo': u'', u'CompletedBy': u'', u'Location': u'Alley', u'InspectedBy': u'', u'OptionalTrackingCode': u'', u'Type': u'Homeless Encampment'}]}, u'ListOfLa311ServiceRequestNotes': {u'La311ServiceRequestNotes': [{u'Comment': u'', u'FeedbackSRType': u'', u'Date3': u'', u'Date2': u'', u'Notification': u'N', u'Date1': u'', u'Text1': u'', u'IntegrationId': u'1420033765921', u'CreatedByUser': u'PRASAD89', u'CommentType': u'External', u'ListOfLa311SrNotesAuditTrail': {}, u'CreatedDate': u'12/31/2014 13:49:23', u'IsSrNoAvailable': u'N'}]}, u'ListOfLa311SingleStreetlightIssue': {}, u'SRYCoordinate': u'1846114', u'ListOfLa311Pothole': {}, u'ParentSRLinkDate': u'', u'ListOfLa311TreeEmergency': {}, u'ListOfLa311GeneralStreetInspection': {}, u'ListOfLa311MedianIslandMaintenance': {}, u'ListOfLa311StreetTreeInspection': {}, u'SRNumber': u'1-1080871', u'ListOfLa311InformationOnly': {}, u'ListOfLa311ManualPickup': {}, u'ListOfLa311Obstructions': {}, u'SRSuffix': u'ST', u'Zipcode': u'90026', u'Priority': u'Normal', u'Source': u'311', u'SRCity': u'', u'Latitude': u'34.064937', u'SRNeighborhoodCouncilName': u'GREATER ECHO PARK ELYSIAN NC', u'Email': u'prasadpotale@gmail.com', u'RescheduleCounter': u'', u'AssignTo': u'North Central - 104 - IED', u'ListOfLa311Resurfacing': {}, u'SRCommunityPoliceStation': u'', u'ListOfLa311GuardWarningRailMaintenance': {}, u'SRAreaPlanningCommissionId': u'4', u'ListOfLa311BusPadLanding': {}, u'ListOfLa311SanitationBillingInquiry': {}, u'SRTBMapGridPage': u'634', u'ListOfLa311SanitationBillingBif': {}, u'AddressVerified': u'Y', u'MobilOS': u'iOS', u'ParentSRLinkUser': u'', u'SRAddressName': u'', u'ListOfLa311Other': {}, u'ListOfLa311SanitationBillingLifeline': {}, u'SRUnitNumber': u'', u'UpdatedByUserLogin': u'PRASAD89', u'ListOfLa311SanitationBillingRssc': {}, u'SRHouseNumber': u'', u'ListOfLa311IllegalAutoRepair': {}, u'CreatedDate': u'12/31/2014 13:49:23', u'Owner': u'BSS', u'SRCrossStreet': u'', u'FirstName': u'Prasad', u'CreatedByUserLogin': u'PRASAD89', u'LastName': u'Pp', u'SRCouncilDistrictNo': u'1', u'ListOfLa311DocumentLog': {}, u'SRTBColumn': u'E', u'Status': u'Open', u'SRCommunityPoliceStationPREC': u'2', u'ListOfLa311IllegalConstruction': {}, u'ListOfLa311BarricadeRemoval': {}, u'ParentSRStatus': u'', u'NewContactEmail': u'', u'ListOfLa311SanitationBillingEcc': {}, u'ListOfLa311StreetTreeViolations': {}, u'Language': u'English', u'ListOfLa311DeadAnimalRemoval': {}, u'ListOfLa311PalmFrondsDown': {}, u'ListOfLa311IllegalExcavation': {}, u'ServiceDate': u'12/31/2014 00:00:00', u'LoginUser': u'', u'ParentSRNumber': u'', u'SRAreaPlanningCommission': u'Central APC', u'ListOfLa311IllegalDumpingPickup': {}, u'ListOfLa311SidewalkRepair': {}, u'LADWPAccountNo': u'', u'ListOfLa311BillingCsscAdjustment': {}, u'ListOfAuditTrailItem2': {}, u'ListOfLa311IllegalDischargeOfWater': {}, u'SRCommunityPoliceStationAPREC': u'RAMPART', u'ParentSRType': u'', u'Assignee': u'Siebel Administrator', u'ListOfLa311Containers': {}, u'ListOfLa311BeesOrBeehive': {}, u'ListOfLa311BulkyItem': {}, u'SRType': u'Homeless Encampment', u'SRStreetName': u'TEMPLE', u'ListOfLa311WeedAbatementForPrivateParcels': {}, u'ResolutionCode': u'', u'ListOfLa311GraffitiRemoval': {}, u'ListOfLa311Flooding': {}, u'ListOfLa311IllegalVending': {}, u'ListOfLa311TablesAndChairsObstructing': {}, u'ListOfLa311MoveInMoveOut': {}, u'ListOfLa311BillingEccAdjustment': {}, u'ListOfLa311OvergrownVegetationPlants': {}, u'NewContactFirstName': u'', u'ListOfLa311BrushItemsPickup': {}, u'IntegrationId': u'1420033765921', u'ReasonCode': u'', u'ListOfLa311CurbRepair': {}, u'ListOfLa311LeafBlowerViolation': {}, u'ListOfLa311MultipleStreetlightIssue': {}, u'ListOfLa311TreeObstruction': {}, u'ActionTaken': u'', u'ListOfLa311BillingRsscAdjustment': {}, u'ListOfLa311GisLayer': {u'La311GisLayer': [{u'DistrictOffice': u'North Central', u'Area': u'', u'Y_Call_No': u'', u'Fraction': u'', u'StreetLightId': u'', u'Type': u'GIS', u'DistrictAbbr': u'', u'R_Call_No': u'', u'CommunityPlanningArea': u'Westlake', u'LastUpdatedBy': u'', u'DistrictName': u'Central', u'BOSRadioHolderName': u'', u'A_Call_No': u'', u'Day': u'', u'DistrictNumber': u'104', u'Name': u'41572025-3803-49c4-8561-6e7ef41775df', u'StreetTo': u'FIRMIN ST', u'StreetLightStatus': u'', u'DirectionSuffix': u'', u'ShortDay': u'', u'SectionId': u'5279800', u'StreetFrom': u'BOYLSTON ST'}]}, u'ListOfLa311SrPhotoId': {u'La311SrPhotoId': []}, u'ListOfLa311LandMudSlide': {}, u'SRNeighborhoodCouncilId': u'44', u'ListOfLa311BillingRsscExemption': {}, u'SRTBRow': u'2', u'NewContactLastName': u'', u'NewContactPhone': u'', u'ListOfLa311GutterRepair': {}, u'HomePhone': u'3123123123'}]}})]
... View more
02-12-2015
02:47 PM
|
0
|
1
|
4205
|
|
POST
|
Hi Joshua, This implementation works wonders, however like you stated the NumPy documentation isn't all of that helpful. My question is will string data types ALWAYS be 12 bytes? This script is for a proof of concept, and another JSON web service will be used which I why I was using the requests module in the initial script, because I will have to execute a POST instead of GET request to the service. I appreciate your help.
... View more
02-08-2015
08:35 PM
|
0
|
1
|
1716
|
|
POST
|
I would like to write two headers, but am receving my actual two headers and 3 blank fields. What could be the cause of this? Here is my script and output. The script parses a JSON web-service and sends lat/lng of buses to a table in a file geodatabase. import requests
import json
import urllib2
import csv
import arcpy
if arcpy.Exists("C:\MYLATesting.gdb\API_Table"):
arcpy.Delete_management("C:\MYLATesting.gdb\API_Table")
url = "http://api.metro.net/agencies/lametro/vehicles/"
parsed_json = json.load(urllib2.urlopen("http://api.metro.net/agencies/lametro/vehicles/"))
details = {'items': 'longitude'}
headers = {'Content-type': 'application/x-www-form-urlencoded', 'Accept': '/'}
response = requests.get(url, data=json.dumps(details), headers=headers)
# tell computer where to put CSV
outfile_path='C:\Users\Administrator\Desktop\API_Testing.csv'
# open it up, the w means we will write to it
writer = csv.writer(open(outfile_path, 'wb'))
#create a list with headings for our columns
headers = ['latitude','longitude']
for items in parsed_json['items']:
row = []
row.append(str(items['latitude']).encode('utf-8'))
row.append(str(items['longitude']).encode('utf-8'))
writer.writerow(row)
i = 1
i = i +1
f = open(outfile_path, 'wb')
writer = csv.writer(f)
#write the row of headings to our CSV file
writer.writerow(headers)
f.close()
#Temporary Delete Function to Overwrite Table
arcpy.TableToTable_conversion(outfile_path, "C:\MYLATesting.gdb", "API_Table")
print response.text
... View more
02-06-2015
08:38 PM
|
0
|
10
|
5721
|
|
POST
|
I have a sample script that I am using as a proof of concept to loop through a JSON web-service and write the results to a CSV then table in file geodatabase. I am using my The ArcGIS Sample Server JSON web-service as an example. The problem is that my script does not write all records to the CSV, however in this case only the last record. http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer?f=json&pretty=true import requests
import json
import urllib2
import csv
import arcpy
url = "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer?f=json&pretty=true"
parsed_json = json.load(urllib2.urlopen("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer?f=json&pretty=true"))
details = {'layers': 'name'}
headers = {'Content-type': 'application/x-www-form-urlencoded', 'Accept': '/'}
response = requests.post(url, data=json.dumps(details), headers=headers)
# tell computer where to put CSV
outfile_path='C:\Users\Administrator\PycharmProjects\untitled\json2fgdb.csv'
# open it up, the w means we will write to it
writer = csv.writer(open(outfile_path, 'wb'))
#create a list with headings for our columns
headers = ['name', 'id']
#write the row of headings to our CSV file
writer.writerow(headers)
for services in parsed_json ["layers"]:
#initialize the row
row = []
#add every 'cell' to the row list, identifying the item just like an index in a list
row.append(str(services['id']).encode('utf-8'))
row.append(str(services['name']).encode('utf-8'))
#once you have all the cells in there, write the row to your csv
writer.writerow(row)
#increment our loop counter, now we're on the next time through the loop
i = 1
i = i +1
f = open(outfile_path, 'wb')
writer = csv.writer(f)
f.close()
#Temporary Delete Function to Overwrite Table
if arcpy.Exists("C:\dev_folder\orginalDev.gdb\jsoncsv7"):
arcpy.Delete_management("C:\dev_folder\orginalDev.gdb\jsoncsv7")
arcpy.TableToTable_conversion("C:\Users\Administrator\Desktop\json2gdb.csv", "C:\dev_folder\orginalDev.gdb", "jsoncsv7")
print response.text my output is: name,id 5,states I would like to write all layer IDs and Names, not just the last one.
... View more
02-05-2015
10:45 AM
|
0
|
2
|
4622
|
|
POST
|
I would like to add a simple if statement to an existing expression, but am having difficulties getting it to execute. My previous expression in vb script concatenates a number of fields to make one long string in a new field. I would like to add multiple if else statements to be a part of this expression. 'Trim([NUMBERCYLA]) & ",SB,"& Trim([RESOLUTION_CODE]) & ",,,SC Truck,"& Trim([last_edited_user])& ",Driver,"& Month( [last_edited_date])&"/"& Day([last_edited_date])&"/"& Year ( [last_edited_date]) & ","' I have a field SCCatDesc that contains the attributes MAT, MBE, MBI, MBW, SBE, and SBI. If SCCatDesc = MAT then output = SB If SCCatDesc = MBE then output = ME If SCCatDesc = MBI then output = MB If SCCatDesc = MBW then output = MW If SCCatDesc = SBE then output = SB If SCCatDesc = SBI then output = SBI I have tried the following as start however it does not work. If [SCCatDesc] = "MAT" Then Output = "SB" ElseIf [SCCatDesc] = "MBE" Then Output = "ME" Else Output = "TEST" End If import arcpy
#Define Local Parameters
whereclause = "PlannedDate = CONVERT(DATE, GETDATE())"
SDEFeatureClass = "C:\Users\Administrator\AppData\Roaming\ESRI\Desktop10.2\ArcCatalog\Connection to localhost_SCData_sa.sde\SCData.DBO.SO_SC"
LocalFGDB = "C:\PeterText.gdb"
Outable = "WLATable"
PeterTable = "C:\PeterText.gdb\WLATABLE"
expression = 'Trim([NUMBERCYLA]) & ",SB,"& Trim([RESOLUTION_CODE]) & ",,,SC Truck,"& Trim([last_edited_user])& ",Driver,"& Month( [last_edited_date])&"/"& Day([last_edited_date])&"/"& Year ( [last_edited_date]) & ","'
#Selection Query
selection = """CYLA_DISTRICT = 'WLA' AND PlannedDate = CONVERT(DATE, GETDATE())"""
#Deletes old FC
if arcpy.Exists(PeterTable):
arcpy.Delete_management(PeterTable)
#Sends Feature Class to Table with Where Clause
arcpy.TableToTable_conversion(SDEFeatureClass, LocalFGDB, Outable, selection)
#Calculates Field with expression for Peter Text File
arcpy.CalculateField_management(PeterTable, "PtrText", expression)
#Search Cursor to extract Peter Text Field
myOutputFile = open("C:\PeterScripts\WLA\Peter.txt", 'w')
rows = arcpy.da.SearchCursor("C:\PeterText.gdb\WLATable", ["PtrText"])
for row in rows:
myOutputFile.write(str(row[0]) + '\n')
del row, rows
myOutputFile.close()
... View more
02-03-2015
02:07 PM
|
0
|
2
|
5407
|
|
POST
|
This leads to another caveat, since this feature class is consumed by a feature service, it is locked and I receive this error. EDIT: if I use arcpy.disconnectusers it stops my feature classes. Traceback (most recent call last): File "C:/PeterScripts/Harbor.py", line 56, in <module> arcpy.DisableEditorTracking_management(SDEFeatureClass) File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\management.py", line 3529, in DisableEditorTracking raise e arcgisscripting.ExecuteError: ERROR 000464: Cannot get exclusive schema lock. Either being edited or in use by another application. Failed to execute (DisableEditorTracking).
... View more
02-03-2015
09:21 AM
|
0
|
1
|
963
|
| 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
|