IaaGeoDataCleaning.MapTools package

Submodules

IaaGeoDataCleaning.MapTools.iaa_explore module

class IaaGeoDataCleaning.MapTools.iaa_explore.MapTool(shapedir, shape_geom, shape_iso2)

Bases: object

create_map(center=(0, 0), zoom=2)

Create a basic map.

Parameters:
  • center
  • zoom
Returns:

Return type:

folium.Map.

format_popup(loc, ctry)

Format the locational description for popup icon.

Parameters:
  • loc (str.) – location or lower level locational information.
  • ctry (str.) – country or higher level locational information.
Returns:

Return type:

tuple of (str, str)

haversine(lat0, lng0, lat1, lng1)

Calculate the distance between two geographical points using the haversin formula (in kilometers).

Parameters:
  • lat0
  • lng0
  • lat1
  • lng1
Returns:

the distance in km.

plot_all_data(data, loc_col, ctry_col, lat_col, lng_col, clr='blue', as_cluster=True)

Create markers for all of the locational data points.

Parameters:
  • data (str or DataFrame.) – filepath (.csv or .xlsx extension) or dataframe.
  • loc_col (str.) – name of location column.
  • ctry_col (str.) – name of country column.
  • lat_col (str.) – name of latitude column.
  • lng_col (str.) – name of longitude column.
  • clr (str.) – color of the markers.
  • as_cluster (bool.) – indicate whether the markers will be saved in a cluster or not.
Returns:

all of the created markers.

Return type:

list of folium.Marker if as_cluster=False or a folium.MarkerCluster if as_cluster=True.

plot_condition(data, query_dict, loc_col, ctry_col, lat_col, lng_col, excl=False, clr='blue')

Create markers for all data points that meet the conditions as specified in the query dictionary.

If excl=True, the function only creates markers for points meeting every single criteria. Else, it creates markers for any point that meets at least one of the conditions.

Parameters:
  • data
  • query_dict (dict of {str: list, str: set, or str: str}.) – dictionary whose keys are column names mapping to the queried value(s).
  • loc_col
  • ctry_col
  • lat_col
  • lng_col
  • excl (bool.) –
  • excl – exclusive or inclusive plotting.
  • clr
Returns:

plot_correct_data(data, loc_col, ctry_col, lat_col, lng_col, clr='green', as_cluster=False)

Create markers for all of the data points whose locational information correspond to their respective country.

Parameters:
  • data
  • loc_col
  • ctry_col
  • lat_col
  • lng_col
  • clr
  • as_cluster
Returns:

plot_pair(coords0, coords1, clr0='lightblue', clr1='darkblue')

Create markers for two sets of coordinates.

Parameters:
  • coords0 (tuple or list of int or float.) –
  • coords1 (tuple or list of int or float.) –
  • clr0
  • clr1
Returns:

plot_pair_in_df(data, index, lat0_col, lng0_col, lat1_col, lng1_col, clr0='lightblue', clr1='darkblue')

Create two markers for a data point if it has two locational information.

Parameters:
  • data
  • index (int) – index of the data point in the data.
  • lat0_col
  • lng0_col
  • lat1_col
  • lng1_col
  • clr0
  • clr1
Returns:

two markers for the coordinates.

Return type:

tuple of (folium.Marker, folium.Marker)

plot_point(lat, lng, desc=None, clr='blue')

Create a single popup located at the passed coordinates.

Parameters:
  • lat (int or float.) –
  • lng (int or float.) –
  • desc (str.) – description of the popup.
  • clr (str.) –
Returns:

Return type:

folium.Marker.

plot_potential_errors(data, loc_col, ctry_col, lat_col, lng_col, clr='lightred', plot_alt=False)

Create markers for all of the data points whose coordinates either fall in the ocean or do not correspond to their respective country.

These entries can be geocoded and the returned coordinates can be created as separate markers if plot_alt=True.

Parameters:
  • data
  • loc_col
  • ctry_col
  • lat_col
  • lng_col
  • clr
  • plot_alt (bool.) – indicate whether to geocode and create markers for alternative coordinates.
Returns:

plot_within_point(data, index, radius, loc_col, ctry_col, lat_col, lng_col, clr0='blue', clr1='lightblue')

Create markers for all data points within the passed radius of the specified data point.

Parameters:
  • data
  • index (int) – index of the focal data point.
  • radius – radius of the search circle (in kilometers).
  • loc_col
  • ctry_col
  • lat_col
  • lng_col
  • clr0
  • clr1
Returns:

plot_within_range(data, center, radius, loc_col, ctry_col, lat_col, lng_col, desc0=None, clr0='blue', clr1='lightblue')

Create markers for all data points within the range of the passed center.

Parameters:
  • data (str or DataFrame) – filepath (.csv or .xlsx extension) or dataframe.
  • center (tuple or list of int or float.) – center of the search circle.
  • radius (int or float.) – radius of the search circle (in kilometers).
  • loc_col
  • ctry_col
  • lat_col
  • lng_col
  • desc0 – description of the marker for the center.
  • clr0 (str.) – color of the center.
  • clr1 (str.) – color of the other markers.
Returns:

Return type:

list of folium.Marker.

Module contents