Select to view content in your preferred language

How to export Map as GeoTIFF through Python?

1620
3
Jump to solution
08-09-2022 05:59 AM
ssK_0
by
New Contributor

New to GIS/ArcGIS Pro, so apologies in advance if I say anything incorrect. I downloaded Esri's World Imagery tile layer, and upon opening it in ArcGIS Pro was able to zoom into an area and export that location as a GeoTIFF file manually by going to Share -> Export Map -> GeoTIFF. 

Does the ArcGIS Python API include a way to write a script to do all this through code (finding a target area of the tile layer/Map file through input coordinates or shapefile or something else and exporting it as a GeoTIFF file)? I tried exportToTIFF from https://pro.arcgis.com/en/pro-app/2.7/arcpy/mapping/layout-class.htm but wasn't able to get what I wanted.

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
JeffreyBarrette
New Contributor

The Python Map Automation API (aka arcpy.mp) should allow you to do exactly what you want.  You will want to work with the MapView class instead of Layout, most likely.  First, review those examples to change extent (i.e., camera) and then use the MapView.exportToTiff() function.  There are so many ways to set an extent so be sure to look at the samples in the Camera class too.

MapView Class: https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/mapview-class.htm

Camera Class: https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/camera-class.htm

If you need help with a specific scenario, please provide more detail.

Jeff - arcpy.mp and Layout teams

View solution in original post

3 Replies
JeffreyBarrette
New Contributor

The Python Map Automation API (aka arcpy.mp) should allow you to do exactly what you want.  You will want to work with the MapView class instead of Layout, most likely.  First, review those examples to change extent (i.e., camera) and then use the MapView.exportToTiff() function.  There are so many ways to set an extent so be sure to look at the samples in the Camera class too.

MapView Class: https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/mapview-class.htm

Camera Class: https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/camera-class.htm

If you need help with a specific scenario, please provide more detail.

Jeff - arcpy.mp and Layout teams

ssK_0
by
New Contributor

Hello, 

Thank you for your answer! It worked well. One follow-up question: I've been able to zoom into specific rectangular locations by modifying Extent.XMin, XMax, YMin, and YMax (where smaller differences between the max/min values seem to zoom in more), but I'm not sure how to interpret those four values or what they represent. Is there a way to convert them to standard latitude and longitude values and vice versa?

0 Kudos
JeffBarrette
Esri Regular Contributor

Hello,

The X/Y Min/Max values represent a rectangle like you suggest.  Rectangles are just one way of controlling extent and are not always the best.  For example, if the data in a map frame is rotated, the extent that gets returned will not match what you see in the UI because a rotated rectangle has a larger extent.  There are other techniques for zooming to a layer, selected features in a layer, etc.

Check out the first sample located in the MapFrame help topic. The same logic will work with a MapView.  The second parameter is to use the layers's selection.  if False, use all features, if True, use selection.  So you can first perform a SelectLayerByAttributes or ByLocation to create a selection and then use the selection to control your zoom level.

mf.camera.setExtent(mf.getLayerExtent(lyr, False, True))

https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/mapframe-class.htm

 

0 Kudos