Select to view content in your preferred language

Is it possible to export my bookmarks as a layer (point / polygon) in ArcGIS Pro?

6525
11
08-20-2018 11:57 PM
SvenBiesdorf1
New Contributor

Is it possible to export my bookmarks as a layer (point / polygon) in ArcGIS Pro?

0 Kudos
11 Replies
DanPatterson_Retired
MVP Emeritus

Bookmarks in arcpy

Bookmark—ArcPy | ArcGIS Desktop 

As for ideas that exist, 

https://community.esri.com/ideas/12759 

Check ArcGIS Ideas‌ for other links

JohnWatt
Frequent Contributor

Had the same problem and blugeoned a work-a-round out of my PC using Excel to get points for each bookmark - which were then used as an index for a map series. Basically you can export the bookmarks to a BKMX file, drag that into Excel (Excel recognises the rows as a bkmx is just xml I think), use text-to-columns, a filter, an INDIRECT formula, and some helper columns to transpose into a simple table with 'name' 'x' and 'y' columns.  Then bring that back into Pro as XY point data.

Ugly, but it worked 🙂

0 Kudos
TomBole
Esri Regular Contributor

Hi John, 

With Pro 2.6 you can use can use the bookmarks directly to create a map series - Introduction to a bookmark map series—ArcGIS Pro | Documentation . If you're map series doesn't need data to drive dynamic text or set page queries for other layers in the map, Bookmark Map Series may be an option for you.

Hope this helps, 

Tom

by Anonymous User
Not applicable

Hi @SvenBiesdorf1

I had this same question, and didn't find an answer I really liked, so I decided to make a toolbox. 

It works very similarly to the solution posted by @JohnWatt  here in the comments, but makes it a little more user friendly. Just export a .bkmx, specify the output folder, name, and coordinate system, and it creates a feature class for your bookmarks. @TomBole mentioned that you can use Bookmarks as the input for your map series which is true, but it is convenient to be able to set your extents as bookmarks and then also have an option for dynamic text fields.  

I have made the toolbox and python script available here:

https://github.com/roirboya/Bookmark2FC_Pro

MichaelRobb2
Occasional Contributor

I know this is an oldish post but just wanted to send some praise this direction as this is a great little tool, thank you!!  It also gets around the issue of not being able to use Python to automate export of multiple PNGs from a Map Series as I can just convert these to shapefiles instead :). Nice!!!

0 Kudos
bcaldwell
New Contributor

Howdy Anonymous,

I took your general idea and simplified it a bit

 

 

# ----------------------------------------------------------------------------
# Import modules
import arcpy, os

# ----------------------------------------------------------------------------
# Get Parameters and create blank feature
layoutName = arcpy.GetParameterAsText(0) # Layout - name of target layout
mapFrame = arcpy.GetParameterAsText (1) # String - name of target map frame
output_dir = arcpy.GetParameterAsText(2) # Folder
output_name = arcpy.GetParameterAsText(3) # String - "include .shp"
coordsys = arcpy.GetParameterAsText(4) # Coord System of Dataframe, or something else if bookmarks are from another source. 

aprx = arcpy.mp.ArcGISProject("CURRENT")
lyt = aprx.listLayouts(layoutName)[0]
mf = lyt.listElements("MAPFRAME_ELEMENT", mapFrame)[0]
FC = arcpy.management.CreateFeatureclass(output_dir,output_name,'POLYGON',"","DISABLED","DISABLED",coordsys)
arcpy.management.AddField(FC, "NAME", "TEXT" )

for m in aprx.listMaps():
    for bkmks in m.listBookmarks():
        mf.zoomToBookmark(bkmks)
        extent = mf.camera.getExtent()
        polygon = extent.polygon
        name = bkmks.name
        row_values = [(name, polygon)]
        icur = arcpy.da.InsertCursor(FC, ["NAME", 'SHAPE@'])
        for row in row_values:
            icur.insertRow(row)
        del icur
        arcpy.AddMessage("Created polygon for bookmark " + name)

map = aprx.listMaps()[0]
map.addDataFromPath(output_dir + "\\" + output_name)
arcpy.AddMessage(output_name + " added to map")

 

 

 

 

 

Tags (3)
MichaelBelnap
New Contributor

Good morning @bcaldwell :

I was able to take the toolbox that the previous Anonymous User provided and create the working script from the Python Snippet they provided.  I haven't been able to take the snippet that you provided and get it functional.  I'm fairly new to Python and I'm still learning much of the basics and fundamentals, but when I run the script it states that Line 16 IndexError: list index out of range. I'm sure that I'm doing something wrong but would greatly love to use your provided tool.  Thank you for any help provided.

0 Kudos
bcaldwell
New Contributor

@MichaelBelnap  I was able to run it with two test bookmarks, using your Pro Toolbox

bcaldwell_1-1685462215407.png

bcaldwell_2-1685462274215.png

I haven't used this in a long time, but I did make an edit to the toolbox/script to not need the map frame, see uploaded abtx. 

bcaldwell_3-1685463552598.pngbcaldwell_4-1685463569741.png

Hope this helps

-Blake

 







ChathurikaThilakarathna
New Contributor

It works. Thank you😍

0 Kudos