Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion input/lines.geojson → example/lines.geojson
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@
}
}
]
}
}
2 changes: 1 addition & 1 deletion input/points.geojson → example/points.geojson
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@
}
}
]
}
}
2 changes: 1 addition & 1 deletion input/polys.geojson → example/polys.geojson
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,4 @@
}
}
]
}
}
17 changes: 10 additions & 7 deletions geoJ.py → geojson2shp.py
Original file line number Diff line number Diff line change
@@ -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:

Expand All @@ -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)
Expand Down Expand Up @@ -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)
1 change: 0 additions & 1 deletion output/log.txt

This file was deleted.