Skip to content

Instantly share code, notes, and snippets.

@cayetanobv
Last active January 17, 2020 09:34
Show Gist options
  • Save cayetanobv/8f9ddb97b9831b5ae471660a48de4342 to your computer and use it in GitHub Desktop.
Save cayetanobv/8f9ddb97b9831b5ae471660a48de4342 to your computer and use it in GitHub Desktop.
#!/bin/bash
GCP_01="388.46002441, 196.62191858 -19555.91116009, 6710435.00801315"
GCP_02="573.11678317, 200.93739002 -19476.82479038, 6710449.74596497"
GCP_03="634.76211884, 304.41287333 -19457.77228947, 6710500.17824991"
GCP_04="481.83055224, 322.38714778 -19527.40774212, 6710498.41133932"
DATA_SOURCE=rgs.dxf
SRC_EPSG=3857
DST_EPSG=3857
ogr2ogr -f 'GPKG' \
rgs_poly.gpkg \
$DATA_SOURCE \
-s_srs EPSG:$SRC_EPSG \
-a_srs EPSG:$DST_EPSG \
-geomfield the_geom \
-nlt POLYGON \
-where "LAYER like 'POL%'" \
-gcp $GCP_01 \
-gcp $GCP_02 \
-gcp $GCP_03 \
-gcp $GCP_04 \
&& ogr2ogr -f 'GPKG' \
rgs_line.gpkg \
$DATA_SOURCE \
-s_srs EPSG:$SRC_EPSG \
-a_srs EPSG:$DST_EPSG \
-geomfield the_geom \
-nlt MULTILINESTRING \
-where "LAYER like 'LIN%'" \
-gcp $GCP_01 \
-gcp $GCP_02 \
-gcp $GCP_03 \
-gcp $GCP_04 \
&& ogr2ogr -f 'GeoJSON' \
rgs_poly.geojson \
rgs_poly.gpkg \
-s_srs EPSG:$SRC_EPSG \
-t_srs EPSG:4326 \
&& ogr2ogr -f 'GeoJSON' \
rgs_line.geojson \
rgs_line.gpkg \
-s_srs EPSG:$SRC_EPSG \
-t_srs EPSG:4326
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment