You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+71-41Lines changed: 71 additions & 41 deletions
Original file line number
Diff line number
Diff line change
@@ -1,23 +1,45 @@
1
1
shell_scripts
2
2
=============
3
3
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.
6
7
7
8
## 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`
9
20
10
-
Make sure ogr2ogr is working in command line with basic command: `ogr2ogr`
21
+
You should get back something like:
11
22
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.
13
26
14
27
## Reference Material
15
28
These resources have helped me a lot in building the `ogr2ogr` batch commands:
29
+
16
30
*[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.
18
33
*[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.
19
39
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`).
20
41
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.
21
43
22
44
## Scripts
23
45
*[clip-extent-project.sh](#clip-extent-projectsh)
@@ -38,29 +60,32 @@ These resources have helped me a lot in building the `ogr2ogr` batch commands:
38
60
39
61
### clip-extent-project.sh
40
62
#### 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.
42
64
#### Supported Types
43
-
`.abc`
65
+
ESRI Shapefile
44
66
#### Usage
45
-
`./xxx_yyy.sh $ARGS`
67
+
`cd` to the directory of your `.shp` data
68
+
`./clip-extent-project.sh`
46
69
#### Sample Output
47
70
`test`
48
71
### clip-raster-to-shp.sh
49
72
#### Description
50
-
This does xyz for abc.
73
+
Clips a raster dataset to a shapefile polygon. Both datasets must be in the same projection.
projects data to google web-mercator projection `EPSG:900913`
116
144
#### Supported Types
117
-
`.abc`
145
+
`.shp`
118
146
#### Usage
119
-
`./xxx_yyy.sh $ARGS`
147
+
`./project-google.sh`
120
148
#### Sample Output
121
149
`test`
122
150
### project-mercator.sh
123
151
#### Description
124
-
This does xyz for abc.
152
+
projects data to WGS 94 / World Mercator `EPSG:3395`
125
153
#### Supported Types
126
-
`.abc`
154
+
`.shp`
127
155
#### 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`
129
159
#### Sample Output
130
160
`test`
131
161
### project-wgs84.sh
132
162
#### Description
133
-
This does xyz for abc.
163
+
Projects data to WGS 84 `EPSG:4326`
134
164
#### Supported Types
135
-
`.abc`
165
+
`.shp`
136
166
#### Usage
137
-
`./xxx_yyy.sh $ARGS`
167
+
`./project-wgs84.sh`
138
168
#### Sample Output
139
169
`test`
140
170
### rename-files-gis-friendly.sh
141
171
#### 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
143
174
#### Supported Types
144
175
`.abc`
145
176
#### Usage
@@ -148,23 +179,23 @@ This does xyz for abc.
148
179
`test`
149
180
### separate-roads-by-type.sh
150
181
#### 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.
152
183
#### Supported Types
153
-
`.abc`
184
+
`.shp`
154
185
#### Usage
155
-
`./xxx_yyy.sh $ARGS`
186
+
`./separate-roads-by-type.sh`
156
187
#### Sample Output
157
188
`test`
158
189
### separate-roads-by-type-skeletron.sh
159
190
#### Description
160
-
This does xyz for abc.
191
+
Same as above but uses input generated from Michael Migurski's [Skeletron.py]() script
161
192
#### Supported Types
162
193
`.abc`
163
194
#### Usage
164
195
`./xxx_yyy.sh $ARGS`
165
196
#### Sample Output
166
197
`test`
167
-
### sshp-to-geojson.sh
198
+
### shp-to-geojson.sh
168
199
#### Description
169
200
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`.
170
201
#### Supported Types
@@ -173,4 +204,3 @@ This converts all shapefiles in a directory `$DIR1` into geoJSON files in `$DIR2
0 commit comments