[GRASS-user] v.in.ogr python-loop
Patrick_schirmer
patrick_GIS at gmx.ch
Fri Dec 10 05:09:08 EST 2010
Dear list,
Tried to import about 400.000 polygons through v.in.ogr from a
PG-database (basically shp-file). After 2 days the process got aborded
as you can see below. Supposedly the memory of my computer is not big
enough- at 51% of boundary break 1.7GB of memory where used.
So I would like to try import by looping and patching in a
python-script. I only started recently to combine GRASS with python and
don't know much of python at all, but I imagine this script should do
the job. Unfortunately the "Flags" are not recognized, although I tried
it in various ways "Flags, flags, flag, Flag, F". I will always get a
Feedback of "ERROR: Projection of dataset does not appear to match
current location....." which I want do ignore by using the flag "-o".
Any idea?
greetz, Patrick
##########PYTHONSCRIPT FOR LOOP####################################
#!/usr/bin/env python
#scipt is only help
#will import through loop
import os
import sys
import grass.script as grass
def main():
i=0
n=0
while i<2:
i=i+1
i=str(i)
grass.run_command(
'v.in.ogr', dsn="PG:dbname=schirpat", Flags="-o",
layer="sc.av_liegensch", output="GR_ZH_av_liegensch_poly"+i,
type="boundary,centroid", where="bfs="+i)
#grass.run.command(
#'v.patch',
input="GR_ZH_av_liegensch_poly"+i",GR_av_liegensch_poly",
output="GR_av_liegensch_poly", Flags="--overwrite")
if __name__ == "__main__":
main()
##############PREVIOUS DIRECT IMPORT VIA SHELL#########################
GRASS 7.0.svn (Survey):~ > v.in.ogr "dsn=PG:dbname=schirpat"
layer=sc.av_liegensch output=GR_ZH_av_liegensch_poly
type=boundary,centroid -o --o
Warning 1: Multi-column primary key in 'gwr_strassen' detected but not
supported.
Warning 1: Multi-column primary key in 'tt_iv' detected but not supported.
Warning 1: Multi-column primary key in 'gwr_adressen' detected but not
supported.
Warning 1: Multi-column primary key in 'tt_oev' detected but not supported.
Warning 1: Multi-column primary key in 'gwr_wohnungen' detected but not
supported.
Over-riding projection check
Layer: sc.av_liegensch
Counting polygons for 367314 features...
Importing map 367314 features...
100%
-----------------------------------------------------
Building topology for vector map <GR_ZH_av_liegensch_poly_tmp at survey>...
Registering primitives...
382467 primitives registered
27795398 vertices registered
Number of nodes: 369522
Number of primitives: 382467
Number of points: 0
Number of lines: 0
Number of boundaries: 382467
Number of centroids: 0
Number of areas: -
Number of isles: -
-----------------------------------------------------
WARNING: Cleaning polygons, result is not guaranteed!
-----------------------------------------------------
Break polygons:
100%
100%
-----------------------------------------------------
Remove duplicates:
100%
-----------------------------------------------------
Break boundaries:
100%
-----------------------------------------------------
Remove duplicates:
100%
-----------------------------------------------------
Clean boundaries at nodes:
100%
-----------------------------------------------------
Break boundaries:
Unexpected error.
Aborted
More information about the grass-user
mailing list