This repository contains a collection of Python scripts designed for geographical data analysis and visualization. These tools provide functionalities for processing KML/KMZ files, calculating polygon areas, generating HTML maps, and more.
-
File Handling
- Extract ZIP/KMZ files to access internal KML files.
- Convert KMZ files to KML format.
-
Geospatial Data Processing
- Read KML files into GeoDataFrames for easy manipulation.
- Validate and classify coordinates (Decimal Degrees or UTM).
- Calculate polygon areas in hectares.
-
Visualization
- Generate interactive HTML maps with Folium, including basemap overlays and polygon visualizations.
-
GeoJSON Handling
- Add custom attributes to GeoJSON files and save updated outputs.
-
Utilities
- Calculate string similarity for comparing names or identifiers.
Clone the repository and install the required dependencies:
git clone https://github.com/hitthecodelabs/Geospatial-Data-Analysis.git
cd Geospatial-Data-Analysis
pip install -r requirements.txtfrom geo_scripts import unzip_file
unzip_file('path/to/your.zip', 'output/directory')or
from geo_scripts import unzip_file
unzip_file('path/to/your.kmz', 'output/directory')from geo_scripts import convert_kmz_to_kml
kml_path = convert_kmz_to_kml('path/to/your.kmz')from geo_scripts import read_kml
gdf, features = read_kml('path/to/your.kml')from geo_scripts import generate_html_map
generate_html_map(gdf, 'output/maps', start_index=0, end_index=10)from geo_scripts import calculate_polygon_area
areas_gdf = calculate_polygon_area('path/to/your.kml')from geo_scripts import add_attribute_to_geojson
add_attribute_to_geojson('input.geojson', 'new_key', 'new_value', 'output.geojson')- Python 3.8+
- Required libraries:
os,shutil,fiona,pyproj,zipfile,numpy,geopandas,folium,BeautifulSoup4
Install the dependencies using:
pip install -r requirements.txtFeel free to fork this repository and submit pull requests. Please ensure code follows PEP 8 standards and includes docstrings for all functions.
This project is licensed under the MIT License. See the LICENSE file for details.
This project uses open-source libraries and tools, including:
For questions or feedback, please reach out to the repository owner.



