-
Notifications
You must be signed in to change notification settings - Fork 345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add own plot method and data.py to CBF #410
Changes from all commits
2ad9803
a2923c8
022db94
f85f60f
531b2fb
b7915f1
60bab6b
46dc0a8
c35e748
f46b77b
70ea7ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1 @@ | ||
{ | ||
"type": "FeatureCollection", | ||
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, | ||
"features": [ | ||
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 0.0, 0.0 ], [ 0.0, 1.0 ], [ 1.0, 1.0 ], [ 1.0, 0.0 ], [ 0.0, 0.0 ] ] ] } } | ||
] | ||
} | ||
{"type": "FeatureCollection", "crs": {"type": "name", "properties": {"name": "urn:ogc:def:crs:OGC:1.3:CRS84"}}, "features": [{"type": "Feature", "properties": {}, "geometry": {"type": "Polygon", "coordinates": [[[0.0, 0.0], [0.0, 1.0], [1.0, 1.0], [1.0, 0.0], [0.0, 0.0]]]}}]} |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
|
||
import hashlib | ||
import json | ||
import os | ||
import shutil | ||
|
||
|
||
def create_geojson(): | ||
geojson = { | ||
"type": "FeatureCollection", | ||
"crs": { | ||
"type": "name", | ||
"properties": {"name": "urn:ogc:def:crs:OGC:1.3:CRS84"}, | ||
}, | ||
"features": [ | ||
{ | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"type": "Polygon", | ||
"coordinates": [ | ||
[[0.0, 0.0], [0.0, 1.0], [1.0, 1.0], [1.0, 0.0], [0.0, 0.0]] | ||
], | ||
}, | ||
} | ||
], | ||
} | ||
return geojson | ||
|
||
|
||
if __name__ == "__main__": | ||
filename = "Alberta.zip" | ||
geojson = create_geojson() | ||
|
||
with open(filename.replace(".zip", ".geojson"), "w") as f: | ||
json.dump(geojson, f) | ||
|
||
# compress single file directly with no directory | ||
shutil.make_archive( | ||
filename.replace(".zip", ""), | ||
"zip", | ||
os.getcwd(), | ||
filename.replace(".zip", ".geojson"), | ||
) | ||
|
||
# Compute checksums | ||
with open(filename, "rb") as f: | ||
md5 = hashlib.md5(f.read()).hexdigest() | ||
print(f"{filename}: {md5}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since CBF was the only
VectorDataset
, and since it overrides theplot
method, this code was no longer being tested. We have a few options:VectorDataset.plot
The benefit of 1 is that it is the least code. The benefit of 2-4 is that they add mypy checks to ensure that all subclasses use the same signature. The benefit of 4 is that it prevents someone from adding a new subclass that doesn't implement plot. The downside of 4 is that it means you can't instantiate a
VectorDataset
directly.I forget where we discussed this already, but I have a slight preference for 4 because it seems like "the right thing to do", and @calebrob6 has a slight preference for 3 because it allows you to use
VectorDataset
directly without creating a subclass. I think 1 and 2 are valid options too. Interested in hearing other opinions on this one.Note that this will also affect
RasterDataset
once we finish adding individualplot
methods to all classes.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if our plotting code has enough in common that we could define one or two
plot
methods inVisionDataset
andGeoDataset
and then have each subclass call super with the appropriate arguments.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does anyone have any opinions on this? We should make this decision so we can finish adding plot methods to all GeoDatasets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do have a good bit of duplication, but I think a utility function would be better for the average case as there are some really whacky plots.