Skip to content

laser.measles.demographics.shapefiles

laser.measles.demographics.shapefiles

laser.measles.demographics.shapefiles.add_dotname(path, dot_name_fields, dotname_symbol=':', append_suffix='dotname', inplace=False, field_name='DOTNAME')

Add a DOTNAME to the shapefile.

laser.measles.demographics.shapefiles.check_field(path, field_name)

Check whether a shapefile contains a named attribute field.

Parameters:

Name Type Description Default
path str | Path

Path to the .shp file.

required
field_name str

Field name to look for (e.g. "DOTNAME").

required

Returns:

Type Description
bool

True if the field exists in the shapefile's DBF schema.

laser.measles.demographics.shapefiles.get_shapefile_dataframe(shapefile_path)

Get a DataFrame containing the shapefile data with DOTNAME and shape columns.

Parameters:

Name Type Description Default
shapefile_path str | Path

The path to the shapefile.

required

Returns:

Type Description
DataFrame

A DataFrame with DOTNAME and shape columns.

laser.measles.demographics.shapefiles.plot_shapefile_dataframe(df, ax=None, plot_kwargs=None)

Render shapefile polygons onto a matplotlib axes.

Parameters:

Name Type Description Default
df DataFrame

DataFrame returned by get_shapefile_dataframe containing a shape column.

required
ax Axes | None

Matplotlib axes. A new figure is created if None.

None
plot_kwargs dict | None

Additional keyword arguments forwarded to matplotlib.patches.Polygon.

None

Returns:

Type Description
Figure

The matplotlib Figure containing the rendered map.