This project generates a visual representation of the Sine Saloum region using geographic coordinates. It allows the visualization of cities and their associated infrastructures on a map based on the Sine_Saloum.csv file. The generated map is saved locally as a .png file.
Before running the script, make sure you have the following dependencies installed:
- Python 3.x
- Pandas
- Matplotlib
You can install the required dependencies using pip:
pip install pandas matplotlib-
CSV File Setup:
-
Ensure that the
Sine_Saloum.csvfile is in the same directory as the executable script. -
Important: Do not change the file name; it must remain
Sine_Saloum.csv. -
The CSV file should include the following columns:
Name: Name of the city or location.Longitude: Longitude of the city.Latitude: Latitude of the city.Altitude: Altitude of the city.Infrastructure: A list of infrastructure codes related to the city.
-
-
Adding Infrastructures:
- To associate an infrastructure with a city, add the relevant code in the "Infrastructure" column of the CSV file.
- If there are multiple infrastructures for a city, separate the codes with commas.
- Ensure that the codes are written in uppercase letters as they are case-sensitive.
-
Revenue-Generating Associations:
A1: ApicultureA2: IndigoA3: Maraîchage
-
Health & Medical:
B1: AlbinismB2: DentalB3: TrainingB4: OphthalmologyB5: Health PostB6: First Aid
-
Education:
C1: Digital LibraryC2: Middle SchoolC3: Community Awareness CenterC4: SchoolC5: High School
-
Running the Script:
-
Once the CSV is set up and placed correctly, run the script:
python main.py
-
The script will process the CSV file, plot the cities on a map, annotate them with infrastructure information, and save the output as a
.pngfile.
-
-
Output:
-
The map will be saved in the same directory as the script with the name
response_mono.png. -
The map will display:
- City names annotated at their respective coordinates.
- Infrastructure markers (represented by specific symbols) for each city based on the infrastructure codes in the CSV.
-
The SineMap class in main.py is responsible for:
- Loading CSV data: Reads the
Sine_Saloum.csvfile into a Pandas DataFrame. - Creating the Map: Sets up the map's axes, bounding box, and grid.
- Plotting Points: Places city names and infrastructure markers on the map.
- Saving and Displaying: Saves the map as a
.pngfile and displays it on the screen.
axes(): Sets up the map's axes, bounding box, grid, and locators.listy(): Moves selected cities to a second DataFrame for further processing.plot(): Plots cities and annotations based on the infrastructure codes.save(): Saves the plot as a PNG image.show(): Displays the plot on the screen.exe_seq(): Executes the full sequence of operations: load, process, plot, save, and display.
To modify the Sine_Saloum.csv file and add new infrastructure associations:
- Open the
Sine_Saloum.csvfile in a text editor or spreadsheet application (e.g., Excel). - In the "Infrastructure" column, add the appropriate code(s) for each city.
- Save the file in CSV format (ensure the name remains
Sine_Saloum.csv). - Make sure that multiple infrastructure codes are separated by commas, and all codes are in uppercase.
Example of CSV structure:
| Name | Longitude | Latitude | Altitude | Infrastructure |
|---|---|---|---|---|
| Diamnadio | -16.5740562717412 | 14.0676469748257 | 0.40 | A1,A3 |
| Moundé | -16.6509121553705 | 13.9549517757492 | 4.39 | C2,A1,B5 |
| Niodor | -16.7231394014362 | 13.8549622993706 | 3.03 | B1,B2,A2 |
| Djirnda | -16.6085452104454 | 13.9788318032727 | 6.07 | C1,C4,A2,A3 |
After running the script, the output will be a map like the following example:
- The cities will be plotted according to their latitude and longitude.
- Infrastructure markers will be placed next to each city, with corresponding labels based on the infrastructure codes in the CSV.
For instance, a city like Diamnadio with infrastructure codes A1,A3 will have markers for Apiculture and Maraîchage placed on the map near the city's coordinates. Similarly, Moundé with codes C2,A1,B5 will display markers for Middle School, Apiculture, and Health Post.
Example of output map:
This map will show the geographic distribution of the cities and their corresponding infrastructures as represented by the markers.