Exemplo n.º 1
0
def UpdateOptionsWithParameters(optionsObject):
    try:
        option0 = GetParameterAsText(0)
        option1 = GetParameterAsText(1)
        option2 = GetParameterAsText(2)
        option3 = GetParameterAsText(3)
        option4 = GetParameterAsText(4)
    except:
        pass
    
    
    if (option0 is not None and option0 != ""): # Geocoded to Intersection (accidentDataAtIntersections)
        optionsObject.accidentDataAtIntersections = option0
    else:
        pass
    if (option1 is not None and option1 != ""): # Where the roads features are (roadsFeaturesLocation)
        optionsObject.roadsFeaturesLocation = option1
    else:
        pass
    if (option2 is not None and option2 != ""): # Where the alias table for the roads features is (aliasTable)
        optionsObject.aliasTable = option2
    else:
        pass
    if (option3 is not None and option3 != ""): # Output location after offset (accidentDataWithOffsetOutput)
        optionsObject.accidentDataWithOffsetOutput = option3
    else:
        pass
    if (option4 is not None and option4 != ""): # Boolean choice of whether or not to use KDOT fields
        optionsObject.useKDOTFields = option4 ## Comes in as text rather than boolean.
    else:
        pass
    
    return optionsObject
Exemplo n.º 2
0
def UpdateGISPROD_NON_STATE_Check():

    print "what route number should be updated?"
    try:
        RID = GetParameterAsText(0)
    except:
        RID = '460C0387500W0'
    RIDExp = "RID = '" + RID + "'"
    MakeTableView_management(r"C:\temp\Nusys_Check.gdb\NON_STATE_EVENTS",
                             "UpdateGISPROD", "#", "in_memory")
    # Replace a layer/table view name with a path to a dataset (which can be a layer file) or create the layer/table view within the script
    # The following inputs are layers or table views: "UpdateGISPROD"
    TableToTable_conversion(in_rows="UpdateGISPROD",
                            out_path="in_memory",
                            out_name="updatetblh",
                            RIDExp,
                            "#",
                            config_keyword="")
    AddIndex_management("updatetblh", "FID_NON_STATE_SYSTEM", "ID2", "UNIQUE",
                        "ASCENDING")
    MakeFeatureLayer_management(NonState, "NonStateAll")
    AddJoin_management("NonStateAll", "ID2", "updatetblh",
                       "FID_NON_STATE_SYSTEM", "KEEP_COMMON")
    print "Check the numbers one more time, and review"
    print "start Edit session on NON_STATE_SYSTEM now and type /'Calc()/' if it all looks good "
Exemplo n.º 3
0
def UpdateOptionsWithParameters(optionsObject):
    try:
        option0 = GetParameterAsText(0)
        option1 = GetParameterAsText(1)

    except:
        pass

    if (option0 is not None and option0 != ""):
        optionsObject.countyName = option0
    else:
        optionsObject.countyName = "Allen"

    if (option1 is not None
            and option1 == "halfInch"):  # Name of the Address Locator
        optionsObject.mapScale = option1
    else:
        optionsObject.mapScale = "quarterInch"

    return optionsObject
def UpdateOptionsWithParameters(optionsObject):
    try:
        option0 = GetParameterAsText(0)
        option1 = GetParameterAsText(1)
        option2 = GetParameterAsText(2)
    except:
        pass

    if (option0 is not None and option0 != ""):
        optionsObject.gdbPath = option0
    else:
        pass
    if (option1 is not None and option1 != ""):  # Name of the Address Locator
        optionsObject.locatorName = option1
    else:
        optionsObject.locatorName = "KCARS_Crash_Loc"
    if (option2 is not None and option2 !=
            ""):  # Boolean choice of whether or not to use KDOT fields
        optionsObject.useKDOTFields = option2
    else:
        optionsObject.useKDOTFields = False  # Defaults to false

    return optionsObject
def UpdateOptionsWithParameters(optionsObject):
    try:
        option0 = GetParameterAsText(0)
        option1 = GetParameterAsText(1)

    except:
        pass

    if (option0 is not None and option0 !=
            ""):  # Where the roads features are (roadsFeaturesLocation)
        optionsObject.roadsFeaturesLocation = option0
        AddMessage(str(option0))
    else:
        pass

    if (option1 is not None
            and option1 != ""):  # Base Accident Data Table (accidentDataTable)
        optionsObject.accidentDataTable = option1
        AddMessage(str(option1))
    else:
        pass

    return optionsObject
Exemplo n.º 6
0
"""
Provide tool binding to calculate zscore functionality in summary utilities.
"""
# import just what we need to speed up tool loading
from summary_utilities import calculate_percent_delta
from arcpy import GetParameterAsText

# run the function
calculate_percent_delta(
    table=GetParameterAsText(0),
    data_field_one=GetParameterAsText(1),
    data_field_two=GetParameterAsText(2),
    delta_field=GetParameterAsText(3)
)
"""
Provide tool binding to calculate zscore functionality in summary utilities.
"""
# import just what we need to speed up tool loading
from summary_utilities import calculate_zscore
from arcpy import GetParameter, GetParameterAsText

# run the function
calculate_zscore(table=GetParameterAsText(0),
                 data_field=GetParameterAsText(1),
                 zscore_field=GetParameterAsText(2),
                 outlier_percent_threshold=GetParameter(3))
"""
Provide tool binding to add and calculate zscore functionality in summary utilities.
"""
# import just what we need to speed up tool loading
from summary_utilities import add_calculate_delta_zscore
from arcpy import GetParameter, GetParameterAsText

# run the function
add_calculate_delta_zscore(table=GetParameterAsText(0),
                           data_field_one=GetParameterAsText(1),
                           data_field_two=GetParameterAsText(2),
                           delta_field_name=GetParameterAsText(3),
                           delta_field_alias=GetParameterAsText(4),
                           zscore_field_name=GetParameterAsText(5),
                           zscore_field_alias=GetParameterAsText(6),
                           outlier_percent_threshold=GetParameter(7))
'''
cn_build_tbx.py

ArcToolbox script interface to the Curve Number Raster Builder script.

Used when you need to build a Curve Number Raster from scratch, using landcover, soils, and curve number lookup CSV.
'''
import importlib
from arcpy import GetParameterAsText
#from logic.gp import build_cn_raster
import logic
importlib.reload(logic)

logic.gp.build_cn_raster(
    landcover_raster=GetParameterAsText(0),
    lookup_csv=GetParameterAsText(3),
    soils_polygon = GetParameterAsText(1),
    soils_hydrogroup_field = GetParameterAsText(2),
    reference_raster=GetParameterAsText(4),
    out_cn_raster=GetParameterAsText(5)
)
Exemplo n.º 10
0
###################################
##### Import des librairies #######
###################################

from arcpy import mapping
from arcpy import GetCount_management
from arcpy import GetParameterAsText
from Tkinter import Tk
from tkFileDialog import askopenfile

###################################
####### Programme principal #######
###################################

mxd = GetParameterAsText(0)
layers = GetParameterAsText(1)
SetParameterAsText(1, mapping.ListLayers(mxd))


#cible = askopenfile(parent=root(), mode='r')
#mxd = mapping.MapDocument(cible.name)

#root.destroy()

#layers = mapping.ListLayers(mxd)
for lay in layers:
    if lay.isFeatureLayer:
        lay.name = lay.name + " (" + str(GetCount_management(lay)) + ")"

mxd.save()
Exemplo n.º 11
0
"""
Reports friendly cats, but uses validation to check parameters before running the script
"""

import os

from arcpy import AddField_management, AddMessage, CreateFeatureclass_management, GetParameterAsText
from arcpy.da import InsertCursor, SearchCursor

in_table = GetParameterAsText(0)  # Feature Layer
friendly_value = GetParameterAsText(1)  # Integer
output = GetParameterAsText(2)  # Feature Layer

# Get data from input-table
where_clause = '{0} = 1'.format(friendly_value)
field_names = ['SHAPE@XY', 'Type']
rows = list()
with SearchCursor(in_table, field_names, where_clause) as sc:
    for row in sc:
        rows.append(row)

# Create new feature class
path = '\\'.join(in_table.split('\\')[:-1])
output_name = output.split('\\')[-1]
CreateFeatureclass_management(path, output_name, 'POINT')

# Add fields to the new feature class
fields = [
    ('Type', 'TEXT'),
    ('Friendly', 'SHORT')
]
Exemplo n.º 12
0
def dealLogin(req, login):
    if login == 'NONE':
        return
    req.add_header('Authorization', 'Basic ' + b64encode(login))


def postGist(outFile, filename, login, description):
    newUrl = 'https://api.github.com/gists'
    baseFile = open(outFile, 'r')
    data = {
        "public": True,
        "files": {
            filename + ".geojson": {
                'content': baseFile.read()
            }
        }
    }
    baseFile.close()
    if description:
        data['description'] = description
    req = Request(newUrl)
    req.add_header('Content-Type', 'application/json')
    dealLogin(req, login)
    resp = urlopen(req, dumps(data))
    r = loads(resp.read())
    url = 'https://gist.github.com' + r['url'][r['url'].rfind('/'):]
    AddMessage(url)


doStuff(GetParameterAsText(0), GetParameterAsText(1), GetParameterAsText(2))
Exemplo n.º 13
0
from arcpy import da, GetParameterAsText, AddMessage, SelectLayerByAttribute_management
import pandas as pd

EventTable = GetParameterAsText(0)
RouteId = GetParameterAsText(1)
FromMeas = GetParameterAsText(2)
ToMeas = GetParameterAsText(3)
OverlapOID = GetParameterAsText(4)

OID_field = 'OID@'
np_array = da.FeatureClassToNumPyArray(EventTable,
                                       [RouteId, FromMeas, ToMeas, OID_field])
df = pd.DataFrame(np_array)
AddMessage(list(df))
route_list = df[RouteId].unique().tolist()

for route in route_list:
    df_route = df.loc[df[RouteId] == route]

    flipped_i = df_route.loc[df_route[FromMeas] > df_route[ToMeas]].index
    df_route.loc[flipped_i,
                 [FromMeas, ToMeas]] = df_route.loc[flipped_i,
                                                    [ToMeas, FromMeas]].values
    df_route.sort_values(by=[FromMeas, ToMeas], inplace=True)

    for index, row in df_route.iterrows():
        complete_overlap = ((df_route[FromMeas] > row[FromMeas]) &
                            (df_route[ToMeas] < row[ToMeas]))
        partial_front_overlap = ((df_route[FromMeas] < row[FromMeas]) &
                                 (df_route[ToMeas] > row[FromMeas]))
        overlap_i = df_route.loc[partial_front_overlap
# Import the bare minimum to increase speed
from arcpy import env as env
from arcpy import GetParameterAsText, SetParameterAsText
from arcpy import AddMessage, AddWarning
from arcpy import da
from arcpy import Point, PointGeometry
from arcpy import SelectLayerByLocation_management
from arcpy import SpatialReference
from arcpy import GetCount_management

# Environment Settings
env.overwriteOutput = True

# Get Inputs
strLatitude = GetParameterAsText(0)
strLongitude = GetParameterAsText(1)
flZCTA = GetParameterAsText(2)
flLEPC = GetParameterAsText(3)
flCounty = GetParameterAsText(4)
strFilePath = GetParameterAsText(5)

# Convert values from text to float
floLatitude = float(strLatitude)
floLongitude = float(strLongitude)

# Make a Point Geometry object.
try:
    ptPointOfInterest = Point(X=floLongitude,
                              Y=floLatitude,
                              Z=None,
            makedirs(out_folder)
        texture_images(i_list, extent, in_texture, in_polygon, out_folder,
                       method, blur_distance)  # Generate Texture-Masked tiles

        CheckInExtension("ImageAnalyst")
    except LicenseError:
        AddError("Image Analyst license is unavailable")
        print("Image Analyst license is unavailable")
    except ExecuteError:
        print(GetMessages(2))


if __name__ == "__main__":
    debug = False
    if debug:
        in_mosaic = r'C:\Users\geof7015\Documents\ArcGIS\Projects\ArcGIS_Image_Designer\test\ortho_mosaic.gdb\tile_27_test'
        in_texture = r'C:\Users\geof7015\Documents\ArcGIS\Projects\ArcGIS_Image_Designer\Textures\Processed\dune_vegetation_seamless.jpg'
        in_polygon = r'C:\Users\geof7015\Documents\ArcGIS\Projects\ArcGIS_Image_Designer\Galveston\Data\Esri_Processed\Dune_Outline.gdb\Galveston_Dune_Grass_Polys_Projected'
        out_folder = r'C:\Users\geof7015\Documents\ArcGIS\Projects\ArcGIS_Image_Designer\test\tile_dune'
        method = "GaussianBlur"  # "GaussianBlur", "BoxBlur", "None"
        blur_distance = 5  # Distance in Pixels
    else:
        from arcpy import GetParameterAsText, GetParameter
        in_mosaic = GetParameterAsText(0)
        in_texture = GetParameterAsText(1)
        in_polygon = GetParameterAsText(2)
        out_folder = GetParameterAsText(3)
        method = GetParameterAsText(4)  # "GaussianBlur", "BoxBlur", "None"
        blur_distance = GetParameter(5)  # Distance in Pixels
    main()
Exemplo n.º 16
0
def main():
    #get parameters from a tool interface
    title = GetParameterAsText(0)
    description = GetParameterAsText(1)
    dataTitles = GetParameterAsText(2)
    dataTypes = GetParameterAsText(3)
    dataDownloads = GetParameterAsText(4)
    dataFormats = GetParameterAsText(5)
    theme = GetParameterAsText(6)
    accessURL = GetParameterAsText(7)
    keyword = GetParameterAsText(8)
    existingfile = GetParameterAsText(9)

    #create download list in proper format
    DL_list = ""
    if dataTitles != "" or accessURL != "":
        lists = 0
        try:
            dataTitlesList = dataTitles.split(",")
            dataTypesList = dataTypes.split(",")
            dataDownloadsList = dataDownloads.split(",")
            dataFormatList = dataFormats.split(",")
            lists = 1
        except:
            print "one or more lists could not be split"

        DL_list = '"distribution": ['
        if lists == 1:
            for dt in dataTitlesList:
                i = dataTitlesList.index(dt)
                DL_list += '{"downloadURL":"' + dataDownloadsList[i].strip() + '","mediaType":"' + dataTypesList[i].strip() + '","format":"' + dataFormatList[i].strip() + '","title":"' + dt.strip() + '"},'

        #if there's a permalink, add it
        if accessURL != "":
            DL_list += '{"accessURL":"' + accessURL + '"}'

        #if the last character is a comma, remove it
        if DL_list[:-1] == ",":
            DL_list = DL_list[:-1]

        #make a pretty close to the
        DL_list += "]"

    #format tags
    keyword_list = '"keyword": ['
    if keyword != "":
        #create some error trapping
        if "," in keyword:
            keywordList = keyword.split(",")
        else:
            keywordList =[keyword]

        for k in keywordList:
            keyword_list += '"' + k.strip() + '",'

        keyword_list = keyword_list[:-1] + ']'

    entryObject = jsonEntry(title, description, DL_list, theme, keyword_list)

    jsonText = object2Json(entryObject)

    addEntry(existingfile, jsonText)

if __name__ == "__main__":
    debug = False
    if debug:
        in_folder = r'C:\Users\geof7015\Documents\ArcGIS\Projects\ArcGIS_Image_Designer\Galveston\Data\NAIP'
        image_format = "jp2"
        pixel_depth = "8_BIT_UNSIGNED"
        num_bands = 3
        product_definition = "NATURAL_COLOR_RGB"
        product_band_definitions = "Red 630 690;Green 530 570;Blue 440 510"
        pixel_size = 1000
        out_folder = r'C:\Users\geof7015\Documents\ArcGIS\Projects\ArcGIS_Image_Designer\scratch'
    else:
        from arcpy import GetParameterAsText, GetParameter
        in_folder = GetParameterAsText(0)
        image_format = GetParameterAsText(1)
        pixel_depth = GetParameterAsText(2)
        num_bands = GetParameter(3)
        product_definition = GetParameterAsText(4)
        product_band_definitions = GetParameterAsText(5)
        pixel_size = GetParameter(6)
        out_folder = GetParameterAsText(7)
        from arcpy import AddMessage
        for m in [
                in_folder, image_format, pixel_depth, num_bands,
                product_definition, product_band_definitions, pixel_size,
                out_folder
        ]:
            AddMessage(m)
    main()
    debug = False
    if debug:
        # Set local variables
        in_mosaic_dataset = r'C:\Users\geof7015\Documents\ArcGIS\Projects\Leveraging_LiDAR\scratch\SurfaceRasters\SurfaceMosaics.gdb\DTM'
        resampling_type = "BILINEAR"  # "NEAREST", "BILINEAR", "CUBIC", "MAJORITY"
        input_spatial_reference = ""
        out_spatial_reference_string = "WGS 1984"
        geographic_transform = "NAD_1983_To_WGS_1984_5"
        file_extension = "tif"
        out_directory = r''
        out_mosaic_dataset = r''
        # System Parameters
        out_spatial_reference = SpatialReference(out_spatial_reference_string)
    else:
        from arcpy import GetParameterAsText
        in_mosaic_dataset = GetParameterAsText(0)

        input_spatial_reference = arcpy.SpatialReference()
        input_spatial_reference.loadFromString(GetParameterAsText(1))

        out_spatial_reference = arcpy.SpatialReference()
        out_spatial_reference.loadFromString(GetParameterAsText(2))

        geographic_transform = GetParameterAsText(3)
        resampling_type = GetParameterAsText(4)
        file_extension = GetParameterAsText(5)
        out_directory = GetParameterAsText(6)
        out_mosaic_dataset = GetParameterAsText(7)

        AddMessage(input_spatial_reference)
        AddMessage(out_spatial_reference)
Exemplo n.º 19
0
import kml_repair

from arcpy import GetParameterAsText, AddMessage
from kml_repair import check_kml

inputPath = GetParameterAsText(0)
targetPath = GetParameterAsText(1)

def execute(source, target):
    # force ArcGIS to reload the module on every execution of the script
    reload(kml_repair)
    check_kml(source, target)

execute(inputPath, targetPath) 
    
AddMessage("Process completed")
Exemplo n.º 20
0
                    Delete(folder)

        # Check back in 3D Analyst license
        CheckInExtension("3D")
    except LicenseError:
        AddError("3D Analyst license is unavailable")
        print("3D Analyst license is unavailable")
    except ExecuteError:
        print(GetMessages(2))


if __name__ == "__main__":
    debug = False
    if debug:
        # Input User Parameters
        in_buildings = r'C:\Users\geof7015\Documents\ArcGIS\Projects\Ohio_LiDAR_Demo\Ohio_LiDAR_Demo.gdb\Building_3D_manual'
        tile_fid = 'FID_tiles'
        out_format = "DAE"  # "Multipatch GDB", "Multipatch SHP", "DAE"
        zip_files = False
        out_folder = r'C:\Users\geof7015\Documents\ArcGIS\Projects\Ohio_LiDAR_Demo\test'
        out_file_basename = "bldg"
    else:
        from arcpy import GetParameterAsText
        in_buildings = GetParameterAsText(0)
        tile_fid = GetParameterAsText(1)
        out_format = GetParameterAsText(2)
        zip_files = make_boolean(GetParameterAsText(3))
        out_folder = GetParameterAsText(4)
        out_file_basename = GetParameterAsText(5)
    process()
Exemplo n.º 21
0
from arcpy import GetParameterAsText, AddMessage
from esri2open import toOpen
from os import path, sep


def getName(feature):
    name = path.splitext(path.split(feature)[1])
    if name[1]:
        if name[1] == ".shp":
            return name[0]
        else:
            return name[1][1:]
    else:
        return name[0]


features = GetParameterAsText(0).split(";")
outFolder = GetParameterAsText(1)
outType = GetParameterAsText(2)
includeGeometries = ("geojson" if (GetParameterAsText(3) == "Default") else
                     GetParameterAsText(3)).lower()
for feature in features:
    if feature[0] in ("'", '"'):
        feature = feature[1:-1]
    outName = getName(feature)
    outPath = "{0}{1}{2}.{3}".format(outFolder, sep, outName, outType)
    if path.exists(outPath):
        AddMessage("{0} exists, skipping".format(outName))
        continue
    AddMessage("starting {0}".format(outName))
    toOpen(feature, outPath, includeGeometries)
Exemplo n.º 22
0
import time
from time import gmtime, strftime

from arcpy import env, Describe, GetMessages, GetParameterAsText, ListFeatureClasses, Project_management, SpatialReference

# Start script
start_time = time.time()

# Get the parameters of project2 tool
input_folder = GetParameterAsText(0)
input_file = GetParameterAsText(1)

# input_folder = "C:\\learnPython\\data\\lesson2"
# input_file = "C:\\learnPython\\data\\lesson2\\StateRoutes.shp"

print("Executing: Project2 tool " + str(input_folder) + " " + str(input_file))
print("Start Time: " + strftime("%a, %d %b %Y %H:%M:%S 2016", gmtime()))
print("Running a script Project2-Batch-reprojection-tool-for-vector-datasets")
# Get a list of all feature classes in the standard folder
env.workspace = input_folder
featureClass = ListFeatureClasses()

# Get spatial reference of standard file
desc_standard_file = Describe(input_file)
sr_standard_file = desc_standard_file.SpatialReference

# list for keep the reproject files names
l = []
try:

    # Loop through all feature classes in standard folder
'''
peakflow2_tbx.py

ArcToolbox script interface to the peak flow tool.

Includes an additional argument for inputing a pre-calculated basin layer, which speeds up the execution time.
'''

from arcpy import GetParameterAsText
from logic import main

main(inlets=GetParameterAsText(0),
     pour_point_field=GetParameterAsText(1),
     input_watershed_raster=GetParameterAsText(2),
     flow_dir_raster=GetParameterAsText(3),
     slope_raster=GetParameterAsText(4),
     cn_raster=GetParameterAsText(5),
     precip_table_noaa=GetParameterAsText(6),
     output=GetParameterAsText(7),
     output_catchments=GetParameterAsText(8))
Exemplo n.º 24
0
        del duplicates_list
        del duplicates

        # Check back in 3D Analyst license
        CheckInExtension("3D")
    except LicenseError:
        AddError("3D Analyst license is unavailable")
        print("3D Analyst license is unavailable")
    except ExecuteError:
        AddError("3D Analyst license is unavailable")
        print(GetMessages(2))


if __name__ == "__main__":
    debug = False
    if debug:
        # User Input Parameters
        in_buildings = r'C:\Users\geof7015\Documents\ArcGIS\Projects\Ohio_LiDAR_Demo\Ohio_LiDAR_Demo.gdb\Building_3D_manual'
        building_fid = "bldg_fid"
        in_tiles = r'C:\Users\geof7015\Documents\ArcGIS\Projects\Leveraging_LiDAR\tiles\tiles.shp\tiles'
        tile_fid = 'FID_tiles'
        file_name = 'FileName'
    else:
        from arcpy import GetParameterAsText
        in_buildings = GetParameterAsText(0)
        building_fid = GetParameterAsText(1)
        in_tiles = GetParameterAsText(2)
        tile_fid = GetParameterAsText(3)
        file_name = GetParameterAsText(4)
    process()
Exemplo n.º 25
0
def main():
    #get parameters from a tool interface
    id1 = GetParameterAsText(0)
    title = GetParameterAsText(1)
    description = GetParameterAsText(2)
    projection = GetParameterAsText(3)
    dataTitles = GetParameterAsText(4)
    dataTypes = GetParameterAsText(5)
    dataDownloads = GetParameterAsText(6)
    services = GetParameterAsText(7)
    metadata = GetParameterAsText(8)
    dataCategory = GetParameterAsText(9)
    documentations = GetParameterAsText(10)
    dataCreator = GetParameterAsText(11)
    webLink = GetParameterAsText(12)
    tags = GetParameterAsText(13)
    geoJSONLink = GetParameterAsText(14)
    thumbnailUrl = GetParameterAsText(15)
    existingfile = GetParameterAsText(16)

    #create download list in proper format
    DL_list = ""
    if dataTitles != "":
        dataTitlesList = dataTitles.split(",")
        dataTypesList = dataTypes.split(",")
        dataDownloadsList = dataDownloads.split(",")

        DL_list = "["
        for dt in dataTitlesList:
            i = dataTitlesList.index(dt)
            DL_list += '{"DataTitle":"' + dt.strip() + '","DataType":"' + dataTypesList[i].strip() + '","url":"' + dataDownloadsList[i].strip() + '"},'

        DL_list = DL_list[:-1] + "]"

    #put services in a list
    service_list = ""
    if services != "":
        servicesList = services.split(",")
        for s in servicesList:
            service_list += '"' + s.strip() + '",'

        service_list = service_list[:-1]

    #put documentation in a list
    doc_list = ""
    if documentations != "":
        docList = documentations.split(",")
        for d in docList:
            doc_list += '"' + d.strip() + '",'

        doc_list = doc_list[:-1]

    #format tags
    tag_list = ""
    if tags != "":
        tagList = tags.split(",")
        for t in tagList:
            tag_list += '"' + t.strip() + '",'

        tag_list = tag_list[:-1]

    entryObject = jsonEntry(id1, title, description, projection, DL_list, service_list, metadata, dataCategory, doc_list, dataCreator, webLink, tag_list, geoJSONLink, thumbnailUrl)

    jsonText = object2Json(entryObject)

    addEntry(existingfile, jsonText)
Exemplo n.º 26
0
        except s3_client.exceptions.NoSuchBucket:
            AddError('Aws bucket %s does not exist' % bucket_name)
            raise ValueError('Aws bucket %s does not exist' % bucket_name)
        # Check back in Image Analyst license
        CheckInExtension("ImageAnalyst")
    except LicenseError:
        AddError("ImageAnalyst license is unavailable")
        print("ImageAnalyst license is unavailable")
    except ExecuteError:
        AddError(GetMessages(2))
        print(GetMessages(2))


if __name__ == "__main__":
    debug = False
    if debug:
        ''''''
        # User Input Variables
        bucket_name = 'pge-mosaicimagery'
        region = 'us-east-1'
        out_spreadsheet = r'C:\Users\geof7015\Documents\GitHub\esri_lidar_3d_management\test\s3_bucket_files3.xlsx'
        list_folders = False
    else:
        from arcpy import GetParameterAsText
        # User Input Variables
        bucket_name = GetParameterAsText(0)
        region = GetParameterAsText(1)
        out_spreadsheet = GetParameterAsText(2)
        list_folders = make_boolean(GetParameterAsText(3))
    process()
Exemplo n.º 27
0
    except ExecuteError:
        print(GetMessages(2))


if __name__ == "__main__":
    debug = False
    if debug:
        in_mosaic_gdb = r'C:\Users\geof7015\Documents\ArcGIS\Projects\ArcGIS_Image_Designer\test\ortho_mosaic.gdb'
        in_texture = r'C:\Users\geof7015\Documents\ArcGIS\Projects\ArcGIS_Image_Designer\Textures\Processed\dune_vegetation_seamless.jpg'
        in_polygon = r'C:\Users\geof7015\Documents\ArcGIS\Projects\ArcGIS_Image_Designer\Galveston\Data\Esri_Processed\Dune_Outline.gdb\Galveston_Dune_Grass_Polys_Projected'
        out_folder = r'C:\Users\geof7015\Documents\ArcGIS\Projects\ArcGIS_Image_Designer\scratch_dunes'
        method = "GaussianBlur"  # "GaussianBlur", "BoxBlur", "None"
        blur_distance = 2  # Distance in Pixels
        pixel_depth = "8_BIT_UNSIGNED"
        num_bands = 3
        product_definition = "NATURAL_COLOR_RGB"
        product_band_definitions = "Red 630 690;Green 530 570;Blue 440 510"
    else:
        from arcpy import GetParameterAsText, GetParameter
        in_mosaic_gdb = GetParameterAsText(0)
        in_texture = GetParameterAsText(1)
        in_polygon = GetParameterAsText(2)
        out_folder = GetParameterAsText(3)
        method = GetParameterAsText(4)  # "GaussianBlur", "BoxBlur", "None"
        blur_distance = GetParameter(5)  # Distance in Pixels
        pixel_depth = GetParameterAsText(6)
        num_bands = GetParameter(7)
        product_definition = GetParameterAsText(8)
        product_band_definitions = GetParameterAsText(9)
    main()
Exemplo n.º 28
0
from arcpy import GetParameterAsText
from esri2open import writeFile, prepareGeoJSON, prepareTOPO, closeJSON, closeTOPOJSON, getExt, getName

#compute the peramaters
features = GetParameterAsText(0).split(";")
outJSON = GetParameterAsText(1)
includeGeometry = "geojson"
fileType = getExt(outJSON)
if fileType == 'geojson':
    prepare = prepareGeoJSON
    closing = closeJSON
elif fileType == 'topojson':
    prepare = prepareTOPO
    closing = closeTOPOJSON
out = prepare(outJSON)
first = True  #this makes sure sure we arn't missing commas
i = 0
for feature in features:
    i += 1
    if feature[0] in ("'", '"'):
        feature = feature[1:-1]
    writeFile(out, feature, fileType, includeGeometry, first, getName(feature))
    first = False
closing(out)
Exemplo n.º 29
0

if __name__ == '__main__':
    debug = False
    if debug:
        ''' Seamless Texture Maps must be the same size as the source image'''
        in_image = r'C:\Users\geof7015\Documents\ArcGIS\Projects\ArcGIS_Image_Designer\TestData\imgFolder\Ortho.jpg'
        in_mask = r'C:\Users\geof7015\Documents\ArcGIS\Projects\ArcGIS_Image_Designer\TestData\maskFolder\dune8TestMask.tif'
        in_texture = r'C:\Users\geof7015\Documents\ArcGIS\Projects\ArcGIS_Image_Designer\Textures\Processed\coastal_steppe.jpg'
        out_image = r'C:\Users\geof7015\Documents\ArcGIS\Projects\ArcGIS_Image_Designer\TestData\test\Da_DuneOrtho.jpg'
        method = "None"  # "GaussianBlur", "BoxBlur", "None"
        blur_distance = 10  # Distance in Pixels
    else:
        from os.path import exists
        from arcpy import GetParameterAsText, GetParameter, AddMessage, AddWarning
        ''' Seamless Texture Maps must be the same size as the source image'''
        in_image = GetParameterAsText(0)
        in_mask = GetParameterAsText(1)
        in_texture = GetParameterAsText(2)
        out_image = GetParameterAsText(3)
        method = GetParameterAsText(4)  # "GaussianBlur", "BoxBlur", "None"
        blur_distance = GetParameter(5)  # Distance in Pixels

        for i in [in_image, in_mask, in_texture]:
            if not exists(i):
                AddWarning("{0} | Detected as non-existing".format(i))
                exit()

        AddMessage(blur_distance)
    main()
Exemplo n.º 30
0
from arcpy import GetParameterAsText
from esri2open import toOpen
from topojson import topojson
from tempfile import mkdtemp
from os import remove, rmdir, path
dr = mkdtemp()
tempfl = dr + path.splitext(path.split(
    GetParameterAsText(1))[1])[0] + '.geojson'
toOpen(GetParameterAsText(0), tempfl, "geojson")
topojson(tempfl, GetParameterAsText(1))
remove(tempfl)
rmdir(dr)
Exemplo n.º 31
0
        pass

    try:
        if CheckExtension("ImageAnalyst") == "Available":
            CheckOutExtension("ImageAnalyst")
        else:
            # raise a custom exception
            raise LicenseError
        subset_image_for_texture(in_image, in_polygon, area, out_image)
        CheckInExtension("ImageAnalyst")
    except LicenseError:
        print("Image Analyst license is unavailable")
    except ExecuteError:
        print(GetMessages(2))


if __name__ == "__main__":
    debug = False
    if debug:
        in_image = r'C:\Users\geof7015\Documents\ArcGIS\Projects\ArcGIS_Image_Designer\TestData\imgFolder\Ortho.jpg'
        in_polygon = r'C:\Users\geof7015\Documents\ArcGIS\Projects\ArcGIS_Image_Designer\ArcGIS_Image_Designer.gdb\subset_polygon'
        area = 400
        out_image = r'C:\Users\geof7015\Documents\ArcGIS\Projects\ArcGIS_Image_Designer\Textures\Unprocessed\test.jpg'
    else:
        from arcpy import GetParameterAsText, GetParameter
        in_image = GetParameterAsText(0)
        in_polygon = GetParameterAsText(1)
        area = GetParameter(2)
        out_image = GetParameterAsText(3)
    main()
    from arcpy import ExecuteError, GetMessages, CheckOutExtension, CheckExtension, CheckInExtension

    class LicenseError(Exception):
        pass

    try:
        if CheckExtension("ImageAnalyst") == "Available":
            CheckOutExtension("ImageAnalyst")
        else:
            # raise a custom exception
            raise LicenseError

        seamless_texture(inImg, outImg)
        CheckInExtension("ImageAnalyst")
    except LicenseError:
        print("Image Analyst license is unavailable")
    except ExecuteError:
        print(GetMessages(2))


if __name__ == '__main__':
    debug = False
    if debug:
        inImg = r'..\Textures\Unprocessed\sand3.jpg'
        outImg = r'..\Textures\Processed\sand3.jpg'
    else:
        from arcpy import GetParameterAsText
        inImg = GetParameterAsText(0)
        outImg = GetParameterAsText(1)
    main()
Exemplo n.º 33
0
from topojson import topojson
from random import randint


def getName(feature):
    name = path.splitext(path.split(feature)[1])
    if name[1]:
        if name[1] == ".shp":
            return name[0]
        else:
            return name[1][1:]
    else:
        return name[0]


features = GetParameterAsText(0).split(";")
outFile = GetParameterAsText(1)
outStuff = {}
tmpdir = mkdtemp()
for feature in features:
    if feature[0] in ("'", '"'):
        feature = feature[1:-1]
    outName = getName(feature)
    outPath = tmpdir + '//' + str(randint(0, 1000000)) + 'temp.geojson'
    if path.exists(outPath):
        remove(outPath)
    toOpen(feature, outPath)
    outStuff[outName] = load(open(outPath))
    remove(outPath)
    #AddMessage(outName)
topo = topojson(outStuff)