POST
|
Thanks for the response! I wasn't very clear on our usage specifically, my fault. We used to have all of our AGS published data in webmercator Aux Sphere and so anything programmatically we would run geometries thru projection to our local planar system (WKID 2881) -- ultimately using the calculation for sqFt in the document I originally referenced. that was all fine! I was just curious if there's any updated calculation method as I am currently rebuilding many of our Geoprocessing tools and services for our updated Enterprise/Pro environments. I like having specific ESRI reference to point to, especially as it relates to calculating acreage!
... View more
07-10-2023
01:25 PM
|
1
|
0
|
816
|
POST
|
We have long used THIS recommended conversion calculation to determine acreage within our python implementations when working with SHAPE@AREA for any geometries in webmercator/sq meters or stateplane/sq feet. Is there any updated documentation or ESRI recommendations? It can be a touchy subject and since the above resource is quite old for previous versions of Desktop, I'm just looking to keep current as we migrate to python 3.x and/or the Python API. Thanks!
... View more
07-10-2023
06:40 AM
|
0
|
3
|
848
|
POST
|
Ok looks like the geometries input parameter is not expecting loaded json objects. The solution is to pass in the json.dumps() of the geometries: paramsBuff = {'f': 'json',
'geometries': json.dumps(geomInput),
'inSR': 2881,
'outSR': 2881,
'bufferSR': 2881,
'distances': 250,
'unit': 9003,
'unionResults': 'true',
'geodesic': 'false',
'token': tok
}
... View more
06-19-2023
08:50 AM
|
0
|
0
|
775
|
POST
|
Having some difficulty with a post request to our ArcGIS Server buffer utility endpoint and coming up with this response when executing in python requests, but running the same exact input parameters on the Utilities/Geometry/GeometryServer/buffer REST page it works. Error message: {'error': {'code': 400, 'extendedCode': -2147024809, 'message': 'Invalid or missing input parameters.', 'details': []}} Python script / code: #create 250ft buffer for ROW canal selections
geomInput = {"geometryType": "esriGeometryPolygon", "geometries": [{"rings": ringFeat['rings']}]}
print (geomInput)
queryURL_buff = 'https://somedomain.com/servername/rest/services/Utilities/Geometry/GeometryServer/buffer'
paramsBuff = {'f': 'json',
'geometries': geomInput,
'inSR': 2881,
'outSR': 2881,
'bufferSR': 2881,
'distances': 250,
'unit': 9003,
'unionResults': 'true',
'geodesic': 'false',
'token': tok
}
reqBuff = requests.post(queryURL_buff, data = paramsBuff, verify=False)
responseBuff = json.loads(reqBuff.content) Here's the input Geometries parameter "geomInput", that comes from an initial request to a service layer on published on the same ArcGIS Server site, SR 2881: {'geometryType': 'esriGeometryPolygon', 'geometries': [{'rings': [[[495575.2709925808, 885508.40553274], [495550.90457149595, 882849.2146569043], [494801.263026163, 882859.831105493], [494741.2670831606, 882860.6811694056], [494559.8045195788, 882863.2520304099], [494349.84627807885, 882866.2267619893], [494140.0382987447, 882869.1978846565], [493930.3799254112, 882872.1686792374], [493720.87575124577, 882875.1355368197], [493511.52183924615, 882878.1017382368], [493302.3175332472, 882881.0643307418], [493082.0259790793, 882884.1853874922], [492918.59684399515, 882886.4980469048], [492922.98856749386, 883580.9809099063], [492889.98830541223, 883581.418573074], [492893.9925624952, 884214.7765583247], [492860.99295657873, 884215.2056913227], [492810.41759841144, 884215.8598894924], [492562.22616566345, 884219.0767465755], [492395.6389004141, 884221.2348787412], [492229.02637274563, 884223.3933389932], [491895.8219866641, 884227.7141964883], [491562.6179286614, 884232.0347259045], [491229.4181357473, 884236.3516464084], [491022.93068782985, 884239.0265098214], [490563.0139567442, 884244.9890963212], [490228.3850328289, 884249.3266860768], [489896.68097182736, 884253.6265462413], [489730.08091132715, 884255.7850064933], [489563.4769138284, 884257.9474037364], [489568.5769692473, 884889.7184499055], [489574.1684934944, 885582.6845836565], [492902.3800129108, 885541.4887999073], [495575.2709925808, 885508.40553274]]]}]}
... View more
06-19-2023
05:56 AM
|
0
|
1
|
789
|
POST
|
Ok it looks like a simple misunderstanding... I think the data= property on .update is simply the full path/filename, not the ZipFile object. extractFolder = r'\\Scripts\Survey123\mmpkUpdate\downloaded'
zip_path = os.path.join(extractFolder,'{}.zip'.format('FS_From_Connect'))
data_item.update(item_properties=props, data=zip_path)
... View more
06-01-2023
12:55 PM
|
0
|
0
|
561
|
POST
|
Attempting to convert older python 2.7 script with Python API that overwrites and existing "Form" item on our org AGO. Context: a survey123 form item is downloaded, unzipped, media folder updated with new mmpk, re-zipped and then POST request was made to the same AGO item. This worked just fine for py 2.7 but I've had to rewrite for the Pyhon API and running into this issue. When i review the contents of the zip it appears everything is correct but the last step fails to upload/overwrite with: AttributeError: 'ZipFile' object has no attribute 'decode' def updateZip(mmpk_file):
mediaFolder = Path('./downloaded/esriinfo/media')
targetFile = os.path.join(mediaFolder, 'quickMMPK.mmpk')
#copy mmpk into medial folder
shutil.copy(mmpk_file, targetFile)
# compress the contents of esriinfo into a new zip file
extractFolder = Path('./downloaded')
esriInfoFolder = Path('./downloaded/esriinfo')
outputFileName = extractFolder.joinpath('esriinfo')
zip_path = extractFolder.joinpath('{}.zip'.format('FS_From_Connect'))
#zip_file = zip_path #ZipFile(zip_path)
zf = ZipFile(zip_path, "w")
os.chdir(extractFolder)
for dirname, subdirs, files in os.walk('esriinfo'):
for filename in files:
zf.write(os.path.join(dirname, filename))
zf.close()
# `ContentManager.get` will return `None` if there is no Item with ID `0ccabee15e76442483d50d82ae0c4053`
data_item = gis.content.get(surveyFormItem)
props = {
"type":"form",
"title":data_item.title,
"overwrite":True
}
data_item.update(item_properties=props, data=zf) #AttributeError: 'ZipFile' object has no attribute 'decode'
... View more
06-01-2023
11:26 AM
|
0
|
1
|
588
|
POST
|
David! Great to hear from you again... I will take a look (or have the admin check it). Thanks!
... View more
05-19-2023
08:38 AM
|
1
|
0
|
600
|
POST
|
As the title suggests, I had successfully published a new Web Tool (Geoprocessing Service) to a Federated ArcGIS Server Site. It created the item in the portal just fine too, however I saw a problem with it and decided to remove it and start over. The issue: I used ArcGIS Server Manager to stop and delete the service rather than deleting the associated item on portal. It seemed to be ok and deleted the portal item and of course it no longer exits on the AGS site or anywhere. Now when I go to publish the Web Tool I get an error message in Pro stating it cannot publish because the item exists. Any help on how to troubleshoot is appreciated.
... View more
05-19-2023
07:48 AM
|
0
|
3
|
627
|
POST
|
Resolved. Simply removing the Folder_ID parameter from the generate_report() method automatically writes the output to the local directory C:\Users\[username]\AppData\Local\Temp\5 From there I can simply use shutil.copyfile() to put it into a desired directory. save_pdf=r'H:\AGOL\bga\bgaReportCopy.pdf'
pdf_report = survey_by_id.generate_report(templates[0], where=whereClause, utc_offset=offset, output_format="pdf", report_title=reportName, merge_files="nextPage")
shutil.copyfile(pdf_report,save_pdf)
... View more
04-26-2023
11:00 AM
|
1
|
0
|
617
|
POST
|
Edit: removing the Folder_ID= parameter automatically puts the output into C:\Users\[UserName]\AppData\Local\Temp\5 Is there any way to specify this directory instead? Perhaps overcomplicating this --- for the AGO NB it needed to create content in a specific AGO folder for a specific user/account. However, I'm starting to better understand the differences running locally and perhaps there's no need to deal with created the report output and saving to a folderId. From https://developers.arcgis.com/python/api-reference/arcgis.apps.survey123.html it mentions, To save to disk, do not specify a folder_id So, removing the folder_id parameter in that generate_report() method it actually worked! However, I'm unsure where it saved the output pdf to? Also, I attempted to add a save_folder parameter but it doesn't recognize that as a valid input.
... View more
04-26-2023
10:23 AM
|
0
|
0
|
619
|
POST
|
ArcPro 2.9.7 Conda 3.7 Error: "Exception: upload destination is invalid. CONT_0004: User folder does not exist." I have a hosted AGO Notebook that works as expected and now I'm attempting to bring this down and re-write locally as a standalone .py script. The local .py script works but fails on this line, pdf_report = survey_by_id.generate_report(templates[0], where=whereClause, utc_offset=offset, output_format="pdf", report_title=reportName, merge_files="nextPage", folder_id='e1d58030cf4a40a989beffc9349fa501') I'm getting the AGO folder id by simply navigating to it and copying the &folder= parameter value from the url (so I know it's correct and it also works in the NB when running on AGOL). Reason for bringing down local is over the life of the existing NB that runs daily on AGOL, we've seen some hiccups of that implementation -- sometimes it may have been a task scheduler thing or the NB would execute without errors/issues but would not generate the pdf output for some reason or another (but on subsequent manual attempts it would work just fine). The majority of the time it runs without issue but there's no real good way to monitor things and handle problems when they occur -- when you have a high visibility output that the NB generates then this is a problem because it requires constant babysitting. We have a ton of experience with py 2.7 scripts running on a windows server vm that get run via the task scheduler and having them run locally there's simply more options available to handle execution failures in more hands-off approach.
... View more
04-26-2023
08:44 AM
|
0
|
2
|
683
|
POST
|
The applyEdits wants the updates parameter array to be in quotes. From: updates.append(dict)
params = {'f': 'json','updates': updates,'token': tok} To: updates.append(dict)
params = {'f': 'json','updates': '{}'.format(updates),'token': tok}
... View more
04-13-2023
09:55 AM
|
0
|
0
|
858
|
POST
|
Enterprise 10.9.1 (build 28388) Federated to Portal When publishing GP services to a federate Enterprise server site an item is created in portal and the share properties of that item dictate accessibility of that GP service. For example, when making a request to the service's /execute task it requires a token parameter to be included. This is fine and all but we want this GP service to be accessible with no authentication required, which if we set the share property to Public it works. However, we don't want this to be a discoverable item in Portal! This is mostly used by other systems and programmatic processes but we still don't want the item itself to be seen, just the url/endpoint should be accessed. Any solutions? Is there a way to set the share property to a restricted group but embed credentials into the item? Thanks!
... View more
04-12-2023
06:10 AM
|
1
|
0
|
401
|
POST
|
Thanks for taking a look! def getGeometry(oid, url):
params = {'f': 'json',
'objectIds': oid,
'outFields': '*',
'returnGeometry': 'true',
'token': tok}
r = requests.post("{}/query".format(url), data = params, verify=False)
response = json.loads(r.content)
if r.status_code==200:
appCount = (response['features'])
if len(appCount) > 0:
return response
else:
return 0
else:
return 0
def update_egisScratch(oid):
try:
updates = []
dict = {'attributes' : {
'OBJECTID' : oid,
'REVIEW_STATUS' : inputStatus,
'PERMIT_ID': inputPermitId,
'PERMIT_TYPE': inputPermitType,
'PERMIT_SUBTYPE': inputPermitSubType,
'PROJECT_NAME': inputProjectName,
'APP_NO': inputAppId,
'PERMIT_NO': inputPermitId,
'APP_ID': inputAppId}
}
jsonResult = getGeometry(oid, queryURL_egisSCRATCH)
#get the geometry from the getGeometry() function for our new payload
geom = jsonResult['features'][0]['geometry']
dict.update({'geometry': geom})
if not jsonResult == 0:
updates.append(dict)
params = {'f': 'json',
'updates': updates,
'token': tok}
url = "{}/applyEdits".format(queryURL_egisSCRATCH)
print (params)
r = requests.post(url, data=params, verify=False)
response = json.loads(r.content)
print (response)
... View more
04-11-2023
03:36 PM
|
0
|
1
|
879
|
POST
|
Enterprise v10.9.1 (federated) ArcPro 2.9.7 Python 3.x For some reason when submitting requests to a feature service's applyEdits task, it doesn't like the updates payload when executed from a .py script source. However, if I print that payload and copy./paste it into the feature service's REST endpoint interface it successfully applies the update. Sample: {'f': 'json', 'updates': [{'attributes': {'OBJECTID': 493680, 'REVIEW_STATUS': 'REVIEW', 'PERMIT_ID': '', 'PERMIT_TYPE': 'ERP', 'PERMIT_SUBTYPE': 'IND', 'PROJECT_NAME': 'GROVE LAND', 'APP_NO': '509-107', 'PERMIT_NO': '', 'geometry': {'rings': [[[850428.7066254951, 1107318.8247719035], [851334.0043555796, 1107319.7210955694], [851357.1526032463, 1106852.254182741], [850441.3657209128, 1106858.234485738], [850428.7066254951, 1107318.8247719035]]]}}], 'token': 'validTokenAppendedHere'} Again, copying pasting the above into the REST endpoint updates parameter input works. However, when executed from the python script it fails with error message: {'error': {'code': 500, 'message': 'Unable to complete operation.', 'details': ["No edits ('adds', 'updates', 'deletes', or 'attachment edits') were specified."]}}
... View more
04-11-2023
01:38 PM
|
0
|
3
|
898
|
Title | Kudos | Posted |
---|---|---|
1 | 08-08-2022 01:40 PM | |
1 | 02-15-2019 08:21 AM | |
2 | 08-14-2023 07:14 AM | |
1 | 07-10-2023 01:25 PM | |
1 | 05-19-2023 08:38 AM |
Online Status |
Offline
|
Date Last Visited |
a week ago
|