1

I have the following code that works fine. However when I open in ArcGIS Pro 3.0 the polylines do not show up until I set the map properties to match the shapefile.

spatialRef = arcpy.SpatialReference(4326)
#Create the shapefile
arcpy.management.CreateFeatureclass(workSpace, polylineFC, geometryType, template, has_m, has_z, spatialRef)

Once I set the coordinate system in the map properties, it works fine. Is there something I'm not doing in the script?

1
  • 1
    The data has a coordref, and the canvas has a coordref (and a map window). They don't have to be the same coordref (and the map window doesn't have to overlap the data extent). You need to create a layer from the data source and add it to the map. If the map is empty, it should take on the layer coordref and set the extent to the data envelope. Otherwise you need to set these things from the script. Note that you don't need to set the map coordinate reference to the data coordref, just something that the Projection Engine can convert "on the fly".
    – Vince
    Nov 28, 2022 at 15:58

2 Answers 2

0

Actually, this code is correct and the problem was with Pro. I checked the options> Map and Scene>Spatial Reference and it was set to something other than use the first layer spatial reference.

0

I would say what you are experiencing is standard behaviour in ArcGIS Pro. If the map is in one coordinate system and you add a layer in a different coordinate system without setting the maps transformation, then that data is often plotted off screen. Imagine trying to shorn-horn a dataset for the USA into British National Grid, it's not going to display. That's what you are trying to do. So, by resetting the map coordinate system to that new layer it then displays in the correct place.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.