示例#1
0
from shapely.geometry import Point, Polygon, MultiPolygon, LineString, MultiLineString, mapping
from shapely.affinity import scale

from rscommons import Logger, RSProject, RSLayer, ModelConfig, dotenv, initGDALOGRErrors, ProgressBar
from rscommons import GeopackageLayer, ShapefileLayer, VectorBase, get_shp_or_gpkg
from rscommons.vector_ops import get_geometry_unary_union, copy_feature_class
from rscommons.util import safe_makedirs, safe_remove_dir, safe_remove_file, parse_metadata
from gnat.utils.confinement_report import ConfinementReport
from gnat.__version__ import __version__

Path = str

initGDALOGRErrors()
gdal.UseExceptions()

cfg = ModelConfig('http://xml.riverscapes.xyz/Projects/XSD/V1/Confinement.xsd',
                  __version__)

LayerTypes = {
    # key: (name, id, tag, relpath)]
    'INPUTS':
    RSLayer(
        'Inputs', 'INPUTS', 'Geopackage', 'inputs/inputs.gpkg', {
            'FLOWLINES':
            RSLayer('Flowlines', 'FLOWLINES', 'Vector', 'Flowlines'),
            'CONFINING_POLYGON':
            RSLayer('Confining Polygon', 'CONFINING_POLYGON', 'Vector',
                    'ConfiningPolygon'),
        }),
    'INTERMEDIATES':
    RSLayer(
        'Intermediates', 'INTERMEDIATES', 'Geopackage',
示例#2
0
import os
import argparse
import json
import sys
import traceback
import uuid
import datetime
from rscommons import Logger, RSProject, RSLayer, ModelConfig, dotenv, initGDALOGRErrors
from rscommons.util import safe_makedirs, safe_remove_file

cfg = ModelConfig('http://xml.riverscapes.xyz/Projects/XSD/V1/LST.xsd',
                  '0.0.1')


def process_lst(lst_xml_folder):
    """This is a slightly hack-y script to create some XMLS for the land_surface_temp script
        It's a bit of an afterthought so it just plunks down the XMLS all alone in a folder

    Args:
        lst_xml_folder ([type]): [description]
    """

    log = Logger("Generate XMLS for LST")
    hucs = [str(1700 + x) for x in range(1, 13)]

    for huc in hucs:
        hucdir = os.path.join(lst_xml_folder, huc)
        xml_file = os.path.join(hucdir, 'project.rs.xml')
        safe_makedirs(hucdir)
        if os.path.exists(xml_file):
            safe_remove_file(xml_file)
示例#3
0
import time
import argparse
import uuid
from rscommons import RSProject, RSLayer, ModelConfig, Logger, dotenv
from rscommons.util import safe_makedirs
# Import your own version. Don't just use RSCommons
from rscommons.__version__ import __version__
"""
Instructuions:
    1. create a file called .env in the root and add the following line (without the quotes):
                "PROJECTFILE=C:/path/to/my/folder/that/will/have/project.rs.xml"
    2. Run `BuildXML` from VSCode's Run dropdown menu
"""

# Set up a class to track thigns like default EPSG, xsd validation and tool version
cfg = ModelConfig('http://xml.riverscapes.xyz/Projects/XSD/V1/Inundation.xsd',
                  __version__)

# Define the types of layers we're going to use up top so we can re-use them later
# We use our handy RSLayer() class here.
LayerTypes = {
    # RSLayer(name, id, tag, rel_path)
    'AP_01':
    RSLayer('2019 August', 'APORTHO_01', 'Raster',
            '01_Inputs/01_Imagery/AP_01/orthomosaic.tif'),
    'APSTR_01':
    RSLayer('2019 August Flowlines', 'APSTR_01', 'Vector',
            '01_Inputs/01_Imagery/AP_01/flowlines.shp'),
}


def build_xml(projectpath):
示例#4
0
import csv
import sqlite3
import json
import argparse
import os
import datetime
import uuid
from rscommons import Logger, ModelConfig, RSProject, RSLayer, dotenv
from rscommons.shapefile import create_field
from rscommons.util import safe_makedirs
from osgeo import gdal, ogr, osr
import csv
from sqlbrat.__version__ import __version__

cfg = ModelConfig('http://xml.riverscapes.xyz/Projects/XSD/V1/fmLTPBR.xsd',
                  __version__)
# Don't forgbet to pip install dbfread. I didn't add it to requirements.txt

LayerTypes = {
    # key: (name, id, tag, relpath)
    'Photos': RSLayer('Photos', 'PHOTO', 'Vector', 'Photos.shp'),
    'Reaches': RSLayer('Reaches', 'REACH', 'Vector', 'Reaches.shp'),
    'Structures': RSLayer('Structures', 'STRUCT', 'Vector', 'Structures.shp'),
}

REACH_FIELDS = [
    # csv_name, shp_name, type, length
    ["pk", "pk", ogr.OFTString],
    ["fk_Project", "fkProj", ogr.OFTString],
    ["Name", "Name", ogr.OFTString],
    ["StreamName", "StreamName", ogr.OFTString],
示例#5
0
import traceback
import uuid
import datetime
from osgeo import ogr
from osgeo import gdal

from rscommons import Logger, initGDALOGRErrors, RSProject, RSLayer, ModelConfig, dotenv
from rscommons.util import safe_makedirs
# Import your own version. Don't just use RSCommons
from rscommons.__version__ import __version__
# Make sure we catch GDAL errors
initGDALOGRErrors()

# Setting up our model with an XSD will let us refer to it later
# The version should be your tool version. Usually this is stored in a __version__.py file
cfg = ModelConfig('http://xml.riverscapes.xyz/Projects/XSD/V1/MYTOOLHERE.xsd',
                  __version__)


def run(my_arg1: str, my_arg2: int):

    log = Logger("My Awesome tool")
    log.info('Starting RSContext v.{}'.format(cfg.version))

    # do_work()


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('arg1', help='Some Argument 1', type=str)
    parser.add_argument('arg2', help='Some Argument 2', type=int)
    parser.add_argument('--verbose',