Select to view content in your preferred language

Find map limits of a map serie (IndexLayer python)

177
7
Monday
VanGoethemNicolas
Emerging Contributor

First I'm sorry about my English level and maybe the wrong place to post my subject (I've looked about the good place but didn't find it)

I created a map serie witch find its index on a layer. On thit serie I put an index grid witch will be the base of an second maps serie (Some people told me that's not possible but it works good). I created a spatial joint on this grid and a page request on it because I want to keep the index for ma second serie.

The  problem is, I can't center my mini map on the index of first serie, so I would like to retrieve the currents limits of the first serie and put it as limits of second mini map by python. 

I tried by camera and the cartographic window but the geography returned is not in the good system (I'm workin with 'Lambert 2008', not with decimal degrees).

I'm not sure to find the information by the way used with the code at the end of post. 

Somebody can help me ton fond the good way ? 

Thank you 🙂

 

import arcpy

# ---------------------
# Liste des constantes
# ---------------------

layout_name = "PARIS2733_Atlas masses d'eau (page de garde)"

# -------------------------
# Accéder au projet actuel
# -------------------------

projet = arcpy.mp.ArcGISProject("CURRENT") #'print(projet)' renvoie l'adresse de stockage

# ---------------------------------------------------
# Récupération du layout de la première mise en page
# ---------------------------------------------------

layout = projet.listLayouts(layout_name)[0] # Le [0] est obligatoire même si n'y a qu'une ligne, sans ce paramètre on récupère une liste et non un layout
index_layer = layout.mapSeries.indexLayer
#field_names = [field.name for field in arcpy.ListFields(index_layer)]

 

 

0 Kudos
7 Replies
AlfredBaldenweck
MVP Regular Contributor

You don't have to use Python for this, if I understand you correctly.

You can instead use Map frame constraints—ArcGIS Pro | Documentation to make the extent of the minimap match that of the main map.

linkedmap.gif

 

0 Kudos
VanGoethemNicolas
Emerging Contributor

Thank you for your answer, I'm using a single map to make two map series : 

The first one looks like that and the minimap works.

VanGoethemNicolas_0-1744638519743.png

The second one is based on the grid of first one to give that result (cut on the first maps serie) : 

VanGoethemNicolas_1-1744638645087.png

I would like to have a zoom as the first main map but on the second minimap but the scale works with the index of the actual map serie witch is the second one. So the zoom is both, bigger or lower than wanted.

Exemple if center with the map frame linked and the layer : 

VanGoethemNicolas_2-1744639171836.pngVanGoethemNicolas_3-1744639223527.pngVanGoethemNicolas_4-1744639250578.png

It's why i decided to use python because I've no idea how to fix it without code.

Thank you for the next answer 🙂

 

 

 

 

0 Kudos
AlfredBaldenweck
MVP Regular Contributor

Oh, I think I understand.

You have a few options here, but both of them involve setting the map series's extent and are essentially the same thing.

AlfredBaldenweck_0-1744663050008.png

 

  1. Set the margin size to 0%
  2. Resize the map frame so that it all-but matches the index feature.AlfredBaldenweck_1-1744663266091.png
    Index Feature is in purple
  3. Set up your extent indicator
    extent.gif

The other option is to do basically the same thing, but manually set the scale. In this example, the 0% margin gave me a scale of 1:906,000, but I found I preferred 1:910,000 instead. It gave me basically the same effect, but it also let me see just a bit outside the index feature.

 

0 Kudos
VanGoethemNicolas
Emerging Contributor

I've already get it but it works only with the main frame : 

VanGoethemNicolas_0-1744701465602.png

I checked the spatial ref in the facultative options and choose the spatial ref of the first index but the mini map doesn't want to center itself on the first mapSerie index :'( . 
I think that the minimap stay center on the first mapSerie scale (global) and not on the new one (grid_index with spatial join and page request on the first mapSerie index). The grid is correctly cut but the minimap still fixed on the entire grid index.

Thank for the help, my project could be work by using some maps or project but it looks possible to make what I want and keep an automatic update of my map 🙂

0 Kudos
AlfredBaldenweck
MVP Regular Contributor

I'm sorry, I'm still not sure if I'm following. It sounds like you want the center of the minimap to move with the main map, and for the extent indicator to match the index feature exactly?

If that's the case, just combine both my answers.

I have my minimap and main map set up like in my second answer here: 

AlfredBaldenweck_0-1744819283587.png

I can then combine that with a linked center to preserve the scale but still move the camera: 

AlfredBaldenweck_1-1744819424952.png

mapserieslink.gif

0 Kudos
VanGoethemNicolas
Emerging Contributor

Hello,

Thanks for the answer. The problem is exactly that, the entity in the grid doesn't stay fixed in the mini map.

I can't give more screenshot today because of a network anomaly are blocking my access to the BDD.
In my project, the first series of maps contain one mini map with a global view on the entities, each page of this series is an entity (not from a grid) so the main map frame is a zoom on the selected entity. Each page is the first page of my second series of maps. It is also why the grid of the second series of maps is on my first series (font are cut by first series and grid to by a page request). The firs mini map is ok because of the same for all pages except the indicator witch one moving when I change the selected page (Figure : first map posted here)

In the same project and with the same map, I created a second series of map and keep the first one ON. This second one is based on the global grid witch one based on the global layer of the first series but correctly cut by the first series (I didn't cut the second series on its index to keep the layout of the first one). So it's impossible to show the good entity. I would like the mini map stays fixed on the entity selected by the firts series of map (Figure : your first one in the last exemple), your second exemple is what I have as a result but not what I want.

The problem is that I've no layer cut for each entity and so ArcGis use the global squale of the first series of map.

Hope my message est more clear than the last one 😄

0 Kudos
AlfredBaldenweck
MVP Regular Contributor

Ok, I think I understand now. You want to show which square of the grid the camera is in.

This is a no-code solution and it's kind of outside the box.

In short, we're not going to use an extent indicator at all, but a spatial join.

  1. Create your index features 
    AlfredBaldenweck_0-1744907891750.png
  2. Create your grid
    AlfredBaldenweck_1-1744907919847.png
  3. Duplicate your grid layer and change its symbology to something elseAlfredBaldenweck_2-1744908010854.png
    AlfredBaldenweck_3-1744908021236.png
  4. Perform a spatial join between the second Grid layer and the index features (points, in my example) 
    1. I used Add Spatial Join (Data Management)—ArcGIS Pro | Documentation, but you can also use Spatial Join (Analysis)—ArcGIS Pro | DocumentationAlfredBaldenweck_4-1744908163239.png
    2. Make sure you don't have anything selected when you perform the join, or else it's only going to work on what you have selected.
  5. Create your layout, following the steps in the other posts. I am still assuming you want the shape of the main map frame to match the minimap, but for this solution it doesn't matter. AlfredBaldenweck_5-1744908253547.png
  6. Create your map series.
    1. Since I'm using a point for my index layer, I'm setting the scale to 1:100,000.
      AlfredBaldenweck_6-1744908325136.pngAlfredBaldenweck_9-1744908654266.png

       

  7. Open the properties for the copy of the Grid with spatial join applied.
  8. On the Page Query tab, set the field to the same field that you're using for the map series. I'm using "Name" in this case. This is pointing to the field we got from the other table when we did our spatial join.
    AlfredBaldenweck_8-1744908594287.png
  9.  This has made it so only the features that match the index features will draw.AlfredBaldenweck_10-1744908705118.png
    I've added an extent indicator in blue to show you how it compares.mapseriesIndexSpatialJoin1.gif
  10. This will also work if you use lines or polygons.
    AlfredBaldenweck_11-1744909234660.pngAlfredBaldenweck_12-1744909349895.png
  11. It also worked just fine if the shape of the map frame didn't match the grid AlfredBaldenweck_13-1744909605382.png
  12. It also worked if the index features cross the grid featuresAlfredBaldenweck_15-1744909869809.pngAlfredBaldenweck_14-1744909851518.png

     

  13. I did have to use a full 1:Many spatial join for situations where there was more than one index feature in the same grid cellAlfredBaldenweck_16-1744910216201.png

     

See here for a related Idea to make this a little easier: Tie Symbology to Page Queries - Esri Community

0 Kudos