Skip to content

Commit

Permalink
Merged branches, added TODO notes and more information to the README
Browse files Browse the repository at this point in the history
  • Loading branch information
wildintellect committed Apr 17, 2012
1 parent 76006a2 commit 29bd26f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
32 changes: 28 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,31 @@
PyGraticule
================

#About

Python script to generate a graticule that will project cleanly (with smooth arcs) at world scale. The graticule should have a dense distribution of internal nodes along it's line, especially along the ±180, ±90 WGS84 bounding box.

Output format is geojson, because it's easy to write as a text file in python. Use ogr2ogr to convert to a SHP file.
##History

Script was originally written as a demonstration for students in Intro to GIS programming with python. Output format is geojson, because it's easy to write as a text file in python. Use ogr2ogr to convert to a SHP file.

##License

By **Alex Mandel** Copyright 2012.
Modifications by Nathaniel Vaughn KELSO.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.


#Usage

`python pygraticule.py -s 1 -o outfile.geojson`
Expand All @@ -22,6 +41,8 @@ There are two script arguments for controlling the density of nodes and the outp

* The output is a GeoJSON format file, not a SHP format Esri Shapefile.

* Graticule is created in local coordinates (purely numeric).

## Examples

When we project out of WGS84 to another coordinate system that is not cylindrical, we need to have enough intermediate nodes
Expand All @@ -30,12 +51,15 @@ so we need to add these extra nodes in the raw geodata.

Here we see Robinson using enough nodes:

![Zoom previews](https://github.com/nvkelso/pygraticule/raw/master/images/robinson.png)
![Zoom previews](https://github.com/wildintellect/pygraticule/raw/master/images/robinson.png)

Box results when nodes are sparse:

![Zoom previews](https://github.com/nvkelso/pygraticule/raw/master/images/box_no_densification.png)
![Zoom previews](https://github.com/wildintellect/pygraticule/raw/master/images/box_no_densification.png)

The two superimposed:

![Zoom previews](https://github.com/nvkelso/pygraticule/raw/master/images/robinson_plus_box.png)
![Zoom previews](https://github.com/wildintellect/pygraticule/raw/master/images/robinson_plus_box.png)

Comparison to QGIS graticule creator which only makes nodes where lines intersect:
![Zoom previews](https://github.com/wildintellect/pygraticule/raw/master/images/robinson_30d_compare.png)
Binary file added images/robinson_30d_compare.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion pygraticule.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import os, stat
from optparse import OptionParser

#TODO: Take bounding box as arg for setting range

parser = OptionParser(usage="""%prog [options]
Generates a GeoJSON file with graticules spaced at specified interval.""")
Expand All @@ -31,6 +33,7 @@
parser.add_option('-o', dest='outfilename', default='',
help='Output filename (with or without path), defaults to "graticule_1dd.geojson".')

#TODO: Implement python OGR writing for multiple output format support.
#parser.add_option('-p', '--shp', dest='shapefile', default=False, type='boolean",
# help='Output a SHP file, defaults to False and requires ORG/GDAL.')

Expand All @@ -39,6 +42,7 @@


#set the stepping of the increment, converting from string to interger
#TODO: Calculate a node density based on the bounding box and interval defined by the user
step = options.step_interval
# destination file
out_file = options.outfilename
Expand Down Expand Up @@ -137,4 +141,4 @@
# try:
# ogr2ogr -f "ESRI Shapefile" out_file out_file
# except:
# pass
# pass

0 comments on commit 29bd26f

Please sign in to comment.