Select to view content in your preferred language

Collect an offset point need to determine altitude from nearest Tracker point

1511
4
Jump to solution
03-17-2021 05:06 PM
kmsmikrud
Frequent Contributor

Hi,

We are using Field Maps for aerial surveys and the altitude value of the points collected is very important in survey estimates. We understand that points collected directly at your location are attributed with the GPS metadata, but if the points are offset no metadata is included.

As a post-survey work around I need to determine the altitude from the nearest tracker points for all offset points. We have been trying to use the arcgis API for Python to go through each point in the survey point feature layer,  find the nearest track point and altitude value, then update the survey point altitude with the nearest track point altitude value.

Similar to this post,  we are getting the Exception: Invalid format of input layer. Below is an example of the code we have tried. According to the api-reference,  the input types should accept simple point coordinates and the lat., long. pair should be fine, but this does not work. Is there a way to get the input to accept a feature or a feature converted to a point geometry object?

Can someone please assist!

 

tracks_lyr = FeatureLayer(tracks_svc)
i = 0
for key, value in calc_dict.items():
    while i in range(len(calc_dict.items())):
        print(i)
        for point in key:
            oid = point.attributes['OBJECTID']
            print(oid)
            x = point.geometry["x"]
            y = point.geometry["y"]
            pt_coord = (x,y)
            tracks_nearby = find_nearest(analysis_layer = pt_coord, near_layer=tracks_lyr, measurement_type="StraightLine", max_count =3)
            print(tracks_nearby)
            try:
                for r in cur:
                    with arcpy.da.UpdateCursor(herring_svc, ["ESRIGNSS_ALTITUDE"]) as cur:
                        if r[0] == 1500:
                            print(r[0])
                            cur.updateRow(r)
                        else:
                            print("pt has altitude value of " + str(r[0]))
            except Exception as e:
                        #arcpy.AddMessage("Error updating point: " + str(e))
                        print("Error updating point: " + str(e))  

 

Thanks in advance!

Kathy

 

0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable

I can't get the same error you see but I think the root issue is that the find_nearest tool is part of the standard analysis tools in ArcGIS Online. The location tracking feature service in ArcGIS Online does not support those analysis tools.

I was able to use this code to run the analysis tool on a different point layer it worked successfully, but using the tracks layer it failed.

from arcgis.gis import GIS
from arcgis.features.analysis import find_nearest

gis = GIS("https://<my-org>.maps.arcgis.com", "username", "password")
tracks_lyr = gis.content.get("<item-id>").layers[0]
coordinate = (0, 0)
tracks_nearby = find_nearest(analysis_layer=coordinate, near_layer=tracks_lyr, measurement_type="StraightLine", max_count=3)
print(tracks_nearby)

That said you should still be able to accomplish your workflow by issuing a spatial query against the tracks layer. You could buffer the collected point by 10 meters and then query the tracks layer to find track within that buffer, then sort by distance from the collected point to get the closest one and use the captured altitude value from it.

We have an example script that does a similar workflow to check if a worker was close the feature they collected. This line shows how to create the geometry filter and execute the query. This line shows how to buffer the collected point using the geometry service. Here is the documentation for the geometry filters  and buffering. Hope that helps.

View solution in original post

0 Kudos
4 Replies
by Anonymous User
Not applicable

Hi @kmsmikrud I can look into this for you. Can you check which version of the ArcGIS API for Python you are using? You can use this snippet to check:

import arcgis
print(arcgis.__version__)

 

0 Kudos
kmsmikrud
Frequent Contributor

Thank-you @Anonymous User !

It looks like 1.8.3 is the ArcGIS API for Python version I'm using after using your code above. I really appreciate you taking the time to look into this. Thank-you!

0 Kudos
by Anonymous User
Not applicable

I can't get the same error you see but I think the root issue is that the find_nearest tool is part of the standard analysis tools in ArcGIS Online. The location tracking feature service in ArcGIS Online does not support those analysis tools.

I was able to use this code to run the analysis tool on a different point layer it worked successfully, but using the tracks layer it failed.

from arcgis.gis import GIS
from arcgis.features.analysis import find_nearest

gis = GIS("https://<my-org>.maps.arcgis.com", "username", "password")
tracks_lyr = gis.content.get("<item-id>").layers[0]
coordinate = (0, 0)
tracks_nearby = find_nearest(analysis_layer=coordinate, near_layer=tracks_lyr, measurement_type="StraightLine", max_count=3)
print(tracks_nearby)

That said you should still be able to accomplish your workflow by issuing a spatial query against the tracks layer. You could buffer the collected point by 10 meters and then query the tracks layer to find track within that buffer, then sort by distance from the collected point to get the closest one and use the captured altitude value from it.

We have an example script that does a similar workflow to check if a worker was close the feature they collected. This line shows how to create the geometry filter and execute the query. This line shows how to buffer the collected point using the geometry service. Here is the documentation for the geometry filters  and buffering. Hope that helps.

0 Kudos
kmsmikrud
Frequent Contributor

Hi Aaron,

Thanks for helping to troubleshoot the issue with the API and the tracks layer. I will try the alternative workflow you suggested above. It is frustrating the tracks are so restricted on so many fronts.

Internally we are trying to transition ArcPad projects that folks have been using for aerial surveys for a number of years. These projects use an external GPS with the ArcPad project and all the points collected in the project get attributed with the device altitude whether they are offset or directly under their location. The project was customized and also provides survey estimates even (offline calculations) so when they land they have already previewed their biomass estimates.

Now 15 years later we are having a really hard time getting the same functionality. While I know the ArcPad project wasn't a simple application to set up, it was still possible. Now I have to tell these same folks that they now need to pay for the tracker extension, which isn't a large cost, but still. In addition they need to wait to return to the office to then run some post-processing scripts. The folks are excited to upgrade their hardware from the laptops and small pop-up boxes in ArcPad to the new Field Maps, but at the same time they are taking a loss on their functionality in much older software.

That's my two cents, its a frustrating journey.

Kathy

0 Kudos