https://colab.research.google.com/assets/colab-badge.svg

Landscape Dynamics#

The Landscape Dynamics spatial database is published here: https://www.nature.com/articles/s41597-021-01100-9

Setup#

Ecoscope#

[ ]:
# !pip install ecoscope
[ ]:
import os
import sys
import zipfile

import geopandas as gpd

import ecoscope

ecoscope.init()

Google Drive Setup#

[ ]:
output_dir = "Ecoscope-Outputs/landDx"

if "google.colab" in sys.modules:
    from google.colab import drive

    drive.mount("/content/drive/", force_remount=True)
    output_dir = os.path.join("/content/drive/MyDrive/", output_dir)

os.makedirs(output_dir, exist_ok=True)

Download landDX Data#

[ ]:
ecoscope.io.download_file(
    url="https://maraelephant.maps.arcgis.com/sharing/rest/content/items/162e299f0c7d472b8e36211e946bb273/data",
    path=output_dir,
    overwrite_existing=False,
)

Extract ZIP#

[ ]:
zipfile.ZipFile(os.path.join(output_dir, "active_public_uncategorized_shpfiles.zip")).extractall(path=output_dir)

Read in Polyline Shapefile#

[ ]:
polylines_gdf = gpd.read_file(os.path.join(output_dir, "landDx_polylines.shp"))
polylines_gdf

Observe the column names. Due to limitations in the shapefile format, some of the column names have been truncated compared to the full names displayed in the ArcGIS Online feature service.

[ ]:
polylines_gdf.columns

View Unique Polyline Types#

[ ]:
polylines_gdf["type"].unique()

Select Polylines by List of Types#

[ ]:
types = ["Road_Primary_Murram", "Road_Primary_Dirt/Sand", "Road_Secondary_Dirt/Sand", "Road_Secondary_Murram"]

roads_gdf = polylines_gdf[polylines_gdf["type"].isin(types)].copy()

Display#

[ ]:
roads_gdf.explore()

Export to GPKG#

[ ]:
roads_gdf.to_file(os.path.join(output_dir, "roads.gpkg"), layer="roads", driver="GPKG")