[postgis-users] brake MPolygon to polygons

pcreso at pcreso.com pcreso at pcreso.com
Mon Feb 1 10:24:43 PST 2010


You might also need to add something like:

alter table single_polygon_countries add column id serial;
alter table single_polygon_countries add primary key (id);

This will create a new column in the table with a unique id value for each row, and use this as a primary key to the table. 

This will be needed by some applications using the new table (such as QGIS or Mapserver), and it is good practice to create a primary key on the table anyway.


Cheers,

  Brent Wood
 

--- On Mon, 2/1/10, Marko Čubranić <mcubranic at gmail.com> wrote:

> From: Marko Čubranić <mcubranic at gmail.com>
> Subject: Re: [postgis-users] brake MPolygon to polygons
> To: "PostGIS Users Discussion" <postgis-users at postgis.refractions.net>
> Date: Monday, February 1, 2010, 10:15 PM
> thanks Nicklas, 
> 
> 2010/2/1 Nicklas Avén <nicklas.aven at jordogskog.no>
> 
> 
> 
> 	
> 	
> 
> 
> 
> 
> 	
> Hallo
> 	
>  
> 	
> If I understand you right you have
> multipolygons representing countries that you want splitted
> to single polygons.
> 	
>  
> 	
> That is no problem but they will not fit
> in the same table since you will get additional rows.
> 	
>  
> 	
> If you want to make a new table with this
> country polygons as single polygons you can do
> 	
>  
> 	
> create table single_polygon_countries
> as
> 	
> select (ST_Dump(the_geom)).geom as
> the_geom, countryID from original_country_table;
> 	
>  
> 	
> I put countryID there, just to illustrate
> that you probably want to bring some id or name to the new
> table. That will be repeated for all single polygons from
> original multi polygon
> 	
>  
> 	
> Hope that helps
> 	
> Nicklas
> 	
>  
> 	
> 
> 
> 		
> 
> 		2010-02-01 Marko Èubraniæ wrote:
> 
> 		
> 
> 		Dear colleagues,
> 
> 		>
> 
> 		>if i have x Mpolygons in table (country) and i want
> to brake each of them in polygons, and put polygons in new
> columns, how should i do that?..
> 
> 		>
> 
> 		>thank you
> 
> 		>
> 
> 		>Marko Cubranic
> 
> 		>
> 
> 
> 
> _______________________________________________
> 
> postgis-users mailing list
> 
> postgis-users at postgis.refractions.net
> 
> http://postgis.refractions.net/mailman/listinfo/postgis-users
> 
> 
> 
> 
> 
> -----Inline Attachment Follows-----
> 
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
> 



More information about the postgis-users mailing list