Model Builder Layer to KMZ Extent to Export Error

528
7
Jump to solution
12-01-2021 11:15 AM
DevonAlsip
New Contributor II

I created a model that iterates over points in a feature class and creates viewsheds observing different heights. The final output is 3 viewsheds (6ft, 10ft, 15ft) per point in the feature class. This part of the tool works fine.

The next step is to convert the viewsheds into KMZs. I get an error on the ‘Extent to Export’ option of the ‘Layer to KML’ tool. I have tried using the ‘Default’ option, but it just returns null coordinates (See Picture Attachment). I have also tried referencing the layer that is to be converted to a KML. This works for the first iteration (Observer 1), but once the tool starts to iterate over Observer 2, the Extent to Export does not change. It keeps the same extent as the layer for Observer 1.

My last attempt I created a buffer of all the points using the observers maximum range.  When I connected the output of the buffer to the ‘Layer to KML’ tool and selected “Extent to Export”, it copied the file path into the coordinate boxes instead of the actual coordinates (See Picture Attachment). If I open up the ‘Layer to KML’ tool and under “Extent to Export” I select the buffer layer, it does work for that entire feature class, BUT if I load a new feature class into the tool in a different part of the world, it keeps the Extent of the first feature class. This is not ideal because I don’t want to manipulate the model each time I need to run viewsheds.

I apologize if my explanation was a bit confusing, I hope the pictures clarify my work. Any help would be much appreciated.  

 

0 Kudos
1 Solution

Accepted Solutions
curtvprice
MVP Esteemed Contributor

Zap the NaN's: str(arcpy.Describe(r"%buffer fc%").Extent).replace("NaN","")

Do not forget to set the Calculate Value output data type to Extent so you can connect it to the tool's parameter of type extent.

This validates OK for me.  No promises whether it actually gets the tool to give you the output you want though!

If it needs to be WGS84, run your buffer with an output coordinate system setting of WGS84 and use that to calculate your extent.

 

 

Executing (Calculate Value): CalculateValue str(arcpy.Describe(r"efillcells_poly").Extent).replace("NaN","") # Extent
Start Time: Wednesday, December 1, 2021 5:29:49 PM
Value = 622280.000000002 4857190 626460 4862460
Succeeded at Wednesday, December 1, 2021 5:29:50 PM (Elapsed Time: 0.03 seconds)
Executing (Layer To KML): LayerToKML efillcells_poly C:\gisclass\efillcells_poly_LayerToKML.kmz 0 NO_COMPOSITE "622280.000000002 4857190 626460 4862460" 1024 96 CLAMPED_TO_GROUND
Start Time: Wednesday, December 1, 2021 5:29:50 PM
Succeeded at Wednesday, December 1, 2021 5:29:51 PM (Elapsed Time: 1.91 seconds)

 

 

 

View solution in original post

7 Replies
curtvprice
MVP Esteemed Contributor

Two approaches to pass that extent to the tool:

1)  connect the extent feature class (buffer output) to the layer to kmz tool and choose Extent environment. The tool help does say it honors the environment extent.

2) use Calculate Value to return extent object :   str(arcpy.Describe(r"%buffer fc%").Extent), data type Extent and connect that extent to the layer to KMZ tool parameter

Good luck!

0 Kudos
DevonAlsip
New Contributor II

I tried both methods. The first method returned 'Error 000964: Specified Extent is invalid'. This was the error I kept getting during all my other approaches. 

I think the second method might be the answer but I just cant get it to work. When using the Calculate Value and Describe Function on its own, the returned value is the four corners of the extent but then it is followed by 'NaN NaN NaN NaN'. When I hook the return value up to the KML to Layer Extent, it gives me Error 000735: Value is Required. Its as if the Extent doesnt exist at all.

0 Kudos
curtvprice
MVP Esteemed Contributor

Zap the NaN's: str(arcpy.Describe(r"%buffer fc%").Extent).replace("NaN","")

Do not forget to set the Calculate Value output data type to Extent so you can connect it to the tool's parameter of type extent.

This validates OK for me.  No promises whether it actually gets the tool to give you the output you want though!

If it needs to be WGS84, run your buffer with an output coordinate system setting of WGS84 and use that to calculate your extent.

 

 

Executing (Calculate Value): CalculateValue str(arcpy.Describe(r"efillcells_poly").Extent).replace("NaN","") # Extent
Start Time: Wednesday, December 1, 2021 5:29:49 PM
Value = 622280.000000002 4857190 626460 4862460
Succeeded at Wednesday, December 1, 2021 5:29:50 PM (Elapsed Time: 0.03 seconds)
Executing (Layer To KML): LayerToKML efillcells_poly C:\gisclass\efillcells_poly_LayerToKML.kmz 0 NO_COMPOSITE "622280.000000002 4857190 626460 4862460" 1024 96 CLAMPED_TO_GROUND
Start Time: Wednesday, December 1, 2021 5:29:50 PM
Succeeded at Wednesday, December 1, 2021 5:29:51 PM (Elapsed Time: 1.91 seconds)

 

 

 

DevonAlsip
New Contributor II

That worked! Thank you for the time and effort you put in to helping us.

ZacharyHart
Regular Contributor

@curtvprice  sorry to dig up an old thread here but I figured better than starting a new one for the exact same reason. I've tried both methods and I still get a 

ERROR 000964: Specified extent is invalid

 This same model works fine in ArcMap (where it was developed) but is failing in Pro 2.9.x. The same exact issue as @DevonAlsip was experiencing. 

I'm not sure what to do except for rebuilding the entire thing using ArcPy (which seems to be what I end up doing with all my old models since model builder is so finicky....). 

Any ideas?

0 Kudos
ABishop
Regular Contributor III

Hello Devon,

Since you are using model builder, I would add the Layer to KML tool for each layer with different extents and export them using the model.  Sounds like you are trying to use the tool manually at the end?

Amanda Bishop, GISP
0 Kudos
DevonAlsip
New Contributor II

Sorry for the confusion, I am trying to automate as much as the process as I can, so I need those extents to dynamically change with layer.