POST
|
Actually i just posted the code for creating polygon (i was using if statement ) and could not removed while posting. I am displaying each polygon vertices and coordinates. The problem is that some line features have only two vertices (starting and ending) .My code is not converting them as it is not a polygon(we need at least three vertices).Please guide me to convert all lines as feature to polygon tool is converting. import arcpy import os from arcpy import env env.overwriteOutput = True starttime = time.time() localtime = time.asctime( time.localtime(time.time()) ) # Create a value table that will hold the input feature classes for Merge mxd=arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd, "")[0] for lyr in arcpy.mapping.ListLayers(mxd,"",df): if not lyr.isGroupLayer: arcpy.AddMessage(lyr.name) if "Export" in lyr.name : break desc = arcpy.Describe(lyr) shapefieldname = desc.ShapeFieldName outPolys=r'C:\RAECGIStoCAD\test.gdb\temp' arcpy.DeleteFeatures_management(r'C:\RAECGIStoCAD\test.gdb\temp') joinoutput=r'C:\RAECGIStoCAD\test.gdb\join' spatialRef = arcpy.Describe(lyr).spatialReference featureList = [] #array = arcpy.Array() cursor = arcpy.da.InsertCursor(outPolys, ['SHAPE@']) rows = arcpy.SearchCursor(lyr) for row in rows: # Create the geometry object feat = row.getValue(shapefieldname) #print "Feature %i: " % row.getValue(desc.OIDFieldName) partnum = 0 part_list = [] # Step through each part of the feature for part in feat: polygonArray = arcpy.Array() for pnt in feat.getPart(partnum): if pnt: # Add to list part_list.append([pnt.X, pnt.Y]) polygonArray.add(arcpy.Point(pnt.X,pnt.Y)) partnum += 1 print partnum print part_list polygon = arcpy.Polygon(polygonArray) featureList.append(polygon) cursor.insertRow([polygon]) del cursor endtime = time.time() totaltime = endtime-starttime print "\nScript took " + str(totaltime/60) + " minutes to run"
... View more
05-22-2017
03:55 AM
|
0
|
2
|
1141
|
POST
|
Dear Jayanta, I know about these tools.My main concern is about the result comparison. I want to know the logic behind feature to polygon tool?there is something missing in my code.
... View more
05-22-2017
03:13 AM
|
0
|
3
|
1141
|
POST
|
Dear FC Basson, partnum counter i hv only placed to check the polygon (coordinates ) only.I want to know what logic is behind feature to polygon tool?
... View more
05-22-2017
01:34 AM
|
0
|
4
|
1141
|
POST
|
I am trying to convert a ploy line feature class to polygon without using Arc info Advanced Licence.The code i am using runs fine and converts polyline to polygon. I have run the "tool feature to polygon" to make a comparison.My code is not converting all lines to polygon(See Screenshot).I have also attached my code.please guide me to get the same results. Polyline :Red(to be converted) Mycode:Brown Feature to polygon: Blue import arcpy import arcpy
import os
from arcpy import env
env.overwriteOutput = True
starttime = time.time()
localtime = time.asctime( time.localtime(time.time()) )
# Create a value table that will hold the input feature classes for Merge
mxd=arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "")[0]
for lyr in arcpy.mapping.ListLayers(mxd,"",df):
if not lyr.isGroupLayer:
arcpy.AddMessage(lyr.name)
if "Export" in lyr.name :
break
desc = arcpy.Describe(lyr)
shapefieldname = desc.ShapeFieldName
outPolys=r'C:\RAECGIStoCAD\test.gdb\temp'
arcpy.DeleteFeatures_management(r'C:\RAECGIStoCAD\test.gdb\temp')
joinoutput=r'C:\RAECGIStoCAD\test.gdb\join'
spatialRef = arcpy.Describe(lyr).spatialReference
featureList = []
#array = arcpy.Array()
cursor = arcpy.da.InsertCursor(outPolys, ['SHAPE@'])
rows = arcpy.SearchCursor(lyr)
for row in rows:
# Create the geometry object
feat = row.getValue(shapefieldname)
#print "Feature %i: " % row.getValue(desc.OIDFieldName)
partnum = 0
part_list = []
# Step through each part of the feature
for part in feat:
polygonArray = arcpy.Array()
for pnt in feat.getPart(partnum):
if pnt:
# Add to list
part_list.append([pnt.X, pnt.Y])
polygonArray.add(arcpy.Point(pnt.X,pnt.Y))
partnum += 1
print partnum
print part_list
polygon = arcpy.Polygon(polygonArray)
featureList.append(polygon)
cursor.insertRow([polygon])
del cursor
endtime = time.time()
totaltime = endtime-starttime
print "\nScript took " + str(totaltime/60) + " minutes to run"
... View more
05-22-2017
12:03 AM
|
0
|
11
|
2743
|
POST
|
finally giving manual spatial reference work. Thank you Robert for your time and support
... View more
04-17-2017
12:12 PM
|
0
|
0
|
543
|
POST
|
Yes i have copied the code which you posted and attached the screenshot of the error.
... View more
04-17-2017
10:14 AM
|
0
|
6
|
543
|
POST
|
Dear Robert, Please see the screenshot and error below:
... View more
04-17-2017
10:00 AM
|
0
|
8
|
543
|
POST
|
Now getting this error Map: Geometry (wkid: 32640) cannot be converted to spatial reference of the map (wkid: 102100) i was thinking to change my code using feature selection.
... View more
04-17-2017
07:35 AM
|
0
|
10
|
1118
|
POST
|
i have already tried both but no success. query.outSpatialReference={wkid :"32640"}; my map service wkid query.outSpatialReference = map.spatialRefernce;
... View more
04-16-2017
05:43 AM
|
0
|
13
|
1118
|
POST
|
Dear Robert, I have make a new html with query.it is running and showing features without adding basemap. when i add basemap: "topo", center: [58.871192 , 20.646328], zoom: 12 The query still runs and results are shown in different area .Something with projection is the error.Please guide <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"> <link rel="stylesheet" href="https://js.arcgis.com/3.20/dijit/themes/claro/claro.css"> <link rel="stylesheet" href="https://js.arcgis.com/3.20/esri/css/esri.css"> <style> html, body { height: 100%; width: 100%; margin: 0; padding: 0; } .claro .dijitContentPane { font-family: "Lucida Grande","Segoe UI","Arial",sans-serif; font-weight: normal; font-size: small; } </style> <script src="https://js.arcgis.com/3.20/"></script> <script> var map; require([ "esri/map", "esri/layers/ArcGISDynamicMapServiceLayer", "esri/tasks/QueryTask", "esri/tasks/query", "esri/symbols/SimpleMarkerSymbol", "esri/InfoTemplate", "dojo/_base/Color", "dojo/dom", "dojo/on", "dojo/domReady!" ], function(Map, ArcGISDynamicMapServiceLayer, QueryTask, Query, SimpleMarkerSymbol, InfoTemplate, Color, dom, on) { //create map and add layer map = new Map("mapDiv",{ basemap: "topo", center: [58.871192 , 20.646328], zoom: 12 }); var layer = new ArcGISDynamicMapServiceLayer( "http://localhost:6080/arcgis/rest/services/RAEC/MapServer"); map.addLayer(layer); //initialize query task queryTask = new QueryTask("http://localhost:6080/arcgis/rest/services/RAEC/MapServer/12"); //initialize query query = new Query(); query.returnGeometry = true; query.outFields = ["FeederID"]; //initialize InfoTemplate infoTemplate = new InfoTemplate("${FeederID}", "Name : ${FeederID}<br/> "); //create symbol for selected features symbol = new SimpleMarkerSymbol(); symbol.setStyle(SimpleMarkerSymbol.STYLE_SQUARE); symbol.setSize(10); symbol.setColor(new Color([255,255,0,0.5])); //write "Get Details" button's click event on(dom.byId("runQuery"), "click", executeQueryTask); function executeQueryTask() { //set query based on what user typed in for population; query.where = "FeederID<> ''"; //execute query queryTask.execute(query,showResults); function showResults(featureSet) { //remove all graphics on the maps graphics layer map.graphics.clear(); //Performance enhancer - assign featureSet array to a single variable. var resultFeatures = featureSet.features; //Loop through each feature returned for (var i=0, il=resultFeatures.length; i<il; i++) { //Get the current feature from the featureSet. //Feature is a graphic var graphic = resultFeatures; graphic.setSymbol(symbol); //Set the infoTemplate. graphic.setInfoTemplate(infoTemplate); //Add graphic to the map graphics layer. map.graphics.add(graphic); } } } }); </script> <body> <br/> <input type="button" value="Get Details" id="runQuery" /> <div id="mapDiv" style="width:600px; height:600px; border:1px solid #000;"></div> </body> </html>
... View more
04-15-2017
11:45 PM
|
0
|
15
|
1118
|
POST
|
Yes query is running fine and passing geometry object, attribute object and graphics symbols.
... View more
04-15-2017
09:11 PM
|
0
|
0
|
1118
|
POST
|
I am trying to select highlight features and zoom to selected features layer extent.My code below runs but doesn't highlight any feature. on(dom.byId("try"), "click", function () { var queryTask = new QueryTask("http://localhost:6080/arcgis/rest/services/RAEC/MapServer/12"); //build query filter var que = new Query(); que.returnGeometry = true; que.outFields = ["FeederID", "OBJECTID"]; que.outSpatialReference = { "wkid": 32640 }; que.where = "FeederID<> ''"; symbol = new SimpleMarkerSymbol(); symbol.setStyle(SimpleMarkerSymbol.STYLE_SQUARE); symbol.setSize(10); symbol.setColor(new Color([255,255,0,0.5])); queryTask.execute(que,showResults); function showResults(featureSet) { map.graphics.clear(); var resultFeatures = featureSet.features; for (var i=0, il=resultFeatures.length; i<il; i++) { var graphic = resultFeatures; graphic.setSymbol(symbol); map.graphics.add(graphic); } } });
... View more
04-15-2017
08:29 AM
|
0
|
18
|
3698
|
POST
|
Have you tried running your GP service by using GP widget?sometimes GP services have problem.so i would suggest to run your GP service by GP widget.
... View more
04-13-2017
03:28 AM
|
0
|
0
|
433
|
Title | Kudos | Posted |
---|---|---|
1 | 07-11-2020 02:38 AM | |
1 | 12-11-2016 01:16 AM | |
3 | 08-29-2018 01:30 AM | |
1 | 12-18-2017 04:49 AM | |
3 | 03-26-2017 11:40 PM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|