Select to view content in your preferred language

ManageMapServerCacheTiles ERROR 001431: Invalid geometry found after projecting to service's spatial reference

356
2
11-20-2024 07:04 AM
ColForbin
Frequent Contributor

I have a script that recreates the map server cache tiles that uses a shape file for the area of interest.  I am getting this error, even though both shape file and map service are in the same spatial reference:

ERROR 001431: Invalid geometry found after projecting to service's spatial reference


Here's the script:

arcpy.SignInToPortal(portal_url, "user name", "password")
mapserviceURL = r"url to map service/MapServer"
scales = [120000, 60000, 30000, 15000, 7500, 3750, 1875, 938, 469, 235]
numOfCachingServiceInstances = 3
updateMode = "RECREATE_ALL_TILES"
areaOfInterest = "path to my shapefile.shp"
waitForJobCompletion = "WAIT"
updateExtents = ""
result = arcpy.ManageMapServerCacheTiles_server(mapserviceURL, scales, updateMode, numOfCachingServiceInstances, areaOfInterest, updateExtents, waitForJobCompletion)

 

 The script runs and cache tiles are recreated if I use coordinates for the updateExtents.  Any ideas why this will not work with a shapefile area of interest?

0 Kudos
2 Replies
TonyAlmeida
MVP Regular Contributor

error indicates that the shapefile contains invalid geometries that cannot be accurately projected into the spatial reference of the map service.

 

Verify the map service spatial reference.

service_spatial_ref = arcpy.SpatialReference("url to map service/MapServer")
print(service_spatial_ref.name)

 Project the service to ensure there are no discrepancies.

map_service_spatial_ref = arcpy.SpatialReference(102100)  # Example: Web Mercator (Auxiliary Sphere)
arcpy.Project_management(
    "path to my shapefile.shp",
    "path to reprojected_shapefile.shp",
    map_service_spatial_ref
)

 

repair the shapefile.

arcpy.RepairGeometry_management("path to reprojected_shapefile.shp")
0 Kudos
ColForbin
Frequent Contributor

I recreated the shapefile (not a copy) with new geometry and same spatialRef as the cache service  still get same error, which seems odd.  I'll try your script and report back.  Thanks

0 Kudos