I am looking for a way to extract coordinate points from a road casement i have drawn to put them in a new shapefile and create a table of coordinate points for the road. I have been taught to turn on vertex snapping to the casement in an editing session for my coordinate point shapefile and just run mouse over the casement until it snaps to a vertex and then create a point there but this method seems extremely inefficient so I'm hoping someone has a better way.
Thanks π
seems like an awful hard way to create point vertices when you can useΒ Feature Vertices To PointsβHelp | ArcGIS for DesktopΒ
or if you don't have the license level, then there are other options
Thanks Dan, I did check out that option but unfortunately don't have the license to use any of the "feature to" type tools. You mentioned there are other options, would love to hear any other suggestions?
Try Ianko's tools.
I see Poly to Point is a free tool in ET Geo wizards.
http://www.ian-ko.com/
Otherwise you would have to use some python / arcpy magic.
With Python you can iterate the polygon part vertices and write them to a new table. Β You can change the field names and outputs as required. Β Select a single polygon segment to only write one table and run the script from the ArcMap Python console.
<SPAN class="keyword token">import</SPAN> arcpy mxd <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>mapping<SPAN class="punctuation token">.</SPAN>MapDocument<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'CURRENT'</SPAN><SPAN class="punctuation token">)</SPAN> df <SPAN class="operator token">=</SPAN> mxd<SPAN class="punctuation token">.</SPAN>activeDataFrame layers <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>mapping<SPAN class="punctuation token">.</SPAN>ListLayers<SPAN class="punctuation token">(</SPAN>df<SPAN class="punctuation token">)</SPAN> layer <SPAN class="operator token">=</SPAN> layers<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="keyword token">with</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>SearchCursor<SPAN class="punctuation token">(</SPAN>layer<SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">"SHAPE@"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"OBJECTID"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">as</SPAN> lcursor<SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">for</SPAN> lrow <SPAN class="keyword token">in</SPAN> lcursor<SPAN class="punctuation token">:</SPAN> polygon <SPAN class="operator token">=</SPAN> lrow<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN> objId <SPAN class="operator token">=</SPAN> lrow<SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="comment token"># create table for selected feature</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>CreateTable_management<SPAN class="punctuation token">(</SPAN>arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>scratchWorkspace<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"pntTable_"</SPAN> <SPAN class="operator token">+</SPAN> str<SPAN class="punctuation token">(</SPAN>objId<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> table <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>scratchWorkspace <SPAN class="operator token">+</SPAN> <SPAN class="string token">"\\pntTable_"</SPAN> <SPAN class="operator token">+</SPAN> str<SPAN class="punctuation token">(</SPAN>objId<SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># add fields or use a template</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>AddField_management<SPAN class="punctuation token">(</SPAN>table<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"X"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"DOUBLE"</SPAN><SPAN class="punctuation token">)</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>AddField_management<SPAN class="punctuation token">(</SPAN>table<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"Y"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"DOUBLE"</SPAN><SPAN class="punctuation token">)</SPAN> icursor <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>InsertCursor<SPAN class="punctuation token">(</SPAN>table<SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">"X"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"Y"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># iterate through polygon parts</SPAN> part <SPAN class="operator token">=</SPAN> polygon<SPAN class="punctuation token">.</SPAN>getPart<SPAN class="punctuation token">(</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># assuming a single part polygon</SPAN> <SPAN class="comment token"># list polygon part points</SPAN> <SPAN class="keyword token">for</SPAN> pnt <SPAN class="keyword token">in</SPAN> part<SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">print</SPAN> <SPAN class="string token">"X: "</SPAN> <SPAN class="operator token">+</SPAN> str<SPAN class="punctuation token">(</SPAN>pnt<SPAN class="punctuation token">.</SPAN>X<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">" Y: "</SPAN> <SPAN class="operator token">+</SPAN> str<SPAN class="punctuation token">(</SPAN>pnt<SPAN class="punctuation token">.</SPAN>Y<SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># add to table</SPAN> icursor<SPAN class="punctuation token">.</SPAN>insertRow<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">[</SPAN>pnt<SPAN class="punctuation token">.</SPAN>X<SPAN class="punctuation token">,</SPAN> pnt<SPAN class="punctuation token">.</SPAN>Y<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">del</SPAN> icursor <SPAN class="keyword token">del</SPAN> lcursorββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ<SPAN class="line-numbers-rows"><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN></SPAN>
Sorry FC, but shouldn't the Create table and the InsertCursor stuff be outside the Search Cursor loop.
At the mo, you are creating a new table for every row in the SearchCursor.
Yes Neil, it could/should sit outside. Β I put it inside just for demo purposes. Β The main thing is to show the iteration over the polygon part vertices.
Ha....
For a shorter way
<SPAN class="comment token"># -*- coding: utf-8 -*-</SPAN> <SPAN class="string token">""" :Created on Tue Aug 16 04:47:18 2016 @author: Dan :Script: poly_to_points.py <SPAN>:Author: </SPAN><A class="jive-link-email-small" href="mailto:Dan.Patterson@carleton.ca" rel="nofollow noopener noreferrer" target="_blank">Dan.Patterson@carleton.ca</A> :Modified: 2016-07-09 :Purpose: polygon to point demo :Requires: nothing :Notes: none :Functions: can't you read :References: none yet """</SPAN> <SPAN class="keyword token">import</SPAN> arcpy <SPAN class="keyword token">def</SPAN> <SPAN class="token function">main</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">""" : - Produce a structured array from an input file : - Print information for that array : - Output a shapefile """</SPAN> input_shp <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"F:\Test2\AOI_mtm9.shp"</SPAN> <SPAN class="comment token"># change obviously</SPAN> output_shp <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"F:\Test2\AOI_pnts.shp"</SPAN> <SPAN class="comment token"># also</SPAN> desc_obj <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Describe<SPAN class="punctuation token">(</SPAN>input_shp<SPAN class="punctuation token">)</SPAN> SR <SPAN class="operator token">=</SPAN> desc_obj<SPAN class="punctuation token">.</SPAN>spatialReference <SPAN class="comment token"># spatial reference object</SPAN> OID_fld <SPAN class="operator token">=</SPAN> desc_obj<SPAN class="punctuation token">.</SPAN>OIDFieldName <SPAN class="comment token"># FID normally</SPAN> shp_fld <SPAN class="operator token">=</SPAN> desc_obj<SPAN class="punctuation token">.</SPAN>shapeFieldName <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"using...\n{}\nto create...\n{}"</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>input_shp<SPAN class="punctuation token">,</SPAN> output_shp<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"file read..."</SPAN><SPAN class="punctuation token">)</SPAN> arr <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>FeatureClassToNumPyArray<SPAN class="punctuation token">(</SPAN>input_shp<SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">[</SPAN>OID_fld<SPAN class="punctuation token">,</SPAN> shp_fld<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> spatial_reference<SPAN class="operator token">=</SPAN>SR<SPAN class="punctuation token">,</SPAN> explode_to_points<SPAN class="operator token">=</SPAN><SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">)</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>NumPyArrayToFeatureClass<SPAN class="punctuation token">(</SPAN>arr<SPAN class="punctuation token">,</SPAN> output_shp<SPAN class="punctuation token">,</SPAN> shp_fld<SPAN class="punctuation token">,</SPAN> SR<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"file written...\n{}"</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>arr<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">return</SPAN> arr <SPAN class="comment token"># -------------------------------------------------------------------------</SPAN> <SPAN class="keyword token">if</SPAN> __name__ <SPAN class="operator token">==</SPAN> <SPAN class="string token">"__main__"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"""Test section, just modify main() """</SPAN> arr <SPAN class="operator token">=</SPAN> main<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> ββββββββββββββββββββββββββββββββββββββββββ<SPAN class="line-numbers-rows"><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN></SPAN>
output
<SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="number token">340000.0</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">5022000.0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="number token">340000.0</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">5026000.0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="number token">344000.0</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">5026000.0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="number token">344000.0</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">5022000.0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="number token">340000.0</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">5022000.0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">]</SPAN>ββββββ <SPAN class="comment token"># with repr(arr)instead of str representation</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>repr<SPAN class="punctuation token">(</SPAN>arr<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> array<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="number token">340000.0</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">5022000.0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="number token">340000.0</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">5026000.0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="number token">344000.0</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">5026000.0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="number token">344000.0</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">5022000.0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="number token">340000.0</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">5022000.0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> dtype<SPAN class="operator token">=</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">'FID'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'<i4'</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="string token">'Shape'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'<f8'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>ββββββββ<SPAN class="line-numbers-rows"><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN></SPAN>
Of course this could be all fluffed up if there was more than one polygon, single-part or multipart, with/without holes and it had attributes.Β It doesn't matter... the polygon is exploded into its constituent parts and returned as a featureclass/shapefile depending on your preference.
Cool. I had forgotten about the "explode to points" option. Mr Numpy rules
Thanks for the help everyone. I'll have to look into running script in arc, I've only been using arc for a couple of weeks so far! But I'm sure with all these suggestions I'll have a solution soon π
Angemeldete Mitglieder kΓΆnnen BeitrΓ€ge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.