Skip to content

Commit

Permalink
Added shapefile to geojson conversion, updated copyrights
Browse files Browse the repository at this point in the history
  • Loading branch information
axelstudios committed Jun 4, 2024
1 parent d3a721b commit 8236768
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 12 deletions.
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# !/usr/bin/env python
"""
SEED Platform (TM), Copyright (c) Alliance for Sustainable Energy, LLC, and other contributors.
See also https://github.com/seed-platform/seed/main/LICENSE.md
See also https://github.com/SEED-platform/seed/blob/main/LICENSE.md
"""

import gzip
Expand Down
2 changes: 1 addition & 1 deletion utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# !/usr/bin/env python
"""
SEED Platform (TM), Copyright (c) Alliance for Sustainable Energy, LLC, and other contributors.
See also https://github.com/seed-platform/seed/main/LICENSE.md
See also https://github.com/SEED-platform/seed/blob/main/LICENSE.md
"""
2 changes: 1 addition & 1 deletion utils/chunk.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# !/usr/bin/env python
"""
SEED Platform (TM), Copyright (c) Alliance for Sustainable Energy, LLC, and other contributors.
See also https://github.com/seed-platform/seed/main/LICENSE.md
See also https://github.com/SEED-platform/seed/blob/main/LICENSE.md
"""


Expand Down
2 changes: 1 addition & 1 deletion utils/common.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# !/usr/bin/env python
"""
SEED Platform (TM), Copyright (c) Alliance for Sustainable Energy, LLC, and other contributors.
See also https://github.com/seed-platform/seed/main/LICENSE.md
See also https://github.com/SEED-platform/seed/blob/main/LICENSE.md
"""

from typing import TypedDict
Expand Down
2 changes: 1 addition & 1 deletion utils/geocode_addresses.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# !/usr/bin/env python
"""
SEED Platform (TM), Copyright (c) Alliance for Sustainable Energy, LLC, and other contributors.
See also https://github.com/seed-platform/seed/main/LICENSE.md
See also https://github.com/SEED-platform/seed/blob/main/LICENSE.md
"""

import requests
Expand Down
2 changes: 1 addition & 1 deletion utils/geojson_helpers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
SEED Platform (TM), Copyright (c) Alliance for Sustainable Energy, LLC, and other contributors.
See also https://github.com/seed-platform/seed/main/LICENSE.md
See also https://github.com/SEED-platform/seed/blob/main/LICENSE.md
"""


Expand Down
2 changes: 1 addition & 1 deletion utils/normalize_address.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# !/usr/bin/env python
"""
SEED Platform (TM), Copyright (c) Alliance for Sustainable Energy, LLC, and other contributors.
See also https://github.com/seed-platform/seed/main/LICENSE.md
See also https://github.com/SEED-platform/seed/blob/main/LICENSE.md
"""

import re
Expand Down
19 changes: 19 additions & 0 deletions utils/shp_to_geojson.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# !/usr/bin/env python
"""
SEED Platform (TM), Copyright (c) Alliance for Sustainable Energy, LLC, and other contributors.
See also https://github.com/SEED-platform/seed/blob/main/LICENSE.md
"""

import os

import geopandas as gpd
from pyproj import CRS

from utils.ubid import add_ubid_to_geodataframe


def shp_to_geojson(shapefile: str):
file_name, _ext = os.path.splitext(shapefile)
gdf = gpd.read_file(shapefile).to_crs(CRS.from_epsg(4326))
(add_ubid_to_geodataframe(gdf, additional_ubid_columns_to_create=[])
.to_file(f"{file_name}.geojson", driver='GeoJSON'))
6 changes: 3 additions & 3 deletions utils/ubid.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# !/usr/bin/env python
"""
SEED Platform (TM), Copyright (c) Alliance for Sustainable Energy, LLC, and other contributors.
See also https://github.com/seed-platform/seed/main/LICENSE.md
See also https://github.com/SEED-platform/seed/blob/main/LICENSE.md
"""

from buildingid.code import decode, encode
Expand All @@ -10,10 +10,10 @@
from shapely.geometry import Point, Polygon


def encode_ubid(geometry: Polygon) -> str:
def encode_ubid(geometry: Polygon, code_length: int = PAIR_CODE_LENGTH_) -> str:
min_longitude, min_latitude, max_longitude, max_latitude = geometry.bounds
centroid = geometry.centroid
ubid = encode(min_latitude, min_longitude, max_latitude, max_longitude, centroid.y, centroid.x, codeLength=PAIR_CODE_LENGTH_)
ubid = encode(min_latitude, min_longitude, max_latitude, max_longitude, centroid.y, centroid.x, codeLength=code_length)
return ubid


Expand Down
2 changes: 1 addition & 1 deletion utils/update_dataset_links.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# !/usr/bin/env python
"""
SEED Platform (TM), Copyright (c) Alliance for Sustainable Energy, LLC, and other contributors.
See also https://github.com/seed-platform/seed/main/LICENSE.md
See also https://github.com/SEED-platform/seed/blob/main/LICENSE.md
"""

import base64
Expand Down
2 changes: 1 addition & 1 deletion utils/update_quadkeys.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# !/usr/bin/env python
"""
SEED Platform (TM), Copyright (c) Alliance for Sustainable Energy, LLC, and other contributors.
See also https://github.com/seed-platform/seed/main/LICENSE.md
See also https://github.com/SEED-platform/seed/blob/main/LICENSE.md
"""

from pathlib import Path
Expand Down

0 comments on commit 8236768

Please sign in to comment.