-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from forefireAPI/geojson
add geojsom dump mode fix #10
- Loading branch information
Showing
11 changed files
with
169 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,7 @@ __pycache__ | |
|
||
# compilation files | ||
*.dblite | ||
*.o | ||
*.o | ||
|
||
# editors | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
*.json | ||
*.geojson | ||
*.geojson | ||
*.ffgeojson |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
setParameter[dumpMode=geojson] | ||
setParameter[caseDirectory=.] | ||
setParameter[ForeFireDataDirectory=.] | ||
setParameter[projection=EPSG:32632] | ||
setParameter[fuelsTableFile=./fuels.ff] | ||
setParameter[propagationModel=Rothermel] | ||
setParameter[year=2022] | ||
setParameter[month=10] | ||
setParameter[day=27] | ||
loadData[landscape.nc;2009-07-24T11:37:39Z] | ||
startFire[loc=(516666.85406561225,4605385.548179354,0);t=0] | ||
step[dt=12000s] | ||
print[./*count*-*ISOdate*.ffgeojson] | ||
print[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import sys | ||
import json | ||
from pyproj import Transformer | ||
|
||
def load_json(file_path): | ||
with open(file_path, 'r') as f: | ||
data = json.load(f) | ||
return data | ||
|
||
def reproject(xy, inEpsg, outEpsg='epsg:4326'): | ||
[x1, y1] = xy | ||
transformer = Transformer.from_crs(inEpsg, outEpsg, always_xy=True) | ||
x2, y2 = transformer.transform(x1, y1) | ||
return [x2,y2] | ||
|
||
def ffjson2geojson(filepath): | ||
ff_geojson = load_json(filepath) | ||
|
||
#reproject | ||
inEpsg = ff_geojson['projection'].lower() | ||
for feature in ff_geojson["features"]: | ||
reproj = [reproject(xy, inEpsg) for xy in feature['geometry']['coordinates'][0]] | ||
reproj.append(reproj[0]) | ||
feature['geometry']['coordinates'][0] = reproj | ||
ff_geojson['projection'] = 'epsg:4326' | ||
|
||
#save | ||
fileextension = filepath.split('.')[-1] | ||
savePath = filepath.replace(f'.{fileextension}', '.geojson') | ||
with open(savePath, 'w', encoding='utf-8') as f: | ||
json.dump(ff_geojson, f, ensure_ascii=False, indent=4) | ||
|
||
|
||
if __name__ == '__main__': | ||
try: | ||
filepath = sys.argv[1] | ||
ffjson2geojson(filepath) | ||
except Exception as e: | ||
print(e) |
Oops, something went wrong.