How to determine whether layer's geometry has z via REST API

840
2
Jump to solution
10-04-2021 10:19 AM
RyanSutcliffe
Occasional Contributor II

I was just looking for a way to quickly determine whether a layer in a published ArcGIS Server MapService has z values. If you look at the html version of the page this is listed: 

RyanSutcliffe_0-1633366770394.png

But if you view the same page in json via `?f=json`, that property seems to be missing. Is there a trick to get this information. I'd like to quickly be able to determine whether a layer loaded in my app has Z values, even though I am loading it in a 2D MapView. 

[A 2D MapView will not load z values even if you request them. See here

 

0 Kudos
1 Solution

Accepted Solutions
RyanSutcliffe
Occasional Contributor II

As @jcarlson has pointed out, and a helpful ESRI Canada representative suggested, there might actually be a `hasZ` property present in json even when the layer does not have z data. It might depend on your service configuration or ArcGIS Server version. 

In my case, using ArcGIS Server 10.7.1 and 10.8, it turns out that the `hasZ` property was present if the layer does have z values (at least in the case of our configurations for our point layers). But not otherwise. 

Once I confirmed that, the json response from an endpoint like (/arcgis/services/[servicename]/MapServer/[layer#]?f=json)  worked fine. In javascript something like:

```

if(!json.hasZ) { 

 // handle no z values
}

```

Will handle both cases nicely. 

View solution in original post

2 Replies
jcarlson
MVP Esteemed Contributor

I see the property:

jcarlson_0-1633368325212.png

 

- Josh Carlson
Kendall County GIS
RyanSutcliffe
Occasional Contributor II

As @jcarlson has pointed out, and a helpful ESRI Canada representative suggested, there might actually be a `hasZ` property present in json even when the layer does not have z data. It might depend on your service configuration or ArcGIS Server version. 

In my case, using ArcGIS Server 10.7.1 and 10.8, it turns out that the `hasZ` property was present if the layer does have z values (at least in the case of our configurations for our point layers). But not otherwise. 

Once I confirmed that, the json response from an endpoint like (/arcgis/services/[servicename]/MapServer/[layer#]?f=json)  worked fine. In javascript something like:

```

if(!json.hasZ) { 

 // handle no z values
}

```

Will handle both cases nicely.