Returning strings showing all vertices from all polygons in shapefile using ArcPy?Concatenating list of strings using ArcPy?Use arcpy.da.searchcursor to select rows to dissolveConverting Vertices of Polylines and Polygons to Points and Maintain AttributesCheck if a polygon is at one elevationSelecting all polygons where neighbor vertex points are below distance threshold in ArcPy?Cutting polygon using line - cutter, cut() - using ArcPy?ArcPy Insert cursor losing vertices when writing Polygon features?Exporting jpeg around polygon boundary using Python?Stratified random point sampling in PythonUsing ArcPy to ListFields inside SearchCursor?Switching from Nested Search Cursors to Dictionaries
How do I generate distribution of positive numbers only with min, max and mean?
3D Statue Park: U shapes
What exactly makes a General Products hull nearly indestructible?
Grid/table with lots of buttons
Trapped in an ocean Temple in Minecraft?
Character is called by their first initial. How do I write it?
Replacing tongue and groove floorboards: but can't find a match
Timing/Stack question about abilities triggered during combat
Why is a dedicated QA team member necessary?
Where to place an artificial gland in the human body?
Why are so many countries still in the Commonwealth?
Is dd if=/dev/urandom of=/dev/mem safe?
How did C64 games handle music during gameplay?
How may I concisely assign different values to a variable, depending on another variable?
What are the exact meanings of roll, pitch and yaw?
kids pooling money for Lego League and taxes
Reduce column width of table while also aligning values at decimal point
How do I run a game when my PCs have different approaches to combat?
Area of parallelogram = Area of square. Shear transform
Are there any examples of technologies have been lost over time?
Commercial jet accompanied by small plane near Seattle
Why are off grid solar setups only 12, 24, 48 VDC?
Strange Cron Job takes up 100% of CPU Ubuntu 18 LTS Server
Memory capability and powers of 2
Returning strings showing all vertices from all polygons in shapefile using ArcPy?
Concatenating list of strings using ArcPy?Use arcpy.da.searchcursor to select rows to dissolveConverting Vertices of Polylines and Polygons to Points and Maintain AttributesCheck if a polygon is at one elevationSelecting all polygons where neighbor vertex points are below distance threshold in ArcPy?Cutting polygon using line - cutter, cut() - using ArcPy?ArcPy Insert cursor losing vertices when writing Polygon features?Exporting jpeg around polygon boundary using Python?Stratified random point sampling in PythonUsing ArcPy to ListFields inside SearchCursor?Switching from Nested Search Cursors to Dictionaries
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I want to have a string showing all vertices from all polygons in a shapefile. In my example below my code lists all vertices and the first column shows the polygon they are part of (I only have 2 in this example)
import arcpy
fc=r'D:GIS DataTOOLSEV calc in PythonData.gdbPolyWGS84'
myList = []
with arcpy.da.SearchCursor(fc,['OID@','SHAPE@']) as cursor:
for row in cursor:
array1=row[1].getPart()
for vertice in range(row[1].pointCount):
pnt=array1.getObject(0).getObject(vertice)
print row[0],pnt.X,pnt.Y
myList.append(str(pnt.X) + " " + str(pnt.Y))
print ", ".join(myList)
This is the result
1 151.513429431 -33.568900991
1 151.313554706 -34.011480738
1 150.928082023 -33.975788823
1 150.906666874 -34.27560091
1 150.506917425 -34.211355462
1 150.692515384 -33.51893231
1 151.513429431 -33.568900991
2 151.72520146 -32.500522999
2 152.082120611 -33.242914833
2 151.196961117 -33.100147173
2 151.72520146 -32.500522999
151.513429431 -33.568900991, 151.313554706 -34.011480738, 150.928082023 -33.975788823, 150.906666874 -34.27560091, 150.506917425 -34.211355462, 150.692515384 -33.51893231, 151.513429431 -33.568900991, 151.72520146 -32.500522999, 152.082120611 -33.242914833, 151.196961117 -33.100147173, 151.72520146 -32.500522999
But what I want is separate strings for each polygon in the shapefile
151.513429431 -33.568900991, 151.313554706 -34.011480738, 150.928082023 -33.975788823, 150.906666874 -34.27560091, 150.506917425 -34.211355462, 150.692515384 -33.51893231, 151.513429431 -33.568900991
151.72520146 -32.500522999, 152.082120611 -33.242914833, 151.196961117 -33.100147173, 151.72520146 -32.500522999
How would you do this?
arcpy polygon vertices list string
add a comment |
I want to have a string showing all vertices from all polygons in a shapefile. In my example below my code lists all vertices and the first column shows the polygon they are part of (I only have 2 in this example)
import arcpy
fc=r'D:GIS DataTOOLSEV calc in PythonData.gdbPolyWGS84'
myList = []
with arcpy.da.SearchCursor(fc,['OID@','SHAPE@']) as cursor:
for row in cursor:
array1=row[1].getPart()
for vertice in range(row[1].pointCount):
pnt=array1.getObject(0).getObject(vertice)
print row[0],pnt.X,pnt.Y
myList.append(str(pnt.X) + " " + str(pnt.Y))
print ", ".join(myList)
This is the result
1 151.513429431 -33.568900991
1 151.313554706 -34.011480738
1 150.928082023 -33.975788823
1 150.906666874 -34.27560091
1 150.506917425 -34.211355462
1 150.692515384 -33.51893231
1 151.513429431 -33.568900991
2 151.72520146 -32.500522999
2 152.082120611 -33.242914833
2 151.196961117 -33.100147173
2 151.72520146 -32.500522999
151.513429431 -33.568900991, 151.313554706 -34.011480738, 150.928082023 -33.975788823, 150.906666874 -34.27560091, 150.506917425 -34.211355462, 150.692515384 -33.51893231, 151.513429431 -33.568900991, 151.72520146 -32.500522999, 152.082120611 -33.242914833, 151.196961117 -33.100147173, 151.72520146 -32.500522999
But what I want is separate strings for each polygon in the shapefile
151.513429431 -33.568900991, 151.313554706 -34.011480738, 150.928082023 -33.975788823, 150.906666874 -34.27560091, 150.506917425 -34.211355462, 150.692515384 -33.51893231, 151.513429431 -33.568900991
151.72520146 -32.500522999, 152.082120611 -33.242914833, 151.196961117 -33.100147173, 151.72520146 -32.500522999
How would you do this?
arcpy polygon vertices list string
add a comment |
I want to have a string showing all vertices from all polygons in a shapefile. In my example below my code lists all vertices and the first column shows the polygon they are part of (I only have 2 in this example)
import arcpy
fc=r'D:GIS DataTOOLSEV calc in PythonData.gdbPolyWGS84'
myList = []
with arcpy.da.SearchCursor(fc,['OID@','SHAPE@']) as cursor:
for row in cursor:
array1=row[1].getPart()
for vertice in range(row[1].pointCount):
pnt=array1.getObject(0).getObject(vertice)
print row[0],pnt.X,pnt.Y
myList.append(str(pnt.X) + " " + str(pnt.Y))
print ", ".join(myList)
This is the result
1 151.513429431 -33.568900991
1 151.313554706 -34.011480738
1 150.928082023 -33.975788823
1 150.906666874 -34.27560091
1 150.506917425 -34.211355462
1 150.692515384 -33.51893231
1 151.513429431 -33.568900991
2 151.72520146 -32.500522999
2 152.082120611 -33.242914833
2 151.196961117 -33.100147173
2 151.72520146 -32.500522999
151.513429431 -33.568900991, 151.313554706 -34.011480738, 150.928082023 -33.975788823, 150.906666874 -34.27560091, 150.506917425 -34.211355462, 150.692515384 -33.51893231, 151.513429431 -33.568900991, 151.72520146 -32.500522999, 152.082120611 -33.242914833, 151.196961117 -33.100147173, 151.72520146 -32.500522999
But what I want is separate strings for each polygon in the shapefile
151.513429431 -33.568900991, 151.313554706 -34.011480738, 150.928082023 -33.975788823, 150.906666874 -34.27560091, 150.506917425 -34.211355462, 150.692515384 -33.51893231, 151.513429431 -33.568900991
151.72520146 -32.500522999, 152.082120611 -33.242914833, 151.196961117 -33.100147173, 151.72520146 -32.500522999
How would you do this?
arcpy polygon vertices list string
I want to have a string showing all vertices from all polygons in a shapefile. In my example below my code lists all vertices and the first column shows the polygon they are part of (I only have 2 in this example)
import arcpy
fc=r'D:GIS DataTOOLSEV calc in PythonData.gdbPolyWGS84'
myList = []
with arcpy.da.SearchCursor(fc,['OID@','SHAPE@']) as cursor:
for row in cursor:
array1=row[1].getPart()
for vertice in range(row[1].pointCount):
pnt=array1.getObject(0).getObject(vertice)
print row[0],pnt.X,pnt.Y
myList.append(str(pnt.X) + " " + str(pnt.Y))
print ", ".join(myList)
This is the result
1 151.513429431 -33.568900991
1 151.313554706 -34.011480738
1 150.928082023 -33.975788823
1 150.906666874 -34.27560091
1 150.506917425 -34.211355462
1 150.692515384 -33.51893231
1 151.513429431 -33.568900991
2 151.72520146 -32.500522999
2 152.082120611 -33.242914833
2 151.196961117 -33.100147173
2 151.72520146 -32.500522999
151.513429431 -33.568900991, 151.313554706 -34.011480738, 150.928082023 -33.975788823, 150.906666874 -34.27560091, 150.506917425 -34.211355462, 150.692515384 -33.51893231, 151.513429431 -33.568900991, 151.72520146 -32.500522999, 152.082120611 -33.242914833, 151.196961117 -33.100147173, 151.72520146 -32.500522999
But what I want is separate strings for each polygon in the shapefile
151.513429431 -33.568900991, 151.313554706 -34.011480738, 150.928082023 -33.975788823, 150.906666874 -34.27560091, 150.506917425 -34.211355462, 150.692515384 -33.51893231, 151.513429431 -33.568900991
151.72520146 -32.500522999, 152.082120611 -33.242914833, 151.196961117 -33.100147173, 151.72520146 -32.500522999
How would you do this?
arcpy polygon vertices list string
arcpy polygon vertices list string
edited Jul 16 at 19:19
PolyGeo♦
54.7k17 gold badges86 silver badges258 bronze badges
54.7k17 gold badges86 silver badges258 bronze badges
asked Jul 16 at 13:31
GiacomoGiacomo
699 bronze badges
699 bronze badges
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You have the general idea in place already -- just move your print of the list into the loop, and remove the print for each vertex.
import arcpy
fc=r'D:GIS DataTOOLSEV calc in PythonData.gdbPolyWGS84'
with arcpy.da.SearchCursor(fc,['OID@','SHAPE@']) as cursor:
for row in cursor:
myList = []
array1=row[1].getPart()
for vertice in range(row[1].pointCount):
pnt=array1.getObject(0).getObject(vertice)
# print row[0],pnt.X,pnt.Y
myList.append(str(pnt.X) + " " + str(pnt.Y))
print row[0], ", ".join(myList)
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "79"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f328917%2freturning-strings-showing-all-vertices-from-all-polygons-in-shapefile-using-arcp%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You have the general idea in place already -- just move your print of the list into the loop, and remove the print for each vertex.
import arcpy
fc=r'D:GIS DataTOOLSEV calc in PythonData.gdbPolyWGS84'
with arcpy.da.SearchCursor(fc,['OID@','SHAPE@']) as cursor:
for row in cursor:
myList = []
array1=row[1].getPart()
for vertice in range(row[1].pointCount):
pnt=array1.getObject(0).getObject(vertice)
# print row[0],pnt.X,pnt.Y
myList.append(str(pnt.X) + " " + str(pnt.Y))
print row[0], ", ".join(myList)
add a comment |
You have the general idea in place already -- just move your print of the list into the loop, and remove the print for each vertex.
import arcpy
fc=r'D:GIS DataTOOLSEV calc in PythonData.gdbPolyWGS84'
with arcpy.da.SearchCursor(fc,['OID@','SHAPE@']) as cursor:
for row in cursor:
myList = []
array1=row[1].getPart()
for vertice in range(row[1].pointCount):
pnt=array1.getObject(0).getObject(vertice)
# print row[0],pnt.X,pnt.Y
myList.append(str(pnt.X) + " " + str(pnt.Y))
print row[0], ", ".join(myList)
add a comment |
You have the general idea in place already -- just move your print of the list into the loop, and remove the print for each vertex.
import arcpy
fc=r'D:GIS DataTOOLSEV calc in PythonData.gdbPolyWGS84'
with arcpy.da.SearchCursor(fc,['OID@','SHAPE@']) as cursor:
for row in cursor:
myList = []
array1=row[1].getPart()
for vertice in range(row[1].pointCount):
pnt=array1.getObject(0).getObject(vertice)
# print row[0],pnt.X,pnt.Y
myList.append(str(pnt.X) + " " + str(pnt.Y))
print row[0], ", ".join(myList)
You have the general idea in place already -- just move your print of the list into the loop, and remove the print for each vertex.
import arcpy
fc=r'D:GIS DataTOOLSEV calc in PythonData.gdbPolyWGS84'
with arcpy.da.SearchCursor(fc,['OID@','SHAPE@']) as cursor:
for row in cursor:
myList = []
array1=row[1].getPart()
for vertice in range(row[1].pointCount):
pnt=array1.getObject(0).getObject(vertice)
# print row[0],pnt.X,pnt.Y
myList.append(str(pnt.X) + " " + str(pnt.Y))
print row[0], ", ".join(myList)
edited Jul 16 at 13:47
answered Jul 16 at 13:36
smillersmiller
2,9235 silver badges17 bronze badges
2,9235 silver badges17 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Geographic Information Systems Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f328917%2freturning-strings-showing-all-vertices-from-all-polygons-in-shapefile-using-arcp%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown