From 1389aa6b166b01209e820d52c45b76162402bc17 Mon Sep 17 00:00:00 2001 From: bacetiner Date: Thu, 18 Jan 2024 02:11:11 -0800 Subject: [PATCH] BRAILS can now create a baseline building inventory from NSI --- brails/workflow/NSIParser.py | 147 +++++++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 brails/workflow/NSIParser.py diff --git a/brails/workflow/NSIParser.py b/brails/workflow/NSIParser.py new file mode 100644 index 0000000..99c7032 --- /dev/null +++ b/brails/workflow/NSIParser.py @@ -0,0 +1,147 @@ +# -*- coding: utf-8 -*- +# +# Copyright (c) 2024 The Regents of the University of California +# +# This file is part of BRAILS. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# You should have received a copy of the BSD 3-Clause License along with +# BRAILS. If not, see . +# +# Contributors: +# Barbaros Cetiner +# +# Last updated: +# 01-18-2024 + +import requests +import numpy as np +import pandas as pd +import os +from requests.adapters import HTTPAdapter, Retry +from shapely.strtree import STRtree +from shapely import Polygon, Point + +class NSIParser: + def __init__(self): + self.inventory = [] + + def GenerateBldgInventory(self,footprints): + minlat = footprints[0][0][1] + minlon = footprints[0][0][0] + maxlat = footprints[0][0][1] + maxlon = footprints[0][0][0] + for fp in footprints: + for vert in fp: + if vert[1]>maxlat: + maxlat = vert[1] + if vert[0]>maxlon: + maxlon = vert[0] + if vert[1]