Nurasyl Abdrazakuly Nurasyl Abdrazakuly

Visualizing Green Spaces in Almaty with OSM and Python

Green Spaces in Almaty

I visualized the green spaces of Almaty city 🇰🇿 using Python. This visualization was developed with Python, utilizing the osmnx (OpenStreetMap) and matplotlib libraries.

The visualization shows all the green spaces in Almaty 🌳. I also calculated the percentage of green spaces in relation to the total area of the city.

The result shows that 44.52% of the city's area is covered by green spaces, largely due to the inclusion of parts of the foothills in the city's territory.

Such maps help urban planners, ecologists, and researchers better understand the distribution of green zones, plan new green spaces, and improve the quality of life for city residents. Additionally, they support scientific research and contribute to creating more sustainable and healthy urban environments.


Preparing the Environment

Before starting, you need to install the necessary libraries:

      pip install osmnx matplotlib geopandas
          

Collecting and Visualizing Green Spaces

We can use the osmnx library to download the green spaces data from OpenStreetMap for Almaty:

      import osmnx as ox
      import geopandas as gpd
      import matplotlib.pyplot as plt
      
      # Download the green spaces in Almaty
      green_spaces = ox.geometries_from_place("Almaty, Kazakhstan", tags={"landuse": "grass"})
      
      # Plot the green spaces
      fig, ax = plt.subplots(figsize=(10, 10))
      green_spaces.plot(ax=ax, color="green", alpha=0.6)
      ax.set_title("Green Spaces in Almaty", fontsize=20)
      ax.set_xticks([])
      ax.set_yticks([])
      plt.show()
          

The code above downloads all areas tagged as "grass" in OpenStreetMap for Almaty and plots them. You can further filter or modify the tags to include other types of green spaces like parks, forests, etc.


Calculating the Percentage of Green Spaces

To calculate the percentage of green spaces relative to the entire city's area, you can use the following code:

      # Load the city's boundary
      city_boundary = ox.geocode_to_gdf("Almaty, Kazakhstan")
      
      # Calculate the area of green spaces and the city
      green_area = green_spaces.geometry.area.sum()
      city_area = city_boundary.geometry.area.sum()
      
      # Calculate the percentage of green spaces
      green_percentage = (green_area / city_area) * 100
      print(f"Percentage of green spaces: {green_percentage:.2f}%")
          

The result shows that 44.52% of Almaty's area is green space, which includes parts of the foothills within the city boundary.


Conclusion

This analysis and visualization provide insights into the distribution of green spaces within Almaty. Such information is valuable for urban planning, environmental studies, and enhancing the overall quality of life in urban environments. You can replicate this process for other cities to support sustainable urban development.


Code

The full project code is available on GitHub.