voxcity.geoprocessor.draw.rectangleยถ
Interactive rectangle drawing and rotation utilities for geographic maps.
Provides functions for: - Drawing rectangles on interactive ipyleaflet maps - Rotating rectangles with proper coordinate transformations - City-centered map initialization with rectangle drawing - Fixed-dimension rectangle creation from center points
Functionsยถ
|
Project rectangle to Mercator, rotate, and re-project to lat-lon coordinates. |
|
Create an interactive map for drawing rectangles with two modes. |
|
Create an interactive map centered on a specified city for drawing rectangles. |
|
Create a map centered on a city where clicking creates a rectangle of specified dimensions. |
|
Create an interactive map with a side panel for drawing rectangles. |
|
Create an interactive rectangle-drawing map with a side panel. |
Module Contentsยถ
- voxcity.geoprocessor.draw.rectangle.rotate_rectangle(m, rectangle_vertices, angle)[source]ยถ
Project rectangle to Mercator, rotate, and re-project to lat-lon coordinates.
The rotation is performed around the rectangleโs centroid using a standard 2D rotation matrix in Web Mercator space for accurate distance preservation.
- Parameters:
m (ipyleaflet.Map) โ Map object to draw the rotated rectangle on.
rectangle_vertices (list) โ List of (lon, lat) tuples defining the rectangle.
angle (float) โ Rotation angle in degrees (positive = counter-clockwise).
- Returns:
Rotated (lon, lat) tuples, or None if no vertices provided.
- Return type:
list
- voxcity.geoprocessor.draw.rectangle.draw_rectangle_map(center=(40, -100), zoom=4)[source]ยถ
Create an interactive map for drawing rectangles with two modes.
Aligned mode: click two opposite corners to draw an axis-aligned rectangle.
Rotated mode: click 3 points to draw a rotated rectangle.
Drawing starts immediately when a mode button is selected.
- Parameters:
center (tuple) โ Center coordinates (lat, lon). Defaults to (40, -100).
zoom (int) โ Initial zoom level. Defaults to 4.
- Returns:
(ipywidgets.VBox, list that will be populated with (lon, lat) vertices)
- Return type:
tuple
- voxcity.geoprocessor.draw.rectangle.draw_rectangle_map_cityname(cityname, zoom=15)[source]ยถ
Create an interactive map centered on a specified city for drawing rectangles.
Two modes are available via toggle buttons:
Aligned: click two opposite corners (axis-aligned rectangle).
Rotated: click 3 points to draw a rotated rectangle.
- Parameters:
cityname (str) โ Name of the city (e.g. โTokyo, Japanโ).
zoom (int) โ Initial zoom level. Defaults to 15.
- Returns:
(ipywidgets.VBox, list that will be populated with (lon, lat) vertices)
- Return type:
tuple
- voxcity.geoprocessor.draw.rectangle.center_location_map_cityname(cityname, east_west_length, north_south_length, zoom=15, rotation_angle=0)[source]ยถ
Create a map centered on a city where clicking creates a rectangle of specified dimensions.
After placing a center point, an interactive rotation slider appears so the rectangle can be rotated on the map in real time.
- Parameters:
cityname (str) โ Name of the city.
east_west_length (float) โ Width of the rectangle in meters.
north_south_length (float) โ Height of the rectangle in meters.
zoom (int) โ Initial zoom level. Defaults to 15.
rotation_angle (float) โ Initial rotation angle in degrees (positive = counter-clockwise). Defaults to 0.
- Returns:
- (widget, list that will be populated with (lon, lat) vertices)
widget is an ipywidgets VBox containing the map and a rotation slider. Display it with
display(widget)or as the last expression in a notebook cell.
- Return type:
tuple
- voxcity.geoprocessor.draw.rectangle.rectangle_map(center=(40, -100), zoom=15, width=500, height=500, cityname='')[source]ยถ
Create an interactive map with a side panel for drawing rectangles.
Three drawing modes are provided via the panel:
Aligned: click two opposite corners for an axis-aligned rectangle.
Rotated: click 3 points to draw a rotated rectangle.
Fixed: click a center point to place a rectangle with the specified width (east-west) and height (north-south), then adjust the rotation angle with a slider.
The panel includes a city-name field that re-centres the map on submission.
- Parameters:
center (tuple) โ Map center as (lat, lon). Defaults to (40, -100).
zoom (int) โ Initial zoom level. Defaults to 15.
width (float) โ Initial east-west length in metres (for Fixed mode).
height (float) โ Initial north-south length in metres (for Fixed mode).
cityname (str) โ Pre-filled city name for the location field.
- Returns:
(ipywidgets.VBox, list that will be populated with (lon, lat) vertices)
- Return type:
tuple
- voxcity.geoprocessor.draw.rectangle.create_rectangle_map(cityname=None, zoom=15, width=500, height=500)[source]ยถ
Create an interactive rectangle-drawing map with a side panel.
Combines aligned / rotated drawing and fixed-dimension placement into a single map. If cityname is provided the map is centred on that city and the location field is pre-filled; otherwise a world-level view is shown and the user can type a city name into the panel.
- Parameters:
cityname (str, optional) โ Name of the city (e.g.
"Tokyo").zoom (int) โ Initial zoom level. Defaults to 15.
width (float) โ Initial east-west length in metres (for Fixed mode).
height (float) โ Initial north-south length in metres (for Fixed mode).
- Returns:
- (ipywidgets.VBox, list that will be populated with (lon, lat)
vertices in SW โ NW โ NE โ SE order)
- Return type:
tuple