Skip to content

Commit 5dd9528

Browse files
committed
Update README.md
1 parent cdd60fb commit 5dd9528

File tree

1 file changed

+71
-41
lines changed

1 file changed

+71
-41
lines changed

README.md

Lines changed: 71 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,45 @@
11
shell_scripts
22
=============
33

4-
bash shell scripts
5-
for batch geoprocessing spatial data using [OGR2OGR](http://www.gdal.org/ogr2ogr.html)
4+
Bash shell scripts primarily for batch geoprocessing spatial data using the OGR2OGR utility, a part of the Geospatial Data Abstract Library: [GDAL](http://www.gdal.org/ogr2ogr.html)
5+
6+
There are a few other scripts in here for doing other useful things.
67

78
## Requirements
8-
Install FWTools (I used the Linux 64-bit version which is [here](http://fwtools.maptools.org/linux-experimental.html).
9+
####Mac OS X:
10+
Install GDAL Complete framework package via [King Chaos](http://www.kyngchaos.com/software/qgis)
11+
Be sure to follow the instructions for adding the path to your bash_profile or bashrc.
12+
13+
####Linux:
14+
15+
Install FWTools (I used the Linux 64-bit version which is [here](http://fwtools.maptools.org/linux-experimental.html).
16+
17+
####Test:
18+
19+
Make sure ogr2ogr is working in command line with basic command: `ogrinfo --version`
920

10-
Make sure ogr2ogr is working in command line with basic command: `ogr2ogr`
21+
You should get back something like:
1122

12-
I suppose you could just add the shell_scripts directory to your `PATH`, but I just run the commands with the full file path.
23+
GDAL 1.10.0, released 2013/04/24
24+
25+
You can either add the shell_scripts directory to your `PATH` or run the commands with the full file path.
1326

1427
## Reference Material
1528
These resources have helped me a lot in building the `ogr2ogr` batch commands:
29+
1630
* [Directory of Spatial Reference Systems (SRS)](http://spatialreference.org/ref/)
17-
* FYI, GitHub currently likes (i.e., requires) `urn:ogc:def:crs:OGC:1.3:CRS84` for displaying geoJSON.
31+
32+
* FYI, GitHub currently likes (i.e., requires) `urn:ogc:def:crs:OGC:1.3:CRS84` for displaying geoJSON.
1833
* [List of OGR-supported Vector Formats](http://www.gdal.org/ogr/ogr_formats.html)...*so many options!*
34+
*
35+
* This [Unix shell scripting tutorial](https://supportweb.cs.bham.ac.uk/documentation/tutorials/docsystem/build/tutorials/unixscripting/unixscripting.html)
36+
37+
##FAQ
38+
The scripts I authored in this repository were written while working with Cartographic Design software that primarily uses the ESRI Shapefile format. Thus most of these scripts assume that is your data format unless otherwise specified. Use the `shp-to-geojson` and `geojson-to-shp` scripts to convert data between these two common data formats as needed.
1939

40+
Many of these scripts contain variables that must be edited to in order to change their paramaters. I plan on updating this in the future as I originally wrote these when first learning bash scripting and did not fully understand how to implement $ARGV when running a script. For now open the scripts with a text editor and change variables for things like output projection (eg: `$T_SRS`).
2041

42+
You will have to set the executible permission for these scripts before you can run them. `cd` to the folder in which they live and `chmod +ux *` to make them executible.
2143

2244
## Scripts
2345
* [clip-extent-project.sh](#clip-extent-projectsh)
@@ -38,29 +60,32 @@ These resources have helped me a lot in building the `ogr2ogr` batch commands:
3860

3961
### clip-extent-project.sh
4062
#### Description
41-
This does xyz for abc.
63+
Clips data given bounding box coordinates and projects to an output CRS. Change variable assignments within the script for these parameters.
4264
#### Supported Types
43-
`.abc`
65+
ESRI Shapefile
4466
#### Usage
45-
`./xxx_yyy.sh $ARGS`
67+
`cd` to the directory of your `.shp` data
68+
`./clip-extent-project.sh`
4669
#### Sample Output
4770
`test`
4871
### clip-raster-to-shp.sh
4972
#### Description
50-
This does xyz for abc.
73+
Clips a raster dataset to a shapefile polygon. Both datasets must be in the same projection.
5174
#### Supported Types
52-
`.abc`
75+
`.shp` and GDAL supported raster formats.
5376
#### Usage
54-
`./xxx_yyy.sh $ARGS`
77+
`./clip-raster-to-shp.sh polygon-to-clip-to.shp raster-data.tiff`
5578
#### Sample Output
5679
`test`
5780
### clip-to-polygon.sh
5881
#### Description
59-
This does xyz for abc.
82+
clips all data to a shapefile polygon
6083
#### Supported Types
61-
`.abc`
84+
`.shp`
6285
#### Usage
63-
`./xxx_yyy.sh $ARGS`
86+
Edit the `CLIP` variable in the script to specify the clipping polygon.
87+
`cd` to directory containing `.shp` data
88+
`./clip-to-polygon.sh`
6489
#### Sample Output
6590
`test`
6691
### geojson-to-shp.sh
@@ -70,13 +95,12 @@ This script will export all .geojson files in a directory to .shp files in a spe
7095
`.geojson`
7196
#### Usage
7297
`cd` to the directory of `.geojson` files you want to convert
73-
7498
`./$SCRIPTHOME/geojson-to-shp.sh`
7599
#### Sample Output
76100
Writes new files to a `data` subdirectory.
77101
### get-extent.sh
78102
#### Description
79-
This does xyz for abc.
103+
returns bounding box coordinates for a dataset
80104
#### Supported Types
81105
`.shp`
82106
#### Usage
@@ -85,61 +109,68 @@ This does xyz for abc.
85109
`-84.391994 33.758135 -84.376599 33.754353`
86110
### gpx-to-shp.sh
87111
#### Description
88-
This does xyz for abc.
112+
converts `.gpx` files to `.shp` format
89113
#### Supported Types
90-
`.abc`
114+
`.gpx`
91115
#### Usage
92116
`./xxx_yyy.sh $ARGS`
93117
#### Sample Output
94118
`test`
95119
### grep-find-replace.sh
96120
#### Description
97-
This does xyz for abc.
121+
search through files in a directory and perform a find and replace.
98122
#### Supported Types
99-
`.abc`
123+
`.txt, .html, .css, etc.`
100124
#### Usage
101-
`./xxx_yyy.sh $ARGS`
125+
`./grep-find-replace.sh`
102126
#### Sample Output
103127
`test`
104128
### merge.sh
105129
#### Description
106-
This does xyz for abc.
130+
merges a directory of shapefiles.
107131
#### Supported Types
108-
`.abc`
132+
`.shp`
109133
#### Usage
110-
`./xxx_yyy.sh $ARGS`
134+
`cd` to the folder containing files to merge
135+
copy a shapefile to merge other shapefiles to by doing
136+
`ogr2ogr merge.shp shapefile-to-merge-everything-to.shp`
137+
then do
138+
`./merge.sh`
111139
#### Sample Output
112140
`test`
113141
### project-google.sh
114142
#### Description
115-
This does xyz for abc.
143+
projects data to google web-mercator projection `EPSG:900913`
116144
#### Supported Types
117-
`.abc`
145+
`.shp`
118146
#### Usage
119-
`./xxx_yyy.sh $ARGS`
147+
`./project-google.sh`
120148
#### Sample Output
121149
`test`
122150
### project-mercator.sh
123151
#### Description
124-
This does xyz for abc.
152+
projects data to WGS 94 / World Mercator `EPSG:3395`
125153
#### Supported Types
126-
`.abc`
154+
`.shp`
127155
#### Usage
128-
`./xxx_yyy.sh $ARGS`
156+
change the `-s_srs` input to your data's source CRS
157+
then `cd` to the folder containing your data and do
158+
`./project-mercator.sh`
129159
#### Sample Output
130160
`test`
131161
### project-wgs84.sh
132162
#### Description
133-
This does xyz for abc.
163+
Projects data to WGS 84 `EPSG:4326`
134164
#### Supported Types
135-
`.abc`
165+
`.shp`
136166
#### Usage
137-
`./xxx_yyy.sh $ARGS`
167+
`./project-wgs84.sh`
138168
#### Sample Output
139169
`test`
140170
### rename-files-gis-friendly.sh
141171
#### Description
142-
This does xyz for abc.
172+
changes filenames in directory to be GIS friendly:
173+
removes all white spaces and makes name lowercase
143174
#### Supported Types
144175
`.abc`
145176
#### Usage
@@ -148,23 +179,23 @@ This does xyz for abc.
148179
`test`
149180
### separate-roads-by-type.sh
150181
#### Description
151-
This does xyz for abc.
182+
Takes an OpenStreetMap `roads.shp` file extracted from [bbbike.org](http://extract.bbbike.org) and parses into multiple shapefiles based on the `type` field.
152183
#### Supported Types
153-
`.abc`
184+
`.shp`
154185
#### Usage
155-
`./xxx_yyy.sh $ARGS`
186+
`./separate-roads-by-type.sh`
156187
#### Sample Output
157188
`test`
158189
### separate-roads-by-type-skeletron.sh
159190
#### Description
160-
This does xyz for abc.
191+
Same as above but uses input generated from Michael Migurski's [Skeletron.py]() script
161192
#### Supported Types
162193
`.abc`
163194
#### Usage
164195
`./xxx_yyy.sh $ARGS`
165196
#### Sample Output
166197
`test`
167-
### sshp-to-geojson.sh
198+
### shp-to-geojson.sh
168199
#### Description
169200
This converts all shapefiles in a directory `$DIR1` into geoJSON files in `$DIR2`. If `$DIR1` is not specified, the script looks in the present working directory. If `$DIR2` is not specificied, the script will place the new geoJSON files in a new subdirectory called `geojson`.
170201
#### Supported Types
@@ -173,4 +204,3 @@ This converts all shapefiles in a directory `$DIR1` into geoJSON files in `$DIR2
173204
`./shp-to-geojson.sh $DIR1 $DIR2`
174205
#### Sample Output
175206
`converting file: /data/bike_lanes.shp...`
176-

0 commit comments

Comments
 (0)