[postgis-users] forced conversion of linestring to mulitlinestring when using shp2pgsql utility ?

Nicolas Ribot nicky666 at gmail.com
Mon Jan 26 06:09:15 PST 2009


> Hi,
>
> I have a shape file of linestrings that I want to load into postgis as linestrings.
> My problem is whenever i use the shp2pgsql utility,  the utility converts all the linestrings
> to multilinestrings. My purpose of loading the shape files is to do geometry operations on them
> eg line interpolation. This operation can only be done on linestring not multilinestrings.
>
> Is there a way shp2pgsql can load linestrings to postgis as linestrings ? or is there another tool that
> can do that for me ?
>

The -S switch is your friend. it forces simple geometries as stated if
you run shp2pgsql w/o args:

RCSID: $Id: shp2pgsql.c 2782 2008-05-27 02:59:06Z pramsey $ RELEASE: 1.3.5
USAGE: shp2pgsql [<options>] <shapefile> [<schema>.]<table>
OPTIONS:
  -s <srid>  Set the SRID field. If not specified it defaults to -1.
  (-d|a|c|p) These are mutually exclusive options:
      -d  Drops the table, then recreates it and populates
          it with current shape file data.
      -a  Appends shape file into current table, must be
          exactly the same table schema.
      -c  Creates a new table and populates it, this is the
          default if you do not specify any options.
      -p  Prepare mode, only creates the table.
  -g <geometry_column> Specify the name of the geometry column
     (mostly useful in append mode).
  -D  Use postgresql dump format (defaults to sql insert statments.
  -k  Keep postgresql identifiers case.
  -i  Use int4 type for all integer dbf fields.
  -I  Create a GiST index on the geometry column.
  -S  Generate simple geometries instead of MULTI geometries.
  -w  Use wkt format (for postgis-0.x support - drops M - drifts coordinates).
  -W <encoding> Specify the character encoding of Shape's
     attribute column. (default : "ASCII")
  -N <policy> Specify NULL geometries handling policy (insert,skip,abort)
  -n  Only import DBF file.
  -? Display this help screen

you can also explode multi into simple objects once the table is
loaded, by dropping the enforce_geom_type constraint on your table.

Nicolas



More information about the postgis-users mailing list