Select to view content in your preferred language

problem of using arcpy.polyline creat line

809
3
06-28-2019 08:21 PM
lmzh
by
Emerging Contributor
I  have a python script that was get coordinate points (Longitudinal and latitudinal coordinate ) from excel and writing them to an arcpy.Array and then writing the array to an already existing feature class as a polyline.  but line created  finished offset the point ,and vertices of  creating line  less than numbers of points. 

0 Kudos
3 Replies
JoshuaBixby
MVP Esteemed Contributor

You appear to be using the original ArcPy cursors, as opposed to the ArcPy Data Access cursors that were introduced in 10.1.  I recommend switching to the DA cursors and then re-post your question if you are still having issues:  Accessing data using cursors—Help | ArcGIS Desktop 

0 Kudos
LukeWebb
Frequent Contributor

I always make my polylines like this, so no idea if this will help:

polyline=arcpy.Polyline(array)

row.setValue(shapename, polyline)

For the offset, you probably need to include a spatial reference:

spatref_epsg = 4326   #https://spatialreference.org/ref/epsg/wgs-84/

arcpy.CreateFeatureclass_management(out_path=folder, out_name=shapename,geometry_type='POLYLINE', spatial_reference=arcpy.SpatialReference(spatref_epsg))

lmzh
by
Emerging Contributor

thanks, offset reason is lack of spatial reference indeed.

0 Kudos