Skip to content

Inset Maps

Often you need to show the viewer where your primary map is located in the broader world. geoplot-themes supports drawing a floating Inset Map.

Enabling Insets

To draw an inset, you simply provide a larger bounding shapefile to inset_map. The engine will automatically draw that shapefile, calculate the bounding box of your main data, and draw a red rectangle on the inset showing your location!

python
import geoplot_themes as gpt

gpt.plot_map_r(
    raster_data="nairobi_county.tif",
    
    # Pass a shapefile of the entire country or continent
    inset_map="kenya_borders.shp",
    
    output_path="nairobi_with_inset.png"
)

Positioning & Sizing

You can control exactly where the floating inset appears and how big it is.

python
gpt.plot_map_r(
    raster_data="nairobi_county.tif",
    inset_map="kenya_borders.shp",
    
    # Position: c(x, y) from 0.0 to 1.0 (bottom-left to top-right)
    inset_position=[0.05, 0.05], # Bottom-left corner
    
    # Scale: How much of the screen should it take? (0.0 to 1.0)
    inset_scale=0.25             # 25% of the canvas
)

Common Positions:

  • Top Right: [0.7, 0.7]
  • Bottom Left: [0.05, 0.05]
  • Top Left: [0.05, 0.7]

Released under the MIT License.