esri / survey123-tools Goto Github PK
View Code? Open in Web Editor NEWTools for ArcGIS Survey123
License: Apache License 2.0
Tools for ArcGIS Survey123
License: Apache License 2.0
I'm seeing the error below when trying to clone a Form item, the other item types seem to clone without issue
cloned_form= target.content.clone_items(items=form])
`---------------------------------------------------------------------------
ParseError Traceback (most recent call last)
/opt/conda/lib/python3.7/site-packages/arcgis/_impl/common/_clone.py in update_form(self, target, new_item, clone_mapping)
5027 payload["form"] = self._replace_form(
-> 5028 form, field_mapping
5029 )
/opt/conda/lib/python3.7/site-packages/arcgis/_impl/common/_clone.py in _replace_form(self, xml_string, lookup)
4819 def _replace_form(self, xml_string: str, lookup: dict) -> str:
-> 4820 xml = ElementTree.fromstring(xml_string)
4821
/opt/conda/lib/python3.7/xml/etree/ElementTree.py in XML(text, parser)
1314 parser = XMLParser(target=TreeBuilder())
-> 1315 parser.feed(text)
1316 return parser.close()
ParseError: mismatched tag: line 5, column 434
During handling of the above exception, another exception occurred:
Exception Traceback (most recent call last)
/opt/conda/lib/python3.7/site-packages/arcgis/_impl/common/_clone.py in clone(self)
4894 original_item = self.info
-> 4895 self.update_form(self.target, new_item, self._clone_mapping)
4896 _share_item_with_groups(
/opt/conda/lib/python3.7/site-packages/arcgis/_impl/common/_clone.py in update_form(self, target, new_item, clone_mapping)
5132 "Failed to update {0} {1}: {2}".format(
-> 5133 new_item["type"], new_item["title"], str(ex)
5134 )
Exception: Failed to update Form Peel Ports Decimal Issue: mismatched tag: line 5, column 434
During handling of the above exception, another exception occurred:
_ItemCreateException Traceback (most recent call last)
/tmp/ipykernel_124/4002343211.py in
----> 1 cloned_flyr = target.content.clone_items(items=[hosted_fl])
/opt/conda/lib/python3.7/site-packages/arcgis/gis/init.py in clone_items(self, items, folder, item_extent, use_org_basemap, copy_data, copy_global_ids, search_existing_items, item_mapping, group_mapping, owner, preserve_item_id)
6730 preserve_item_id=preserve_item_id,
6731 )
-> 6732 return deep_cloner.clone()
6733
6734 def bulk_update(self, itemids, properties):
/opt/conda/lib/python3.7/site-packages/arcgis/_impl/common/_clone.py in clone(self)
1156
1157 with concurrent.futures.ThreadPoolExecutor(max_workers=20) as executor:
-> 1158 results = executor.submit(self._clone, executor).result()
1159 return results
1160
/opt/conda/lib/python3.7/concurrent/futures/_base.py in result(self, timeout)
433 raise CancelledError()
434 elif self._state == FINISHED:
--> 435 return self.__get_result()
436 else:
437 raise TimeoutError()
/opt/conda/lib/python3.7/concurrent/futures/_base.py in __get_result(self)
382 def __get_result(self):
383 if self._exception:
--> 384 raise self._exception
385 else:
386 return self._result
/opt/conda/lib/python3.7/concurrent/futures/thread.py in run(self)
55
56 try:
---> 57 result = self.fn(*self.args, **self.kwargs)
58 except BaseException as exc:
59 self.future.set_exception(exc)
/opt/conda/lib/python3.7/site-packages/arcgis/_impl/common/_clone.py in _clone(self, excecutor)
1129 if item:
1130 item.delete()
-> 1131 raise ex
1132
1133 level += 1
/opt/conda/lib/python3.7/concurrent/futures/thread.py in run(self)
55
56 try:
---> 57 result = self.fn(*self.args, **self.kwargs)
58 except BaseException as exc:
59 self.future.set_exception(exc)
/opt/conda/lib/python3.7/site-packages/arcgis/_impl/common/_clone.py in clone(self)
4906 original_item["type"], original_item["title"], str(ex)
4907 ),
-> 4908 new_item,
4909 )
4910
_ItemCreateException: ('Failed to create Form Peel Ports Decimal Issue: Failed to update Form Peel Ports Decimal Issue: mismatched tag: line 5, column 434', <Item title:"Peel Ports Decimal Issue" type:Form owner:[email protected]>)
โ`
In the final function, line 47, " os.rmdir(feature_layer_folder)" needs to be inside the if statement or it throws an error concerning an unestablished variable.
I'm attempting to follow along with the example at https://github.com/Esri/Survey123-tools/blob/main/Work_with_Survey_Data/work_with_survey_data.ipynb
I'm using arcgis 1.9.1 with Python 3.7
Everything works except the Pandas Dataframe:
import pandas as pd
survey_df = survey_by_id.download('DF')
survey_df.head()
I get the following traceback:
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
/var/folders/dd/rxwr7nfj6dl_kb09w6kvmz380000gn/T/ipykernel_83201/656517875.py in <module>
1 import pandas as pd
----> 2 survey_df = survey_by_id.download('DF')
3 survey_df.head()
~/miniconda3/envs/gis-env/lib/python3.7/site-packages/arcgis/apps/survey123/_survey.py in download(self, export_format, save_folder)
201 title = "a%s" % uuid.uuid4().hex
202 if export_format.lower() == "df":
--> 203 return self._ssi.layers[0].query().sdf
204 if save_folder is None:
205 save_folder = tempfile.gettempdir()
~/miniconda3/envs/gis-env/lib/python3.7/site-packages/arcgis/features/layer.py in query(self, where, out_fields, time_filter, geometry_filter, return_geometry, return_count_only, return_ids_only, return_distinct_values, return_extent_only, group_by_fields_for_statistics, statistic_filter, result_offset, result_record_count, object_ids, distance, units, max_allowable_offset, out_sr, geometry_precision, gdb_version, order_by_fields, out_statistics, return_z, return_m, multipatch_option, quantization_parameters, return_centroid, return_all_records, result_type, historic_moment, sql_format, return_true_curves, return_exceeded_limit_features, as_df, datum_transformation, **kwargs)
1731 if "objectIdField" in self.properties:
1732 params["where"] = f"{self.properties.objectIdField} > 0"
-> 1733 record_count = self._query(url, params, raw=as_raw)
1734 params["where"] = "1=1"
1735 else:
~/miniconda3/envs/gis-env/lib/python3.7/site-packages/arcgis/features/layer.py in _query(self, url, params, raw, **kwargs)
3032
3033 else:
-> 3034 raise queryException
3035
3036 def is_true(x):
~/miniconda3/envs/gis-env/lib/python3.7/site-packages/arcgis/features/layer.py in _query(self, url, params, raw, **kwargs)
2987 result = self._con.post(
2988 path=url,
-> 2989 postdata=params,
2990 )
2991 except Exception as queryException:
~/miniconda3/envs/gis-env/lib/python3.7/site-packages/arcgis/gis/_impl/_con/_connection.py in post(self, path, params, files, **kwargs)
1077 file_name=file_name,
1078 try_json=try_json,
-> 1079 force_bytes=kwargs.pop("force_bytes", False),
1080 )
1081
~/miniconda3/envs/gis-env/lib/python3.7/site-packages/arcgis/gis/_impl/_con/_connection.py in _handle_response(self, resp, file_name, out_path, try_json, force_bytes, ignore_error_key)
623 return data
624 errorcode = data["error"]["code"] if "code" in data["error"] else 0
--> 625 self._handle_json_error(data["error"], errorcode)
626 return data
627 else:
~/miniconda3/envs/gis-env/lib/python3.7/site-packages/arcgis/gis/_impl/_con/_connection.py in _handle_json_error(self, error, errorcode)
646
647 errormessage = errormessage + "\n(Error Code: " + str(errorcode) + ")"
--> 648 raise Exception(errormessage)
649
650 def post_multipart(self, path, params=None, files=None, **kwargs):
Exception:
This operation is not supported.
(Error Code: 400)
@Zachary-Sutherby I'm attempting to use a combo of the "Work with survey data" and "Export survey data" to access, filter, join (using pandas merge) child records to parent records and then export data from Survey123.
My survey has a repeat. I'm unclear how to get at the related records from repeat.
When I view the pandas df tail in JN, I see only the records from the "parent" portion of the form. Can you help me understand how I can get the related records as well? Thanks.
Is cloning surveys from on-prem portal to Arcgis.com supported?
I can successfully clone the survey folder and all items from portal - arcgis.com, but survey123 does not recognize the survey. Survey123 errors with 'The survey does not exist or is not accessible.'
ive tried to generate a report which works but when i try to specify the report_title the generated report isnt named the same as specified:
import datetime from datetime import date, timedelta nowstring = datetime.datetime.now().strftime("%Y%m%d%H%M%S") report = survey_by_id.generate_report(templates[6], where="objectid=10471", report_title="SUR_{0}".format(nowstring), folder_id=folder_ID) print(report)
returns
<Item title:"Survey_V3_report_9c629a"
thank you very much for this useful tool.
I am conducting a PPGIS survey where subjects are asked to take pictures. However, taking the pictures is not mandatory. How can I change loop that the number of the question is also in the table, so that I can assign the pictures to the questions?
Thank you very much!
I cannot find any module that could publish a survey using excel template. I want to use a standard excel template to publish a survey123 form with a feature layer and web map.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.