POST
|
OK I got the polygon to draw... Needed RINGS: vertices, Just need to figure out the point geometry: {
type: "polygon",
rings: vertices,
spatialReference: view.spatialReference
},
... View more
09-08-2022
10:48 AM
|
0
|
0
|
1411
|
POST
|
OK I am trying this solution... It has the Line working I am now trying to incorporate the Polygon add... Not sure where I am failing <html>
<head>
<meta charset="utf-8" />
<meta name="viewport"
content="initial-scale=1,maximum-scale=1,user-scalable=no" />
<title>Draw polyline | Sample | ArcGIS API for JavaScript 4.24</title>
<link rel="stylesheet" href="https://js.arcgis.com/4.24/esri/themes/light/main.css" />
<script src="https://js.arcgis.com/4.24/"></script>
<style>
html,
body,
#viewDiv {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
</style>
<script>
require([
"esri/Map",
"esri/views/MapView",
"esri/views/draw/Draw",
"esri/Graphic",
"esri/geometry/geometryEngine"
], (Map, MapView, Draw, Graphic, geometryEngine) => {
const map = new Map({
basemap: "gray-vector"
});
const view = new MapView({
container: "viewDiv",
map: map,
zoom: 15,
center: [18.06, 59.34]
});
// add the button for the draw tool
view.ui.add("line-button", "top-left");
view.ui.add("point-button", "top-left");
view.ui.add("polygon-button", "top-left");
const draw = new Draw({
view: view
});
document.getElementById("polygon-button").onclick = () => {
view.graphics.removeAll();
// creates and returns an instance of PolyLineDrawAction
const action = draw.create("polygon");
// focus the view to activate keyboard shortcuts for sketching
view.focus();
// listen polylineDrawAction events to give immediate visual feedback
// to users as the line is being drawn on the view.
action.on(
[
"vertex-add",
"vertex-remove",
"cursor-update",
"redo",
"undo",
"draw-complete"
],
updateVerticesPolygon
);
};
// draw polyline button
document.getElementById("line-button").onclick = () => {
view.graphics.removeAll();
// creates and returns an instance of PolyLineDrawAction
const action = draw.create("polyline");
// focus the view to activate keyboard shortcuts for sketching
view.focus();
// listen polylineDrawAction events to give immediate visual feedback
// to users as the line is being drawn on the view.
action.on(
[
"vertex-add",
"vertex-remove",
"cursor-update",
"redo",
"undo",
"draw-complete"
],
updateVerticesLine
);
};
// Checks if the last vertex is making the line intersect itself.
function updateVerticesPolygon(event) {
// create a polyline from returned vertices
if (event.vertices.length > 1) {
const result = createGraphicPolygon(event);
}
}
function updateVerticesLine(event) {
// create a polyline from returned vertices
if (event.vertices.length > 1) {
const result = createGraphicLine(event);
// if the last vertex is making the line intersects itself,
// prevent the events from firing
if (result.selfIntersects) {
event.preventDefault();
}
}
}
// create a new graphic presenting the polyline that is being drawn on the view
function createGraphicPolygon(event) {
const vertices = event.vertices;
view.graphics.removeAll();
// a graphic representing the polyline that is being drawn
const graphicPoly = new Graphic({
geometry: {
type: "polygon",
paths: vertices,
spatialReference: view.spatialReference
},
symbol: {
type: "simple-fill", // autocasts as new SimpleFillSymbol
color: [227, 139, 79, 0.8],
outline: {
color: [255, 255, 255],
width: 1
}
}
});
view.graphics.add(graphicPoly);
}
function createGraphicLine(event) {
const vertices = event.vertices;
view.graphics.removeAll();
// a graphic representing the polyline that is being drawn
const graphicLine = new Graphic({
geometry: {
type: "polyline",
paths: vertices,
spatialReference: view.spatialReference
},
symbol: {
type: "simple-line", // autocasts as new SimpleFillSymbol
color: [4, 90, 141],
width: 4,
cap: "round",
join: "round"
}
});
// check if the polyline intersects itself.
const intersectingSegment = getIntersectingSegment(graphicLine.geometry);
// Add a new graphic for the intersecting segment.
if (intersectingSegment) {
view.graphics.addMany([graphicLine, intersectingSegment]);
}
// Just add the graphic representing the polyline if no intersection
else {
view.graphics.add(graphicLine);
}
// return intersectingSegment
return {
selfIntersects: intersectingSegment
};
}
// function that checks if the line intersects itself
function isSelfIntersecting(polyline) {
if (polyline.paths[0].length < 3) {
return false;
}
const line = polyline.clone();
//get the last segment from the polyline that is being drawn
const lastSegment = getLastSegment(polyline);
line.removePoint(0, line.paths[0].length - 1);
// returns true if the line intersects itself, false otherwise
return geometryEngine.crosses(lastSegment, line);
}
// Checks if the line intersects itself. If yes, change the last
// segment's symbol giving a visual feedback to the user.
function getIntersectingSegment(polyline) {
if (isSelfIntersecting(polyline)) {
return new Graphic({
geometry: getLastSegment(polyline),
symbol: {
type: "simple-line", // autocasts as new SimpleLineSymbol
style: "short-dot",
width: 3.5,
color: "yellow"
}
});
}
return null;
}
// Get the last segment of the polyline that is being drawn
function getLastSegment(polyline) {
const line = polyline.clone();
const lastXYPoint = line.removePoint(0, line.paths[0].length - 1);
const existingLineFinalPoint = line.getPoint(
0,
line.paths[0].length - 1
);
return {
type: "polyline",
spatialReference: view.spatialReference,
hasZ: false,
paths: [
[
[existingLineFinalPoint.x, existingLineFinalPoint.y],
[lastXYPoint.x, lastXYPoint.y]
]
]
};
}
});
</script>
</head>
<body>
<!-- https://developers.arcgis.com/javascript/latest/esri-icon-font/ -->
<div id="viewDiv">
<div id="point-button" class="esri-widget esri-widget--button esri-interactive" title="Draw point">
<span class="esri-icon-map-pin"></span>
</div>
<div id="line-button" class="esri-widget esri-widget--button esri-interactive" title="Draw polyline">
<span class="esri-icon-polyline"></span>
</div>
<div id="polygon-button" class="esri-widget esri-widget--button esri-interactive" title="Draw polygon">
<span class="esri-icon-polygon"></span>
</div>
</div>
</body>
</html>
... View more
09-08-2022
10:30 AM
|
0
|
1
|
1415
|
POST
|
I am trying to have a simple map and: Allow the user to draw a point, line, or polygon. Although just 1. I then need to buffer this feature I then need to capture its geometry so I can send that as a parameter to a GP Tool I looked at this widget https://developers.arcgis.com/javascript/latest/sample-code/sketch-geometries/ but could not figure out how to limit it to one geometry in the graphics layer. I assume that I could just remove all features every time the user clicks the map. Or someway to disable the widget after each feature creation in the map (Then deleting all features next time the widget is used?) I am not sure the widget is the way to go and looking for some thoughts or examples for this. The widget stores geometry in the graphics layer so If I could control the layer to only have 1 feature at a time I could query the graphics layer for its geometry.... Thoughts?
... View more
09-08-2022
10:01 AM
|
0
|
3
|
1437
|
POST
|
@ReneRubalcava Yea thanks... I was looking at the definitionExpression but my workflow lead me in this direction... Cheers. And thanks for the input
... View more
08-24-2022
11:06 AM
|
0
|
0
|
1907
|
POST
|
Fantastic... thanks so much ... SO - Am I correct to assume that this approach does now load all the points until the query is done and then and only then does it display the two points that are being shown
... View more
08-24-2022
09:15 AM
|
0
|
1
|
1920
|
POST
|
when I do this I get all the features displaying in the map not the 2 that where returned from the query. I dont want to show all the features JUST the ones that are returned from the query. I want to query the Main RestEndpoint and grab the two records and then push them to a graphics layer. So this way I don have to display ALL the values at ANY point.
... View more
08-24-2022
08:55 AM
|
0
|
4
|
1930
|
POST
|
I added a graphics layer and tried to add the results to that... Modifyed from original script above <html>
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="initial-scale=1,maximum-scale=1,user-scalable=no"
/>
<title>
Basic Querying in FeatureLayer | Sample | ArcGIS API for JavaScript 4.24
</title>
<link
rel="stylesheet"
href="https://js.arcgis.com/4.24/esri/themes/light/main.css"
/>
<script src="https://js.arcgis.com/4.24/"></script>
<style>
html,
body,
#viewDiv {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
#optionsDiv {
background-color: white;
color: black;
padding: 6px;
max-width: 400px;
}
</style>
<script>
require([
"esri/Map","esri/Graphic","esri/views/MapView","esri/layers/FeatureLayer",
"esri/widgets/Legend","esri/rest/support/Query", "esri/layers/GraphicsLayer"
], (Map, Graphic, MapView, FeatureLayer, Legend, Query, GraphicsLayer) => {
var graphicA = new Graphic();
var layerGraphics = new GraphicsLayer({
graphics: [graphicA]
});
const layer = new FeatureLayer({
url: "https://servicesdev.dwr.virginia.gov/arcgis/rest/services/CWSS/AquaDB_Locations/FeatureServer/0",
outFields: ["*"]
});
const map = new Map({
basemap: "gray-vector", //,
layers: [layerGraphics]
});
const view = new MapView({
container: "viewDiv",
map: map,
});
layer.load().then(() => {
queryFeatures1();
});
function queryFeatures1() {
var collectionIDvalue1 = '123';
var collectionIDvalue2 = '124';
var collectionIDstring = "CollectionID = " + "'" + collectionIDvalue1 + "'";
const layer = new FeatureLayer({
url: "https://servicesdev.dwr.virginia.gov/arcgis/rest/services/CWSS/AquaDB_Locations/FeatureServer/0"
});
const query = new Query();
query.where = collectionIDstring;
query.returnGeometry = true;
query.outFields = [ "CollectionID", "GlobalID" ];
layer.queryFeatureCount(query)
.then(function(numResults){
alert("There are " + numResults + " return from this query");
});
layer.queryFeatures(query)
.then((results) => {
var countFeatures = results.features.length;
alert("Feature count: " + countFeatures);
displayResults(results);
}).catch((error) => {
console.log(error.error);
});
}
function displayResults(results) {
// Create a blue polygon
const symbol = {
type: "simple-fill",
color: [ 20, 130, 200, 0.5 ],
outline: {
color: "white",
width: .5
},
};
const popupTemplate = {
title: "Locations {OBJECTID}",
content: "ObjectID: {OBJECTID} <br> Collection ID: {CollectionID}"
};
// Assign styles and popup to features
results.features.map((feature) => {
feature.symbol = symbol;
feature.popupTemplate = popupTemplate;
return feature;
});
// Clear display
//view.popup.close();
//view.graphics.removeAll();
//// Add features to graphics layer
//view.graphics.addMany(results.features);
view.popup.close();
view.layerGraphics.removeAll();
// Add features to graphics layer
view.layerGraphics.addMany(results.features);
}
});
</script>
</head>
<body>
<div id="viewDiv"></div>
</body>
</html>
... View more
08-24-2022
08:37 AM
|
0
|
1
|
1937
|
POST
|
I am tryin to piece together a few example and simply trying to query a Rest Endpoint and display those records that are returned. I am using the scrip below. I get the correct number of results returned but can get them to display. Any thoughts to why? <html>
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="initial-scale=1,maximum-scale=1,user-scalable=no"
/>
<title>
Basic Querying in FeatureLayer | Sample | ArcGIS API for JavaScript 4.24
</title>
<link
rel="stylesheet"
href="https://js.arcgis.com/4.24/esri/themes/light/main.css"
/>
<script src="https://js.arcgis.com/4.24/"></script>
<style>
html,
body,
#viewDiv {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
#optionsDiv {
background-color: white;
color: black;
padding: 6px;
max-width: 400px;
}
</style>
<script>
require([
"esri/Map","esri/Graphic","esri/views/MapView","esri/layers/FeatureLayer",
"esri/widgets/Legend","esri/rest/support/Query"
], (Map, Graphic, MapView, FeatureLayer, Legend, Query) => {
const map = new Map({
basemap: "gray-vector"
});
const view = new MapView({
container: "viewDiv",
map: map,
});
layer.load().then(() => {
queryFeatures1();
});
function queryFeatures1() {
var collectionIDvalue1 = '123';
var collectionIDvalue2 = '124';
var collectionIDstring = "CollectionID = " + "'" + collectionIDvalue1 + "'";
const layer = new FeatureLayer({
url: "https://servicesdev.dwr.virginia.gov/arcgis/rest/services/CWSS/AquaDB_Locations/FeatureServer/0"
});
const query = new Query();
query.where = collectionIDstring;
query.returnGeometry = true;
query.outFields = [ "CollectionID", "GlobalID" ];
layer.queryFeatureCount(query)
.then(function(numResults){
alert("There are " + numResults + " return from this query");
});
layer.queryFeatures(query)
.then((results) => {
var countFeatures = results.features.length;
alert("Feature count: " + countFeatures);
displayResults(results);
}).catch((error) => {
console.log(error.error);
});
}
function displayResults(results) {
// Create a blue polygon
const symbol = {
type: "simple-fill",
color: [ 20, 130, 200, 0.5 ],
outline: {
color: "white",
width: .5
},
};
const popupTemplate = {
title: "Locations {OBJECTID}",
content: "ObjectID: {OBJECTID} <br> Collection ID: {CollectionID}"
};
// Assign styles and popup to features
results.features.map((feature) => {
feature.symbol = symbol;
feature.popupTemplate = popupTemplate;
return feature;
});
// Clear display
view.popup.close();
view.graphics.removeAll();
// Add features to graphics layer
view.graphics.addMany(results.features);
}
});
</script>
</head>
<body>
<div id="viewDiv"></div>
</body>
</html>
... View more
08-24-2022
08:24 AM
|
0
|
8
|
1945
|
POST
|
OK that makes me happy that it was not me but annoyed this is a 7 year bug OK so I think I should be able to: Delete Features from my Enterprise GDB FC Read my file geodatabase FC Append it to the Enterprise Geodatabase FC Work around but think it will work
... View more
08-09-2022
12:39 PM
|
1
|
0
|
1556
|
POST
|
@Anonymous User ok so I name the file without DB and DBO This is the full code without removing anything.... Still getting this stupid error... File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 512, in <lambda> return lambda *args: val(*gp_fixargs(args, True)) arcgisscripting.ExecuteError: ERROR 000206: Cannot create FeatureClass 'E:\ArcGIS_Server_aws\ArcGIS_Published_MXDs\BirdingTrail\vdwrdwradminjkVBWTRack30.sde\VBWT.DBO.testNew55'. Underlying DBMS error [[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Violation of PRIMARY KEY constraint 'R15_pk'. Cannot insert duplicate key in object 'dbo.TESTNEW55'. The duplicate key value is (0).] [VBWT.DBO.testNew55] Failed to execute (JSONToFeatures). I am baffled as to why it will not write to the SDE DB import arcpy
import json
import uuid
import os
import re
import requests
# SCRIPT GLOBAL VARIABLES
arcpy.env.workspace = 'E:/ArcGIS_Server_aws/ArcGIS_Published_MXDs/BirdingTrail/'
fsURL = "https://dwr.virginia.gov/-/api/v1/vbwt-sites"
dataInput = r"E:/ArcGIS_Server_aws/ArcGIS_Published_MXDs/BirdingTrail/JSON_New4.json"
output_fc = r"E:/ArcGIS_Server_aws/ArcGIS_Published_MXDs/BirdingTrail/vdwrdwradminjkVBWTRack30.sde/testNew55"
fld_dict = {}
new_dict = {}
converted_list = []
p_tag = re.compile(r'.*?>(.*)<')
def main():
# Read URL and truncate long fields
readURL()
# delete existing Feature Classes
deleteExistingFC()
def readURL():
r3 = requests.get(fsURL)
data = json.loads(r3.text)
print("")
print("There are: " + str(len(data)) + " records")
print("")
# Added this So I could use it in the For loop
data1 = {"BirdTrailLocations": data }
for i in data1['BirdTrailLocations']:
feat_dict = {}
feat_dict["geometry"] = {"x": i["site_longitude"], "y": i["site_latitude"]}
## the list created a value type is incompatible with the field type. [site_facilities] so we nee dto convert it to a string
fixSiteFacilities = str(i["site_facilities"])
newValSiteFacilities = fixSiteFacilities.replace("u'", "").replace('[', '').replace(']', '').replace(r"'", r'')
stringTrunSiteFacitlities = newValSiteFacilities[0:255]
i["site_facilities"] = str(stringTrunSiteFacitlities)
# Truncate Site Access
fixSiteAccess = str(i["site_access"])
newValSiteaccess = fixSiteAccess.replace("u'", "'").replace('[', '').replace(']', '').replace(r"'", r'')
stringTrunSiteAccess = newValSiteaccess[0:255]
i["site_access"] = (stringTrunSiteAccess)
# Truncate Site Description
varSiteDescription = str(i["site_description"])
stringTrunSiteDescription = varSiteDescription[0:255]
i["site_description"] = (stringTrunSiteDescription)
# Truncate Site Directions
varSiteDirections = str(i["site_directions"])
stringTrunSiteDirections = varSiteDirections[0:255]
i["site_directions"] = (stringTrunSiteDirections)
# Truncate Website
correctedWebsite = str(i["site_website"])
newWebsiteVal = re.sub(r'/', r'\\', correctedWebsite)
newWebsiteVal = newWebsiteVal.replace('\\\\', '\\')
newWebsiteVal2 = newWebsiteVal[0:255]
i["site_website"] = newWebsiteVal2
feat_dict["attributes"] = i
converted_list.append(feat_dict)
new_dict = {"geometryType" : "esriGeometryPoint",
"spatialReference" : {"wkid" : 4326},
'fields': [{"name": str(k), "type": "esriFieldTypeString", "alias": str(k), "length": 255} for k, v in data[0].items()],
'features': converted_list}
# write this truncated capture to a local file for further processing this is a requirement for this to work per ESRI
writeLocalFileURLText(new_dict)
def writeLocalFileURLText(urlResults):
new_dict = urlResults
print (new_dict)
with open(dataInput, 'w') as f:
json.dump(new_dict, f)
def deleteExistingFC():
arcpy.env.workspace = r"E:/ArcGIS_Server_aws/ArcGIS_Published_MXDs/BirdingTrail/vdwrdwradminjkVBWTRack30.sde"
arcpy.env.overwriteOutput = True
arcpy.JSONToFeatures_conversion(dataInput, output_fc)
arcpy.env.overwriteOutput = False
if __name__ =="__main__":
main()
... View more
08-09-2022
10:34 AM
|
0
|
0
|
1276
|
POST
|
@BrianWilsonthe crazy thing is this code works fine when I WRITE to a File Geodatabase.
... View more
08-09-2022
09:52 AM
|
0
|
1
|
1283
|
POST
|
@Anonymous User- Ok so this is working off the solution you helped me with last week. now just trying to tweak to write to a Enterprise SDE Database. 1. read from URL 2. write to local JSON file 3. JSONtoFeatures (Local JSON file , New Output Feature Class) I am not doing anything crazy with the File name. Is there a character limit in the Connection File String? THIS WORKS if I write to a local File Geodatabase. import arcpy
import json
import uuid
import os
import re
import requests
# SCRIPT GLOBAL VARIABLES
arcpy.env.workspace = 'E:/ArcGIS_Server/ArcGIS/Trail/'
fsURL = "https://dwr.virginia.gov/-/api/v1/vbwt-sites"
dataInput = "E:/ArcGIS_Server/ArcGIS/Trail/JSON_New4.json"
output_fc = "E:/ArcGIS_Server/AdminConnectionFile.sde/Trail.DBO.VABWTS"
inFeatures = "VABWTS"
tempLayer = "testLayer"
fld_dict = {}
new_dict = {}
converted_list = []
def main():
# Read URL and truncate long fields
readURL()
# Add New Feature Class
addNewFC()
def readURL():
r3 = requests.get(fsURL)
data = json.loads(r3.text)
# Added this So I could use it in the For loop
data1 = {"BirdTrailLocations": data }
for i in data1['BirdTrailLocations']:
feat_dict = {}
feat_dict["geometry"] = {"x": i["site_longitude"], "y": i["site_latitude"]}
feat_dict["attributes"] = i
converted_list.append(feat_dict)
new_dict = {"geometryType" : "esriGeometryPoint",
"spatialReference" : {"wkid" : 4326},
'fields': [{"name": str(k), "type": "esriFieldTypeString", "alias": str(k), "length": 255} for k, v in data[0].items()],
'features': converted_list}
# write this truncated capture to a local file for further processing this is a requirement for this to work per ESRI
writeLocalFileURLText(new_dict)
def writeLocalFileURLText(urlResults):
new_dict = urlResults
print (new_dict)
with open(dataInput, 'w') as f:
json.dump(new_dict, f)
def addNewFC():
arcpy.env.overwriteOutput = True
arcpy.JSONToFeatures_conversion(dataInput, output_fc)
arcpy.env.overwriteOutput = False
ERROR: Traceback (most recent call last): File "E:\ArcGIS_Server\ArcGIS\Trail\AddPoints_w_changeFieldTypes3.py", line 403, in <module> main() File "E:\ArcGIS_Server\ArcGIS\Trail\AddPoints_w_changeFieldTypes3.py", line 49, in main deleteExistingFC() File "E:\ArcGIS_Server\ArcGIS\Trail\AddPoints_w_changeFieldTypes3.py", line 144, in deleteExistingFC arcpy.JSONToFeatures_conversion(dataInput, output_fc) File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\conversion.py", line 1171, in JSONToFeatures raise e File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\conversion.py", line 1168, in JSONToFeatures retval = convertArcObjectToPythonObject(gp.JSONToFeatures_conversion(*gp_fixargs((in_json_file, out_features, geometry_type), True))) File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 512, in <lambda> return lambda *args: val(*gp_fixargs(args, True)) arcgisscripting.ExecuteError: ERROR 000206: Cannot create FeatureClass 'E:\ArcGIS_Server\AdminConnectionFile.sde\Trail.DBO.VABWTS'. Underlying DBMS error [[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Violation of PRIMARY KEY constraint 'R34_pk'. Cannot insert duplicate key in object 'dbo.VABWTS'. The duplicate key value is (0).] [BirdingTrail.DBO.VABWTS] Failed to execute (JSONToFeatures).
... View more
08-09-2022
09:39 AM
|
0
|
2
|
1289
|
POST
|
I have been successful in writing to a File Geodatabase using JSONtoFeature in python But now I am trying to write to an Enterprise GDB and having issues. I added the Connection File that has Admin Rights for this test. So should be good to go there. Thoughts? Noting that just before this I am trying to DELETE the existing FC using this fc_Delete = ["Data_Staging"]
for fc in fc_Delete:
fc_path = os.path.join(cws, fc)
if arcpy.Exists(fc_path):
arcpy.Delete_management(fc_path) FILE GEODATABASE - this works dataOutput = r"C:/Users/t/Desktop/JSONSamples/INPUTJSONFILE.json"
output_fc = r'C:\\Users\\t\\Desktop\\JSONSamples\\outgdb.gdb\test'
arcpy.JSONToFeatures_conversion(dataInput, output_fc) ENTERPRISE GEODATABASE - not working dataInput = r"E:/ArcGIS_Server/ArcGIS/Trail/INPUTJSONFILE.json"
output_fc = r"E:/ArcGIS_Server/ArcGIS/Trail/ConnectionFile.sde/Data_Staging"
arcpy.JSONToFeatures_conversion(dataInput, output_fc) ERROR: Traceback (most recent call last): File "E:\ArcGIS_Server_aws\ArcGIS_Published_MXDs\BirdingTrail\AddPoints_w_changeFieldTypes3.py", line 395, in <module> main() File "E:\ArcGIS_Server_aws\ArcGIS_Published_MXDs\BirdingTrail\AddPoints_w_changeFieldTypes3.py", line 43, in main deleteExistingFC() File "E:\ArcGIS_Server_aws\ArcGIS_Published_MXDs\BirdingTrail\AddPoints_w_changeFieldTypes3.py", line 137, in deleteExistingFC arcpy.JSONToFeatures_conversion(dataInput, output_fc) File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\conversion.py", line 1171, in JSONToFeatures raise e File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\conversion.py", line 1168, in JSONToFeatures retval = convertArcObjectToPythonObject(gp.JSONToFeatures_conversion(*gp_fixargs((in_json_file, out_features, geometry_type), True))) File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 512, in <lambda> return lambda *args: val(*gp_fixargs(args, True)) arcgisscripting.ExecuteError: ERROR 000206: Cannot create FeatureClass 'E:/ArcGIS_Server/ArcGIS/Trail/ConnectionFile.sde/Data_Staging'. Underlying DBMS error [[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Violation of PRIMARY KEY constraint 'R23_pk'. Cannot insert duplicate key in object 'dbo.Data_Staging'. The duplicate key value is (0).] [Trail.DBO.Data_Staging] Failed to execute (JSONToFeatures).
... View more
08-09-2022
08:26 AM
|
0
|
11
|
1605
|
POST
|
OK so here is where I am currently at. I am pretty confused why this is not working.... Below are my 4 options when I go to run the .py file Code This is the URL I am using import arcpy
import requests
import json
import uuid
from urllib.request import urlopen
import urllib
import requests
url = "https://dwr.virginia.gov/-/api/v1/vbwt-sites/"
response = urlopen(url)
data_json = json.loads(response.read)
print (data_json) 1st Option - Edit with IDLE This open it in IDLE 2.7 which was a prior install of python that is on this computer Error - Traceback (most recent call last): File "C:\Users\tjv36463\Desktop\JSONSamples\readJson.py", line 5, in <module> from urllib.request import urlopen ImportError: No module named request 2nd Option - Edit with IDLE (ArcGIS Pro) If I choose this option Error - Traceback (most recent call last): File "C:\Users\tjv36463\Desktop\JSONSamples\readJson.py", line 13, in <module> response = urlopen(url) File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\urllib\request.py", line 222, in urlopen return opener.open(url, data, timeout) File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\urllib\request.py", line 531, in open response = meth(req, response) File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\urllib\request.py", line 641, in http_response 'http', request, response, code, msg, hdrs) File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\urllib\request.py", line 569, in error return self._call_chain(*args) File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\urllib\request.py", line 503, in _call_chain result = func(*args) File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\urllib\request.py", line 649, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 403: Forbidden 3rd Option - Edit with IDLE (Edit with IDLE 3.10 (64-bit)) The 3rd options opens in this Error - Traceback (most recent call last): File "C:\Users\tjv36463\Desktop\JSONSamples\readJson.py", line 1, in <module> import arcpy ModuleNotFoundError: No module named 'arcpy' If I run it from PYTHON command prompt I get this
... View more
08-08-2022
06:01 AM
|
0
|
3
|
3191
|
POST
|
OK I was able to go into the terminal under GIS and do PIP LIST Then went to install urllib3 and says that its already satisfied Let me step back a bit I am running this little snip of code from a file with .py extension through the IDLE interface. I am not running this via ArcGIS Pro. I want to be able to put this .py file on the network and write a .bat file to run in task scheduler. I could be going about this the wrong way ... It says below that the requirement is already satisfied but when I run through IDLE it give me that error. This is a learning curve and I thank you for your patience and input. Cheers So maybe as you stated I need to make sure the IDLE interface is pointed to ArcGIS Pro or the correct python install as there is still older versions on this computer - not sure how to check or do that.
... View more
08-05-2022
12:58 PM
|
0
|
5
|
3215
|
Title | Kudos | Posted |
---|---|---|
1 | 09-15-2022 11:02 AM | |
1 | 05-21-2021 07:35 AM | |
1 | 08-09-2022 12:39 PM | |
1 | 11-10-2016 11:20 AM | |
2 | 11-15-2016 03:33 PM |
Online Status |
Offline
|
Date Last Visited |
09-19-2022
09:23 PM
|