2010-11-21 22:43:57 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Written by Martin Spott
|
|
|
|
#
|
|
|
|
# Copyright (C) 2010 Martin Spott - Martin (at) flightgear (dot) org
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License as
|
|
|
|
# published by the Free Software Foundation; either version 2 of the
|
|
|
|
# License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful, but
|
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
#
|
|
|
|
|
|
|
|
# Create reasonable symlinks pointing to this script to return proper
|
|
|
|
# $MODE-values for the "case" clause, like 'grass05extract.sh_shp'
|
|
|
|
MODE=`basename ${0} | cut -f 2 -d \_`
|
|
|
|
|
|
|
|
DUMPDIR=${HOME}/shp
|
|
|
|
mkdir -p ${DUMPDIR}
|
|
|
|
RUNDIR=`pwd`
|
|
|
|
cd `dirname ${0}` && export BASEDIR=`pwd`
|
|
|
|
cd ${RUNDIR}
|
|
|
|
#
|
|
|
|
|
2012-01-25 09:05:25 +00:00
|
|
|
MAPPINGFILE=${BASEDIR}/CORINEtoCS.txt
|
2010-12-13 19:35:33 +00:00
|
|
|
#EXTRACTPREFIX=clc00_nl_
|
|
|
|
EXTRACTPREFIX=clc00_
|
2011-11-15 17:17:59 +00:00
|
|
|
CLEANMAP=${EXTRACTPREFIX}_dissolved
|
2010-11-21 22:43:57 +00:00
|
|
|
|
|
|
|
case ${MODE} in
|
|
|
|
shp)
|
|
|
|
# Re-project from EPSG:3035 - this one is _not_ to be run inside
|
|
|
|
# the import location !!!
|
2012-01-25 09:05:25 +00:00
|
|
|
v.proj location=corine_laea mapset=PERMANENT input=${CLEANMAP} # output=${CLEANMAP}
|
2010-11-21 22:43:57 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Print available (integer) categories - centroids only !!!
|
|
|
|
#
|
|
|
|
SELECTION=`v.category input=${CLEANMAP} type=centroid option=print | sort -n | uniq`
|
|
|
|
|
|
|
|
for CATEGORY in ${SELECTION}; do
|
|
|
|
LAYER=`grep \^${CATEGORY} ${MAPPINGFILE} | awk '{print $2}' | sed -e "s/^cs_/${EXTRACTPREFIX}/g"`
|
|
|
|
v.extract list=${CATEGORY} input=${CLEANMAP} output=${EXTRACTPREFIX}${CATEGORY} type=area
|
2010-12-13 19:35:33 +00:00
|
|
|
v.out.ogr input=${EXTRACTPREFIX}${CATEGORY} dsn=${DUMPDIR}/${LAYER}.shp
|
2010-11-21 22:43:57 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
# EOF
|