Python method to change spatial reference of query layer?

251
1
05-17-2023 10:17 AM
DanCall1
New Contributor II

I am using ArcGIS Pro 3.04. I have a bunch of maps in several APRX files which contain query layers, each based on a different SQL database view. Those maps are published to an ArcGIS Portal site. The data behind the database views is changing: the spatial reference is currently a state plane system but is being converted to web mercator. The query used for these layers is just one line, selecting everything that's in the database view.

I already have a process to update all the SQL views, but I need to update the query layers to the new spatial reference. In the GUI, I can do this in the layer properties, Source tab: When I re-validate the query (the query doesn't need to change), Pro re-examines the view and selects the correct SRID.

Is there any way to automate the process of changing a query layer's SRID? I've done some searching and it doesn't look like it's possible. I know I can change the connection properties using arcpy, but as far as I've seen it's not possible to update the details of a query layer (either changing the query text, or changing the SRID).

0 Kudos
1 Reply
RogerDunnGIS
Occasional Contributor II

I'm curious on one point.  How do you know that it's being converted?  Online maps and ArcGIS Pro will try to project-on-the-fly, and they usually try to match a map's basemap layer's coordinate system.  That's where I'm curious.

0 Kudos