I am using PyShp to create line shapefile in Python.

w = shapefile.Writer('shapefiles/line')
w.field('name', 'C')
w.line([ [[3,2],[2,6]] ])

Is there a way to specify a different color (and width) for each line object?

  • 3
    This question indicates a fundamental misunderstanding of what a shapefile is. Shapefiles are GIS datasets. In the GIS model, unlike in the CAD model, data is data, and symbolization is a drawing rule, managed by a map project (often based on attributes). You can add attributes 'COLOR' and 'WIDTH` to the shapefile, and populate these values, and this will mean nothing to the majority of GIS packages until these attributes are explicitly linked to symbolization. In the end, it is not possible to create a shapefile with color, only to customize symbolization using GIS-specific tools. – Vince Dec 30 '19 at 22:25
  • @Vince Thanks for the clarification. Can you explain a little bit more how to add attributes 'COLOR' and 'WIDTH' to the shapefile and populate these values and explicitly link these attributes to symbolization. That would really help. I would like to create isoline plot in ArcGIS. I know gdal can do this. Just wonder if there is a way to work this around with PyShp. – fengdongyuxi Dec 30 '19 at 22:32
  • No, but you can Edit the question to ask this, and then maybe a pyshp user can help you. You should, of course, make an effort by reviewing the documentation first. – Vince Dec 31 '19 at 1:58

Your Answer

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

Browse other questions tagged or ask your own question.