GenerateOptimalCoordinateSystem

Summary

Generates a SpatialReference object with a custom projected coordinate system optimal for the specified extent and intended purpose of your map or analysis.

Since there is no way to project a curved surface onto a flat surface without distortion, various map projections exist that compromise between preserving angle, area, distance, or direction. The intended purpose and extent of a map can help determine which of these properties to preserve. For example, a conformal projection may be chosen for a navigational map to preserve bearing, or a projection preserving area may be required to visualize or measure the relative size of features.

Syntax

GenerateOptimalCoordinateSystem (extent, property, {custom_name})
ParameterExplanationData Type
extent

The extent of interest. The Extent object must have a spatial reference in a geographic coordinate system such as WGS84.

Extent
property

A property that represents the purpose of the projection.

  • EQUAL_AREAPreserves the relative area of regions everywhere on earth. Shape and distances will be distorted.
  • CONFORMALPreserves angles in small areas, so shapes are for the most part preserved. Size and distances will be distorted.
  • EQUIDISTANT_ONE_POINTPreserves distance when measured through the center of the projection. Area, shape, and other distances will be distorted.
  • EQUIDISTANT_MERIDIANSPreserves distance when measured along meridians. Area, shape, and other distances will be distorted.
  • COMPROMISE_WORLDDoes not preserve area, shape, or distance specifically, but creates a balance between these geometric properties. Compromise projections are only suggested for very large areas.

Not all properties are supported for all extents of interest. The CONFORMAL and EQUIDISTANT_MERIDIANS properties are only supported for large-scale extents, and the COMPROMISE_WORLD property is only supported for full-world extents. The EQUAL_AREA and EQUIDISTANT_ONE_POINT properties are supported for all extents

String
custom_name

The name of the custom projected coordinate system. If unspecified, the name will be Custom_Projection.

String
Return Value
Data TypeExplanation
SpatialReference

A SpatialReference object with the custom projected coordinate system that is optimal for the specified extent and intended purpose.

Code sample

GenerateOptimalCoordinateSystem example 1

Create a custom projected coordinate system that optimizes preserving area over a feature class's extent, and project the feature class to the custom projected coordinate system.

import arcpy

# Input features in Projected Coordinate System
infc = r"C:\Projected.gdb\Colorado_Counties"

# Get extent of features
desc = arcpy.Describe(infc)
extent = desc.extent

# Project the extent to Geographic Coordinate System WGS84
gcs_sr = arcpy.SpatialReference(4326)
prj_extent = extent.projectAs(gcs_sr)

# Create custom projected coordinate system
custom_sr = arcpy.GenerateOptimalCoordinateSystem(prj_extent, "EQUAL_AREA",
                                                  "EQUAL_AREA_COLORADO")

# Project the input features to the custom projection
fc_prj = arcpy.management.Project(infc, "TestPoly_Projected", custom_sr)
GenerateOptimalCoordinateSystem example 2

Create a simple polygon object and project it to a custom projected coordinate system with the conformal property.

import arcpy

gcs_sr = arcpy.SpatialReference(4326) # Create WGS84 spatial reference

# Create polygon
poly_info = [[20, 20], [20, 60], [60, 60], [60, 20], [20, 20]]
poly_pts = arcpy.Array([arcpy.Point(*coords) for coords in poly_info])
poly = arcpy.Polygon(poly_pts, gcs_sr)

# Create extent object from polygon
extent = poly.extent

# Create custom projected coordinate system
custom_sr = arcpy.GenerateOptimalCoordinateSystem(extent, "CONFORMAL")

# Project the polygon to the custom projection
poly_prj = poly.projectAs(custom_sr)

Related topics