ChangeGDBSpatialReference

Title  Change GDB Spatial Reference

Description

Creates a new file geodatabase in the user-specified spatial reference.

Usage

          
Creates a new file geodatabase in the user-specified spatial reference.

License

Standard

Syntax

ChangeGDBSpatialReference (gdb, spatial_reference, output_folder, output_name)

Parameter Explanation Data Type
gdb Dialog Reference

The input gdb that will be copied.

DEWorkspace
spatial_reference Dialog Reference

The spatial reference of the new geodatabase.

GPSpatialReference
output_folder Dialog Reference

The folder location where the asset package will be created.

DEWorkspace
output_name Dialog Reference

The name of the output geodatabase.

GPString

Code Samples

ChangeGDBSpatialReference example 1 (Python window)

Changes the spatial reference of all items in the geodatabase.

import arcpy

arcpy.udms.ChangeGDBSpatialReference("D:/data/network.gdb", 3457, "D:/data", "network_3457")

ChangeGDBSpatialReference example 2 (stand-alone script)

Changes the spatial reference of all items in the geodatabase.

import os

import arcpy

workspace = "D:/data/network.gdb"
spatial_reference = arcpy.SpatialReference(3457)  # Louisiana SPCS South

result = arcpy.udms.ChangeGDBSpatialReference(
    gdb=workspace,
    spatial_reference=spatial_reference,
    output_folder=os.path.dirname(workspace),
    output_name=f"{os.path.basename(workspace).split('.')[0]}_{spatial_reference.name}",
)

print(result[0])