Pages

Thursday, November 16, 2017

Creating MultiPoint Shapefiles with PyShp

Pyshp let's you create any type of shapefile.  Normally a point shapefile has one point per record.  But
Photo credit: VancouverMom.ca
you can also have a group of points tied to a single record in a Multipoint shapefile.  To create a Multipoint shapefile, you just use the "poly" method in the Writer. The poly method isn't just for polygons. It can also create polylines and polypoints (i.e. MultiPoints)!

Here's a simple Multipoint shapefile:


import shapefile

# Create our writer as a multipoint shapefile
w = shapefile.Writer(shapefile.MULTIPOINT)

# We'll create a single dbf field
w.field("NAME","C",40)

# Create a single-part, multi-point shape 
# by declaring the shape
# type after the parts/points list
w.poly([[[3,4],[5,6],[7,8],[9,8]]], shapeType=shapefile.MULTIPOINT)

# Create a record for this feature
w.record("Group1")

# Save the multipoint shapefile
w.save("mpoint")
Repeat the poly and record steps to add additional shapes. Add another nested list of points in the first poly method argument to add more parts to the same record

5 comments:


  1. I must say you had done a tremendous job,I appreciate all your efforts.
    Thanks alot for your writings.
    Waiting for a new 1...Please visit our wonderful and valuable website-
    For More Details Visit are Official Websites :

    http://kutarockcity.postbit.com/tips-cara-mengatur-pola-hidup-sehat.html/


    http://inempoker.bravesites.com/


    https://www.kiwibox.com/Inem/blog/


    http://murdock44.angelfire.com/


    https://gedheanune.blogspot.com/2017/11/bandar-judi-togel-aman-dan-terpercaya.html

    ReplyDelete
  2. Thanks for sharing this in here. You are running a great blog, keep up this good work.
    Check it out : AWS Training in chennai | AWS Training institute in velachery

    ReplyDelete
  3. Hadoop concepts, Applying modelling through R programming using Machine learning algorithms and illustrate impeccable Data Visualization by leveraging on 'R' capabilities.With companies across industries striving to bring their research and analysis (R&A) departments up to speed, the demand for qualified data scientists is rising.
    data science training in bangalore

    ReplyDelete