0

I have a CSV which I've imported into ArcGIS Desktop, and it contains a Linestring column.

How do I convert it into a shapefile?

Example of what one of the fields contain below:

[[51.53878768021, -0.01805397057],[51.53878865403, -0.01811160963],
 [51.5393377751, -0.01814543493],[51.53936448971, -0.0181298538],
 [51.54012998282, -0.01766397309],[51.54065187717, -0.0171509813],
 [51.54082063461, -0.01649470118],[51.54057432587, -0.01575552408],
 [51.54042543071, -0.01545916271],[51.54022213116, -0.01513632888],
 [51.53982939314, -0.01477847997],[51.54004741802, -0.01384606376],
 [51.54013064554, -0.01291951037],[51.54015613891, -0.01283187515],
 [51.54036833688, -0.01208716771],[51.54207215087, -0.00862388496],
 [51.54215106745, -0.00850506822],[51.54274424885, -0.00742639128],
 [51.54273732937, -0.00490291103],[51.54273994243, -0.00452783466],
 [51.54280308915, -0.00453949369],[51.54287669256, -0.00463722526],
 [51.54334224557, -0.00451590589],[51.54334224557, -0.00451590589],
 [51.54333154362, -0.00441542146],[51.54335580468, -0.00425572003],
 [51.54355300498, -0.00421824756],[51.54375094078, -0.00422400837],
 [51.54396660328, -0.00421457153],[51.54396586774, -0.00417133769]]
2

You can use arcpy's Geometry() classes:

coords = [[51.53878768021, -0.01805397057],[51.53878865403, -0.01811160963],[51.5393377751, -0.01814543493],[51.53936448971, -0.0181298538],[51.54012998282, -0.01766397309],[51.54065187717, -0.0171509813],[51.54082063461, -0.01649470118],[51.54057432587, -0.01575552408],[51.54042543071, -0.01545916271],[51.54022213116, -0.01513632888],[51.53982939314, -0.01477847997],[51.54004741802, -0.01384606376],[51.54013064554, -0.01291951037],[51.54015613891, -0.01283187515],[51.54036833688, -0.01208716771],[51.54207215087, -0.00862388496],[51.54215106745, -0.00850506822],[51.54274424885, -0.00742639128],[51.54273732937, -0.00490291103],[51.54273994243, -0.00452783466],[51.54280308915, -0.00453949369],[51.54287669256, -0.00463722526],[51.54334224557, -0.00451590589],[51.54334224557, -0.00451590589],[51.54333154362, -0.00441542146],[51.54335580468, -0.00425572003],[51.54355300498, -0.00421824756],[51.54375094078, -0.00422400837],[51.54396660328, -0.00421457153],[51.54396586774, -0.00417133769]]

geom = arcpy.Polyline(arcpy.Array([arcpy.Point(*c) for c in coords]))

arcpy.CopyFeatures_management(geom, r'C:\example\some_shape.shp')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.