[Gvsig_english] QUESTION gvSIG 1.9 (BN 1253) -- Can you automatically split a vector layer based on an attribute in a field?

Simon Cropper scropper at botanicusaustralia.com.au
Thu May 6 04:37:06 CEST 2010


Hi Antonio and Ben,

Ben, Antonio is right. The "Separate Entities" option in Sextante is very 
buggy. When I tried it, it created multiple shapefiles with each shapefile's 
name incrementing in size until Java baulks at file names when they reach 254 
characters. None of the files created actually contain anything either.

That is, the directory where the files are saved have the following output 
(assuming original name is "TS" and field with attributes is "Name" and the 
first attribute "AUSTRALIAN GRAYLING". See below, not pretty, Huh!

As it was, none of the usual candidates could do this (gvSIG, OADE gvSIG, 
Sextante, OpenJUMP). I did however find that SAGA actually has this capability. 
It actually provided to methods! 

The first takes a shapefile and exports to shapefiles -- With just a few thousand 
records this took 30+ minutes as every reiteration of the routine appeared to 
open, insert the record, reindex and close the recipient files following every 
record (even if the next record was for the same species). Also, once the 
routine starts it can not be interrupted, even if you try and stop the 
process! 

The second option is not very intuitive. First you need to import the shapefile 
into a SAGA project (which presumably makes a SAGA shapefile) then split this 
imported shapefile based on the attributes. This creates a series of temporary 
SAGA files in cache (this took 1-2 seconds). Unfortunately it is not really 
obvious how to get these temporary files saved to separate shapefiles so I tried 
to exited SAGA, and like gvSIG, it recognised that the files were still in 
memory and asked if you want to save the files. You select all and within about 
20 seconds they are all saved to the project directory. Not bad. Fast when you 
know what you are doing but not very intuitive -- although this is an apt 
description for SAGA.

*********************** OUTPUT *************************************
tsAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLING.dbf
tsAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLING.shp
tsAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLING.shx
tsAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLING.dbf
tsAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLING.shp
tsAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLING.shx
tsAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLING.dbf
tsAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLING.shp
tsAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLING.shx
tsAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLING.dbf
tsAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLING.shp
tsAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLING.shx
tsAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLING.dbf
tsAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLING.shp
tsAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLING.shx
tsAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLING.dbf
tsAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLING.shp
tsAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLING.shx
tsAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLING.dbf
tsAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLING.shp
tsAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLING.shx
tsAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLING.dbf
tsAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLING.shp
tsAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLING.shx
tsAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLING.dbf
tsAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLING.shp
tsAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLINGAUSTRALIAN GRAYLING.shx
tsAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLING.dbf
tsAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLING.shp
tsAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN 
GRAYLING.shx
tsAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLING.dbf
tsAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLING.shp
tsAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLING.shx
tsAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLING.dbf
tsAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLING.shp
tsAUSTRALIAN GRAYLINGAUSTRALIAN GRAYLING.shx
tsAUSTRALIAN GRAYLING.dbf
tsAUSTRALIAN GRAYLING.shp
tsAUSTRALIAN GRAYLING.shx
 
-- 
Cheer Simon

	Simon Cropper
	Botanicus Australia Pty Ltd
	PO Box 160 Sunshine 3020
	P: 03 9311 5822. M: 041 830 3437
	W: http://www.botanicusaustralia.com.au
On Wednesday 05 May 2010 18:38:42 Antonio Falciano wrote:
> Il 05/05/2010 9.09, Benjamin Ducke ha scritto:
> > SEXTANTE has a tool "Separate entities" in its vector
> > layers toolbox that does exactly what you are looking for.
> 
> Hi all,
> a good starting point could be using "Separate entities" tool in
> SEXTANTE, however it's a bit buggy (see ticket 960 [1]). It
> substantially explodes the input layer into N output layers, where N is
> the number of features contained in the input layer, without taking in
> count that there could be many features with the same field value.
> Instead, I should use a batch file with ogr2ogr exploiting the -sql option.
> 
> Cheers,
> Antonio
> 
> > Il 05/05/2010 6.45, Simon Cropper (Botanicus Australia Pty Ltd) ha 
scritto:
> >> Hi,
> >>
> >> I have a shapefile of points representing the known locations of 20-30
> >> species.
> >>
> >> Is their any way I can point a routine at a table field and have it
> >> create multiple shapefiles based on the values in this field,
> >> essentially creating separate shapefiles for each species?
> 
> [1] http://forge.osor.eu/tracker/index.php?func=detail&aid=960
> 


More information about the Gvsig_internacional mailing list