diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..83bad14 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2016 Arie Kurniawan + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index e40818c..dba02cf 100644 --- a/README.md +++ b/README.md @@ -46,3 +46,10 @@ Please keep in mind that the current code expects the common geoJSON format with } ] } + +## how to use + +`$python3 geojson2shp -i /location/of/your/file.geojson` + +## output +> file.shp, file.shx, file.dbf, file.prj diff --git a/input/lines.geojson b/example/lines.geojson similarity index 99% rename from input/lines.geojson rename to example/lines.geojson index ca43554..03fe41b 100644 --- a/input/lines.geojson +++ b/example/lines.geojson @@ -62,4 +62,4 @@ } } ] -} \ No newline at end of file +} diff --git a/input/points.geojson b/example/points.geojson similarity index 99% rename from input/points.geojson rename to example/points.geojson index e55852d..faf334e 100644 --- a/input/points.geojson +++ b/example/points.geojson @@ -41,4 +41,4 @@ } } ] -} \ No newline at end of file +} diff --git a/input/polys.geojson b/example/polys.geojson similarity index 99% rename from input/polys.geojson rename to example/polys.geojson index 82729be..848fc7d 100644 --- a/input/polys.geojson +++ b/example/polys.geojson @@ -206,4 +206,4 @@ } } ] -} \ No newline at end of file +} diff --git a/geoJ.py b/geojson2shp.py similarity index 88% rename from geoJ.py rename to geojson2shp.py index c7f3d3c..c94cc07 100644 --- a/geoJ.py +++ b/geojson2shp.py @@ -1,7 +1,11 @@ -# The json module is needed to load the geoJSON file import json -# The shapefile, from pyshp, is needed to construct the shapefile object -import shapefile +import shapefile # The shapefile, from pyshp, is needed to construct the shapefile object +import argparse + +parser = argparse.ArgumentParser() +parser.add_argument("-i", type=str, required=True, dest='input',help='location of geojson file [ex: /path/to/file.geojson]') +#parser.add_argument("-o", type=str, required=True, dest='output',help='ouput location [ex: /path/to/outputname]') +args = parser.parse_args() class GeoJ: @@ -19,7 +23,7 @@ def __init__(self, geoJFile): try: self.geoJFile = open(geoJFile) except IOError: - print "Error: can not find file. Make sure the file name and path are correct" + print("Error: can not find file. Make sure the file name and path are correct") else: try: self.geoJObj = json.load(self.geoJFile) @@ -125,9 +129,8 @@ def __createPrjFile(self, shpFile): ########################## if __name__ == '__main__': - # Create an object from the GeoJ class - gJ = GeoJ('input/lines.geojson') + gJ = GeoJ(args.input) # Creating a shapefile from the geoJSON object - gJ.toShp('output/lines') + gJ.toShp(args.input) diff --git a/output/log.txt b/output/log.txt deleted file mode 100644 index 53a90bf..0000000 --- a/output/log.txt +++ /dev/null @@ -1 +0,0 @@ -Empty