Help modifiying getExtent to get data from only 1 layer

845
5
Jump to solution
01-07-2020 07:48 AM
RickHawkins
New Contributor II

I have the following code:

The way it is written it shows all of the layers in my mxd file. I want to change the code so that i only gets the data for 1 layer: Primary OH

How would i change the script to do this?

Thanks

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
JoshuaBixby
MVP Esteemed Contributor

The Extent—Help | ArcGIS Desktop documentation covers it, albeit maybe not direct enough.

Summary

An extent is a rectangle specified by providing the coordinate of the lower left corner and the coordinate of the upper right corner in map units.

The key is "in map units," which means in the units of the spatial reference for the layer.  From looking at the values in your screenshot below, it is obvious the coordinates aren't geographic, so you are working with some projection.

View solution in original post

0 Kudos
5 Replies
JoshuaBixby
MVP Esteemed Contributor

There are multiple ways to do this, and the ListLayers—Help | ArcGIS Desktop documentation covers this

Syntax

ListLayers (map_document_or_layer, {wildcard}, {data_frame})
ParameterExplanationData Type
map_document_or_layer

A variable that references a MapDocument or Layer object.

Object
wildcard

A combination of asterisks (*) and characters can be used to help limit the results.

(The default value is None)

String
data_frame

A variable that references a DataFrame object.

(The default value is None)

DataFrame

and shows a couple examples:

0 Kudos
RickHawkins
New Contributor II

Joshua, Thanks for pointing me in he right direction. This code works. It get floating numbers for the min/max values.

Can you tell me what the number mean - x/y coordinates, feet, etc?

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

The Extent—Help | ArcGIS Desktop documentation covers it, albeit maybe not direct enough.

Summary

An extent is a rectangle specified by providing the coordinate of the lower left corner and the coordinate of the upper right corner in map units.

The key is "in map units," which means in the units of the spatial reference for the layer.  From looking at the values in your screenshot below, it is obvious the coordinates aren't geographic, so you are working with some projection.

0 Kudos
RickHawkins
New Contributor II

Sorry, i meant to show the numbers that i am getting:

Also, would you know how to make ArcGIS zoom to these coordinates?

Thanks

0 Kudos
RickHawkins
New Contributor II

Joshua,

Thanks for the help

0 Kudos