Spaces:
Sleeping
Sleeping
Commit
·
b638e63
1
Parent(s):
e501eeb
Delete modules/geojson_github_loader.py
Browse files
modules/geojson_github_loader.py
DELETED
@@ -1,40 +0,0 @@
|
|
1 |
-
|
2 |
-
import requests
|
3 |
-
import geopandas as gpd
|
4 |
-
|
5 |
-
def download_github_geojson(github_user, repository, file_path, token):
|
6 |
-
"""
|
7 |
-
Load GeoJSON data from a GitHub repository.
|
8 |
-
|
9 |
-
Args:
|
10 |
-
github_user (str): GitHub username.
|
11 |
-
repository (str): GitHub repository name.
|
12 |
-
file_path (str): Path of the GeoJSON file in the repository.
|
13 |
-
|
14 |
-
Returns:
|
15 |
-
pd.DataFrame: The loaded GeoJSON data.
|
16 |
-
"""
|
17 |
-
|
18 |
-
# headers with personal access token
|
19 |
-
headers = {
|
20 |
-
"Authorization": f"token {token}"
|
21 |
-
}
|
22 |
-
|
23 |
-
# Create a URL to the raw GeoJSON file in the repository
|
24 |
-
raw_url = f"https://raw.githubusercontent.com/{github_user}/{repository}/{file_path}"
|
25 |
-
|
26 |
-
print(f"Debug: raw_url = {raw_url}") # Debugging line
|
27 |
-
|
28 |
-
# Make a GET request to the URL
|
29 |
-
response = requests.get(raw_url, headers=headers)
|
30 |
-
|
31 |
-
if response.status_code == 200:
|
32 |
-
# Parse the GeoJSON data
|
33 |
-
geojson_data = gpd.read_file(response.text)
|
34 |
-
print("File loaded succesfully.")
|
35 |
-
print(geojson_data.head())
|
36 |
-
return geojson_data
|
37 |
-
|
38 |
-
else:
|
39 |
-
print(f"Failed to retrieve GeoJSON data. Status code: {response.status_code}")
|
40 |
-
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|