Example #1
0
def toOpen(featureClass, outJSON, includeGeometry="geojson"):
    #check the file type based on the extention
    fileType = getExt(outJSON)
    #some sanity checking
    #valid geojson needs features, seriously you'll get an error
    if not int(GetCount_management(featureClass).getOutput(0)):
        AddMessage("No features found, skipping")
        return
    elif not fileType:
        AddMessage("this filetype doesn't make sense")
        return
    #geojson needs geometry
    if fileType == "geojson":
        includeGeometry = "geojson"
    elif fileType == "sqlite":
        includeGeometry = "well known binary"
    else:
        includeGeometry = includeGeometry.lower()
    #open up the file
    outFile = prepareFile(outJSON, featureClass, fileType, includeGeometry)
    #outFile will be false if the format isn't defined
    if not outFile:
        AddMessage("I don't understand the format")
        return
    #write the rows
    writeFile(outFile, featureClass, fileType, includeGeometry)
    #go home
    closeUp(outFile, fileType)
Example #2
0
def toOpen(featureClass, outJSON, includeGeometry="geojson"):
    #check the file type based on the extention
    fileType=getExt(outJSON)
    #some sanity checking
    #valid geojson needs features, seriously you'll get an error
    if not int(GetCount_management(featureClass).getOutput(0)):
        AddMessage("No features found, skipping")
        return
    elif not fileType:
        AddMessage("this filetype doesn't make sense")
        return
    #geojson needs geometry
    if fileType=="geojson":
        includeGeometry="geojson"
    elif fileType=="sqlite":
        includeGeometry="well known binary"
    else:
        includeGeometry=includeGeometry.lower()
    #open up the file
    outFile=prepareFile(outJSON,featureClass,fileType,includeGeometry)
    #outFile will be false if the format isn't defined
    if not outFile:
        AddMessage("I don't understand the format")
        return
    #write the rows
    writeFile(outFile,featureClass,fileType,includeGeometry)
    #go home
    closeUp(outFile,fileType)
Example #3
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)
Example #4
0
from arcpy import GetParameterAsText
from esri2open import writeFile, prepareGeoJSON, closeJSON
#compute the peramaters
features = GetParameterAsText(0).split(";")
outJSON = GetParameterAsText(1)
includeGeometry = "geojson"
fileType = "geojson"
out = prepareGeoJSON(outJSON)
first = True  #this makes sure sure we arn't missing commas
for feature in features:
    if feature[0] in ("'", '"'):
        feature = feature[1:-1]
    writeFile(out, feature, fileType, includeGeometry, first)
    first = False
closeJSON(out)
Example #5
0
from arcpy import GetParameterAsText
from esri2open import writeFile, prepareGeoJSON, closeJSON
#compute the peramaters
features = GetParameterAsText(0).split(";")
outJSON=GetParameterAsText(1)
includeGeometry = "geojson"
fileType = "geojson"
out=prepareGeoJSON(outJSON)
first=True#this makes sure sure we arn't missing commas
for feature in features:
    if feature[0] in ("'",'"'):
        feature = feature[1:-1]
    writeFile(out,feature,fileType,includeGeometry, first)
    first=False
closeJSON(out)
Example #6
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)