[Qgis-user] Selecting polygons on attribute - Trying OGR

Micha Silver micha at arava.co.il
Tue Jul 24 10:11:36 PDT 2012


On 07/24/2012 07:07 PM, Zoltan Szecsei wrote:
> On 2012/07/24 17:39, Micha Silver wrote:
>> On 07/24/2012 06:34 PM, Zoltan Szecsei wrote:
>>> On 2012/07/24 17:29, Andre Joost wrote:
>>>> Am 24.07.2012 17:21, schrieb Micha Silver:
>>>>
>>>>>
>>>>> I think the problem is the attribute column name begins with a 
>>>>> digit. Look what
>>>>> happens when I rename my column from above to 21Name:
>>>>>
>>>>
>>>> In the Qgis query form, no error is produced, but all elements are 
>>>> 'found' after renaming the field name to another beginning with 
>>>> numbers.
>>> Do you mean all 1.1m, or my subset of 545663 records that start with 
>>> C016?
>>> Can't find anywhere in QGis to change the fields name :-(
>>
>> Use the Table Manager plugin. (or just open the dbf in OpenOffice and 
>> change *only* the name of the column)
> Which is the Table Manager plugin? I'm just browsing QGIS plugins 
> repository and cannot see anything like this.
>
> I tried with OpenOffice 3.3 on both 64 & 32 bit Win 7, but the job 
> disappears and task manager shows that it is just eating up memory 
> (over 600MB after 10 minutes, and climbing).
>

Oh sorry, you said 1M polys. That's way too much for OpenOffice. Sorry 
for misleading...

Well, back to my first idea: Move into a spatialite DB?

Here's a page of the "Spatialite Cookbook" that explains exactly how to 
SELECT a set of features into a new table, and export the selected 
features back to a new shapefile.

http://www.gaia-gis.it/gaia-sins/spatialite-cookbook/html/impexp.html

Briefly:
# Create a new DB:
spatialite erf.sqlite
# You are now in the sqlite interface. To load a shapefile:
 > .loadshp /mnt/geo_lvm0/SGO_cadastral/200909/WC/Erf erf LATIN1 <SRID>

# *You'll have to set the correct EPSG code as the SRID above for the 
shapefile,
# and choose the appropriate encoding.
*
# Create new table for the selected polys
*> CREATE TABLE zerf (*
*> PK_UID INTEGER PRIMARY KEY AUTOINCREMENT,*
*# add all the other columns you need from the original*
*> "DigitKey21" Text,*
*> );*
*# Now make it spatial
 > SELECT AddGeometryColumn('zerf', 'Geometry', <SRID>, 'MULTIPOLYGON', 
'XY');*
*

# And Insert SELECTed rows into the new table
 > INSERT INTO zerf (DigitKey21, ..., ..., Geometry)
 > (SELECT 21DigitKey, ...,..., Geometry) FROM erf
 > WHERE 21DigitKey LIKE 'CO16%';

# Finally export to shapefile
 > .dumpshp zerf Geometry zerf_filtered LATIN1

#Should create a shapefile "zerf_filtered.shp" in current directory

HTH,
Micha
*
> Thanks,
> Z
>>
>>>
>>>>
>>>> Greetings,
>>>> André Joost
>>>>
>>>> _______________________________________________
>>>> Qgis-user mailing list
>>>> Qgis-user at lists.osgeo.org
>>>> http://lists.osgeo.org/mailman/listinfo/qgis-user
>>>
>>>
>>
>>
>> -- 
>> Micha Silver
>> GIS Consultant, Arava Development Co.
>> http://www.surfaces.co.il
>
>
> -- 
>
> ===========================================
> Zoltan Szecsei PrGISc [PGP0031]
> Geograph (Pty) Ltd.
> P.O. Box 7, Muizenberg 7950, South Africa.
>
> 65 Main Road, Muizenberg 7945
> Western Cape, South Africa.
>
> 34° 6'16.35"S 18°28'5.62"E
>
> Tel: +27-21-7884897  Mobile: +27-83-6004028
> Fax: +27-86-6115323www.geograph.co.za
> ===========================================
>
>
> This mail was received via Mail-SeCure System.


-- 
Micha Silver
GIS Consultant, Arava Development Co.
http://www.surfaces.co.il




More information about the Qgis-user mailing list