Skip to content

Instantly share code, notes, and snippets.

View Youssef-Harby's full-sized avatar
🌍

Youssef Harby Youssef-Harby

🌍
View GitHub Profile

Keybase proof

I hereby claim:

  • I am youssef-harby on github.
  • I am yharby (https://keybase.io/yharby) on keybase.
  • I have a public key ASBmkyd87Ju7hwN_Uej1lBn8r2SbYZsl12bXghbTDcxPNwo

To claim this, I am signing this object:

@Youssef-Harby
Youssef-Harby / googlemapsurltoxy.py
Created August 21, 2023 09:43
How to extract X-Long and Y-Lat from google maps url
import csv
import re
def extract_lat_long(csv_file, url_column):
pattern = r".+!3d(-?\d+\.\d+)!4d(-?\d+\.\d+).+"
data = []
# Read the CSV file and extract latitude and longitude values
with open(csv_file, 'r') as f:
@Youssef-Harby
Youssef-Harby / buildings.py
Created December 15, 2023 15:01
OvertureMaps Duckdb Scripts
import duckdb
con = duckdb.connect('./duckdb.duckdb')
data = """
SET memory_limit = '32GB';
SET threads TO 16;
SET enable_progress_bar = true;
SET enable_progress_bar_print = true;
INSTALL httpfs;
INSTALL spatial;
@Youssef-Harby
Youssef-Harby / csv_to_geospatial.py
Created December 24, 2023 08:41
Converting CSV to Any Geospatial Format Using DuckDB and DuckDB Spatial Extension.
# dataset ref : https://www.kaggle.com/datasets/max-mind/world-cities-database/code
# pip install duckdb
import duckdb
con = duckdb.connect()
data = """
-- Environment setup
SET enable_progress_bar = true;
@Youssef-Harby
Youssef-Harby / aws_s3_http.py
Created January 2, 2024 16:55
Amazon S3 REST API with HTTP
import httpx
import datetime
import hashlib
import hmac
# AWS credentials
access_key = "secret"
secret_key = "secret"
region = "eu-central-1" # e.g. 'us-west-1'
bucket = "bucket-name"
@Youssef-Harby
Youssef-Harby / geoparquet_metadata_point_example.py
Created April 23, 2024 01:44
GeoParquet 1.1 metadata example
import pyarrow as pa
import pyarrow.parquet as pq
from pathlib import Path
import json
import pandas as pd
def process_parquet_file(parquet_path):
# Read the Parquet file into a PyArrow Table
table = pq.read_table(parquet_path)
@Youssef-Harby
Youssef-Harby / README.md
Created October 2, 2024 09:57
Overture Maps Data Downloader with Optional GeoJSON Clipping

Overture Maps Data Downloader with Optional GeoJSON Clipping

This Python script downloads geospatial data from Overture Maps, based on user-defined themes and data types (e.g., buildings, transportation). The script can download specific data within a given bounding box (bbox) and export it in GeoParquet or GeoPackage format.

Features:

Allows downloading multiple themes/types (e.g., buildings, transportation) using the overturemaps Python library.
Bounding box (bbox) filtering to limit data to a specific geographic extent.
Optionally clips geometries to the exact boundaries of a GeoJSON file, if provided.

Supports output in GeoParquet or GeoPackage formats.

@Youssef-Harby
Youssef-Harby / hrrr.py
Created June 23, 2025 21:31 — forked from barronh/hrrr.py
Retrieve HRRR via Open Data on AWS and Zarr
__doc__ = """
# Overview
This example shows how to open High Resolution Rapid Refresh (HRRR) meteorology
"surfaces." These surfaces are slices in vertical space to create single level
maps of variables like temperature, wind speed components, pressure, etc. Each
surface is opened using the Zarr archive described in Amazon's opendata registry
described at https://registry.opendata.aws/noaa-hrrr-pds/.
# Examples