Select to view content in your preferred language

Elevation Profile Does Not Return Z or M Values

1000
3
Jump to solution
12-15-2021 02:32 PM
Moe-Notos
Occasional Contributor

I am attempting to retrieve an elevation profile for a local feature through the Python API.


While the job executes successfully, the output does not contain any Z or M values (see below).
I have explored several approaches, such as loading in the toolbox manually, as well as attempting to find some place to specify returnZ = True.

Please advise how Z and M values could be retrieved.

Thanks in advance!

 

Code:

from arcgis.features.elevation import profile
from arcgis.features.feature import Feature, FeatureSet
from arcgis.geometry import Polyline

input_polyline = Polyline({
	"paths": [[[-73.609551, 45.490678], [-73.584162, 45.513645]]],
	"spatialReference": {
		"wkid": 4326
	}
})

input_feature_set = FeatureSet(
	features=[Feature(geometry=input_polyline)])

pf = profile(input_line_features=input_feature_set,
			 dem_resolution='FINEST',
			 maximum_sample_distance_units='Meters')

print(pf)

 

Output:

{
    "displayFieldName": "",
    "features": [
        {
            "attributes": {
                "DEMResolution": "10m",
                "OBJECTID": 1,
                "ProductName": "NED_1r3_arcsec",
                "ProfileLength": 3233.121443184,
                "Shape_Length": 0.034235718815843016,
                "Source": "USGS",
                "Source_URL": "http://ned.usgs.gov"
            },
            "geometry": {
                "paths": [
                    [
                        [
                            -73.60955099984307,
                            45.49067799983942
                        ],
                        [
                            -73.60903285711129,
                            45.49114671393437
                        ],
                        [
                            -73.60851471437951,
                            45.49161542802932
                        ],
                        [
                            -73.60799657164767,
                            45.49208414302365
                        ],
                        [
                            -73.60747842801658,
                            45.492552857118596
                        ],
                        [
                            -73.6069602852848,
                            45.493021571213546
                        ],
                        [
                            -73.60644214255302,
                            45.493490285308496
                        ],
                        [
                            -73.60592399982119,
                            45.493959000302766
                        ],
                        [
                            -73.60540585708941,
                            45.49442771439777
                        ],
                        [
                            -73.60488771435763,
                            45.49489642849272
                        ],
                        [
                            -73.60436957162585,
                            45.49536514258767
                        ],
                        [
                            -73.6038514279947,
                            45.49583385668262
                        ],
                        [
                            -73.60333328526292,
                            45.49630257167689
                        ],
                        [
                            -73.60281514253114,
                            45.4967712857719
                        ],
                        [
                            -73.60229699979931,
                            45.49723999986685
                        ],
                        [
                            -73.60177885706753,
                            45.4977087139618
                        ],
                        [
                            -73.60126071433575,
                            45.49817742895607
                        ],
                        [
                            -73.60074257160397,
                            45.49864614305102
                        ],
                        [
                            -73.60022442797282,
                            45.499114857146026
                        ],
                        [
                            -73.59970628524104,
                            45.499583571240976
                        ],
                        [
                            -73.59918814250926,
                            45.500052285335926
                        ],
                        [
                            -73.59866999977748,
                            45.500521000330195
                        ],
                        [
                            -73.59815185704565,
                            45.500989714425145
                        ],
                        [
                            -73.59763371431387,
                            45.50145842852015
                        ],
                        [
                            -73.5971155715821,
                            45.5019271426151
                        ],
                        [
                            -73.59659742795094,
                            45.50239585760937
                        ],
                        [
                            -73.59607928521916,
                            45.50286457170432
                        ],
                        [
                            -73.59556114248738,
                            45.50333328579933
                        ],
                        [
                            -73.5950429997556,
                            45.50380199989428
                        ],
                        [
                            -73.59452485702377,
                            45.50427071488855
                        ],
                        [
                            -73.594006714292,
                            45.5047394289835
                        ],
                        [
                            -73.59348857156021,
                            45.50520814307845
                        ],
                        [
                            -73.59297042792912,
                            45.505676857173455
                        ],
                        [
                            -73.59245228519728,
                            45.506145571268405
                        ],
                        [
                            -73.5919341424655,
                            45.506614286262675
                        ],
                        [
                            -73.59141599973373,
                            45.507083000357625
                        ],
                        [
                            -73.59089785700195,
                            45.507551714452575
                        ],
                        [
                            -73.59037971427011,
                            45.50802042854758
                        ],
                        [
                            -73.58986157153834,
                            45.50848914354185
                        ],
                        [
                            -73.58934342790724,
                            45.5089578576368
                        ],
                        [
                            -73.5888252851754,
                            45.50942657173175
                        ],
                        [
                            -73.58830714244363,
                            45.5098952858267
                        ],
                        [
                            -73.58778899971185,
                            45.51036399992171
                        ],
                        [
                            -73.58727085698007,
                            45.51083271491598
                        ],
                        [
                            -73.58675271424823,
                            45.51130142901093
                        ],
                        [
                            -73.58623457151646,
                            45.51177014310588
                        ],
                        [
                            -73.58571642788536,
                            45.51223885720083
                        ],
                        [
                            -73.58519828515358,
                            45.512707572195154
                        ],
                        [
                            -73.58468014242175,
                            45.513176286290104
                        ],
                        [
                            -73.58416199968997,
                            45.513645000385054
                        ]
                    ]
                ],
                "spatialReference": {
                    "latestWkid": 4326,
                    "wkid": 4326
                }
            }
        }
    ],
    "fields": [
        {
            "alias": "OBJECTID",
            "name": "OBJECTID",
            "type": "esriFieldTypeOID"
        },
        {
            "alias": "DEM Resolution",
            "length": 50,
            "name": "DEMResolution",
            "type": "esriFieldTypeString"
        },
        {
            "alias": "Product Name",
            "length": 50,
            "name": "ProductName",
            "type": "esriFieldTypeString"
        },
        {
            "alias": "Source",
            "length": 50,
            "name": "Source",
            "type": "esriFieldTypeString"
        },
        {
            "alias": "Source URL",
            "length": 84,
            "name": "Source_URL",
            "type": "esriFieldTypeString"
        },
        {
            "alias": "Length Meters",
            "name": "ProfileLength",
            "type": "esriFieldTypeDouble"
        },
        {
            "alias": "Shape_Length",
            "name": "Shape_Length",
            "type": "esriFieldTypeDouble"
        }
    ],
    "geometryType": "esriGeometryPolyline",
    "objectIdFieldName": "OBJECTID",
    "spatialReference": {
        "latestWkid": 4326,
        "wkid": 4326
    }
}
0 Kudos
1 Solution

Accepted Solutions
Moe-Notos
Occasional Contributor

I was able to retrieve the Z and M values using the following code:

input_polyline = Polyline({
	"paths": [[[-73.609551, 45.490678, 0, 0],
			   [-73.584162, 45.513645, 0, 0]]],
	"spatialReference": {
		"wkid": 4326
	}
})

input_feature_set = FeatureSet(
	features=[Feature(geometry=input_polyline)])

arcgis.env.return_z = True
arcgis.env.return_m = True

pf = profile(input_line_features=input_feature_set,
			 dem_resolution='FINEST')

print(pf)

 

Two steps were required:

1) The following lines had to be added, which set the environment variables for arcgis:

import arcgis
arcgis.env.return_z = True
arcgis.env.return_m = True

 

2) Z and M values must be provided within the input geometry for each point, and adding in zeros is sufficient.

 

View solution in original post

3 Replies
DanPatterson
MVP Esteemed Contributor

over what dem is the profile to extract the data?

arcgis.features.elevation.DataFile(....


... sort of retired...
0 Kudos
Moe-Notos
Occasional Contributor

From my understanding, since I specified:


dem_resolution='FINEST'

it determined that:


"ProductName": "NED_1r3_arcsec"​

should be used (located within the output). Additionally, the REST API Reference For profile (which from my understanding the python api implements) mentions that the data source can be auto selected or specified within the request.

 

I was attempting to follow the latest Python API Reference For arcgis.features.elevation as well as several sample notebooks, including Using Geoprocessing Tools.

If there are other sources of documentation please let me know.

 

Thanks!

0 Kudos
Moe-Notos
Occasional Contributor

I was able to retrieve the Z and M values using the following code:

input_polyline = Polyline({
	"paths": [[[-73.609551, 45.490678, 0, 0],
			   [-73.584162, 45.513645, 0, 0]]],
	"spatialReference": {
		"wkid": 4326
	}
})

input_feature_set = FeatureSet(
	features=[Feature(geometry=input_polyline)])

arcgis.env.return_z = True
arcgis.env.return_m = True

pf = profile(input_line_features=input_feature_set,
			 dem_resolution='FINEST')

print(pf)

 

Two steps were required:

1) The following lines had to be added, which set the environment variables for arcgis:

import arcgis
arcgis.env.return_z = True
arcgis.env.return_m = True

 

2) Z and M values must be provided within the input geometry for each point, and adding in zeros is sufficient.