Skip to content

Commit

Permalink
wip: Provide a job to scrape BDPR #2
Browse files Browse the repository at this point in the history
  • Loading branch information
Christophe Nouguier committed Apr 27, 2020
1 parent aad1850 commit 289ed73
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions geoservices.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#/!bin/sh

ARCHIVE=$1
HOST=$2
USER=$3
PASS=$4

# donwload the archive
# note: wget stuck in passive mode and curl is really slow
echo "<> downloading $ARCHIVE from $HOST"
lftp -u $USER,$PASS $HOST -e "get $ARCHIVE; bye"

# extract the archive
echo "<> extracting $ARCHIVE"
rm -fr dataset
7z x $ARCHIVE -odataset

# find the shape files
SHAPES=`find dataset -name *.shp`

# iterate though the files and convert them using mapshaper
echo "<> converting files"
WORKDIR=`pwd`
for SHAPE in $SHAPES; do
echo processing $SHAPE
SHAPE_PATH=`dirname "${SHAPE}"`
SHAPE_BASENAME=`basename "${SHAPE}"`
JSON_BASENAME=`echo $SHAPE_BASENAME | sed -e 's/.shp/.geojson/g'` # cannot use variable substitution as we are running in shell not bash
echo converting $SHAPE_BASENAME in $JSON_BASENAME
cd $SHAPE_PATH
mapshaper -i $SHAPE_BASENAME -o format=geojson precision=0.000001 $JSON_BASENAME
cd $WORKDIR
done

0 comments on commit 289ed73

Please sign in to comment.