def overlay(self, csv_file): if (str(self.outFileType.currentText()) == 'CSV'): seperator = "," else: seperator = "\t" loc_df = map_locations.locations_df(csv_file, sep=seperator, output_dir=str(self.outputLine.text()), \ df_column=str(self.comboBox.currentText())) loc_gdf = generate_maps.get_loc_gdf(loc_df) text = str(self.typeBox.currentText()) if (text == "Heatmap"): hmap = heatmap.heatmap(loc_gdf, output_dir=str(self.outputLine.text())) elif (text == "Choropleth"): gdf = choropleth.choropleth_map(loc_gdf, shp_path=str( self.shapeLine.text())) plot = choropleth.plot_map(gdf, output_dir=str(self.outputLine.text())) elif (text == "Overlay Locations Map"): gdf, loc_gdf = generate_maps.generate_overlay_gdf( loc_df, shp_path=str(self.shapeLine.text())) plot = generate_maps.plot_gdf(gdf, loc_gdf, output_dir=str( self.outputLine.text()))
def create_user_gif(user_df, gif_filename, output_dir='', png_basename='map'): ''' Generates a GIF for a dataframe, which is used to be able to track specfic users or values locations over time. Parameters ---------- user_df: Pandas DataFrame A DataFrame generated by the get_user_df function. gif_filename: str The name of the GIF which will be outputted. output_dir: str Directory to output images of each user at time intervals. png_basename: str The basename for each image outputted to track a specfic user. Returns ------- : int Returns 1 if completed. ''' images = [] filenames = [] for i in range(0, len(user_df)): gdf, loc_gdf = generate_maps.generate_overlay_gdf( user_df[user_df.index == i]) ax, plot, graph = generate_maps.plot_gdf(gdf, loc_gdf) plot.savefig(png_basename + '_{}.png'.format(i)) for file in glob.glob(output_dir + "*.png"): images.append(imageio.imread(file)) if (gif_filename[-4:] != ".gif"): imageio.mimsave(gif_filename + '.gif', images) else: imageio.mimsave(gif_filename, images) return 1
def generate_map(csv_file): if (str(p1.outFileType.currentText()) == 'CSV'): seperator = "," else: seperator = "\t" loc_df = pd.read_csv(csv_file, sep=seperator) loc_gdf = generate_maps.get_loc_gdf(loc_df, column_name=str( p2.columnBox.currentText())) text = str(p2.typeBox.currentText()) if (text == "Heatmap"): hmap = heatmap.heatmap(loc_gdf, output_dir=str(p1.outputLine.text())) elif (text == "Choropleth"): gdf = choropleth.choropleth_map(loc_gdf, shp_path=str(p2.shapeLine.text())) plot = choropleth.plot_map(gdf, output_dir=str(p1.outputLine.text())) elif (text == "Map of Locations Overlay onto Shapefile"): gdf, loc_gdf = generate_maps.generate_overlay_gdf( loc_df, shp_path=str(p2.shapeLine.text())) plot = generate_maps.plot_gdf(gdf, loc_gdf, output_dir=str(p1.outputLine.text()))