FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
utilities/python/createCSVFromGEOJSON.py at master · SpaceNetChallenge/utilities · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
This repository was archived by the owner on Jul 2, 2019. It is now read-only.
SpaceNetChallenge
/
utilities
Public archive
Notifications
You must be signed in to change notification settings
Fork
94
Star
249
Code
Issues
23
Pull requests
7
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
utilities
/
python
/
createCSVFromGEOJSON.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
81 lines (63 loc) · 2.99 KB
Breadcrumbs
utilities
/
python
/
createCSVFromGEOJSON.py
Copy path
File metadata and controls
81 lines (63 loc) · 2.99 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
from
spaceNetUtilities
import
labelTools
as
lT
import
os
import
glob
import
argparse
if
__name__
==
"__main__"
:
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"-imgDir"
,
"--imgDir"
,
type
=
str
,
help
=
"Directory of Raster Images"
)
parser
.
add_argument
(
"-geoDir"
,
"--geojsonDir"
,
type
=
str
,
help
=
"Directory of geojson files"
)
parser
.
add_argument
(
"-o"
,
"--outputCSV"
,
type
=
str
,
help
=
"Output File Name and Location for CSV"
)
parser
.
add_argument
(
"-pixPrecision"
,
"--pixelPrecision"
,
type
=
int
,
help
=
"Number of decimal places to include for pixel, uses round(xPix, pixPrecision)"
"Default = 2"
,
default
=
2
)
parser
.
add_argument
(
"--CreateProposalFile"
,
help
=
"Create ProposalsFile"
,
action
=
"store_true"
)
parser
.
add_argument
(
"-strip"
,
"--stripOutFromGeoJson"
,
type
=
str
,
help
=
"string delimited"
)
parser
.
add_argument
(
"--DontstripFirstUnderScore"
,
action
=
"store_false"
)
args
=
parser
.
parse_args
()
rasterDirectory
=
args
.
imgDir
geoJsonDirectory
=
args
.
geojsonDir
outputCSVFileName
=
args
.
outputCSV
createProposalFile
=
args
.
CreateProposalFile
if
args
.
stripOutFromGeoJson
:
stripList
=
args
.
stripOutFromGeoJson
.
split
(
' '
)
else
:
stripList
=
[]
#band3directory = '/usr/local/share/data/AOI_1_RIO/processed2/3band'
#band8directory = '/usr/local/share/data/AOI_1_RIO/processed2/8band'
#geoJsonDirectory = '/usr/local/share/data/AOI_1_RIO/processed2/geojson'
jsonList
=
[]
chipSummaryList
=
[]
#AOI_2_RIO_3Band_img997.tif
#AOI_2_RIO_img635.geojson
# find RasterPrecursor
rasterList
=
glob
.
glob
(
os
.
path
.
join
(
rasterDirectory
,
'*.tif'
))
rasterPrefix
=
os
.
path
.
basename
(
rasterList
[
0
])
rasterPrefix
=
rasterPrefix
.
split
(
"_"
)[
0
]
geoJsonList
=
glob
.
glob
(
os
.
path
.
join
(
geoJsonDirectory
,
'*.geojson'
))
for
imageId
in
geoJsonList
:
imageId
=
os
.
path
.
basename
(
imageId
)
rasterName
=
imageId
.
replace
(
'.geojson'
,
'.tif'
)
for
stripItem
in
stripList
:
rasterName
=
rasterName
.
replace
(
stripItem
,
''
)
if
args
.
DontstripFirstUnderScore
:
rasterName
=
rasterPrefix
+
"_"
+
rasterName
.
split
(
'_'
,
1
)[
1
]
else
:
rasterName
=
rasterPrefix
+
"_"
+
rasterName
print
(
imageId
)
print
(
os
.
path
.
join
(
rasterDirectory
,
rasterName
))
chipSummary
=
{
'chipName'
:
os
.
path
.
join
(
rasterDirectory
,
rasterName
),
'geoVectorName'
:
os
.
path
.
join
(
geoJsonDirectory
,
imageId
),
'imageId'
:
os
.
path
.
splitext
(
imageId
)[
0
]}
chipSummaryList
.
append
(
chipSummary
)
print
(
"starting"
)
lT
.
createCSVSummaryFile
(
chipSummaryList
,
outputCSVFileName
,
replaceImageID
=
rasterPrefix
+
"_"
,
createProposalsFile
=
createProposalFile
,
pixPrecision
=
args
.
pixelPrecision
)
print
(
"finished"
)
Back
|
FazBrowse Home
|
New Git URL