FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
geospatialpython/subset.py at master · GeospatialPython/geospatialpython · GitHub
GeospatialPython
/
geospatialpython
Public
Notifications
You must be signed in to change notification settings
Fork
8
Star
14
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
geospatialpython
/
subset.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
20 lines (19 loc) · 667 Bytes
Breadcrumbs
geospatialpython
/
subset.py
Copy path
File metadata and controls
20 lines (19 loc) · 667 Bytes
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
import
shapefile
# Create a reader instance
r
=
shapefile
.
Reader
(
"buildingfootprints/Building_Footprint"
)
# Create a writer instance
w
=
shapefile
.
Writer
(
shapeType
=
shapefile
.
POLYGON
)
# Copy the fields to the writer
w
.
fields
=
list
(
r
.
fields
)
# Grab the geometry and records from all features
# with the correct county name
selection
=
[]
for
rec
in
enumerate
(
r
.
records
()):
if
rec
[
1
][
1
].
startswith
(
"Hancock"
):
selection
.
append
(
rec
)
# Add the geometry and records to the writer
for
rec
in
selection
:
w
.
_shapes
.
append
(
r
.
shape
(
rec
[
0
]))
w
.
records
.
append
(
rec
[
1
])
# Save the new shapefile
w
.
save
(
"buildingfootprints/HancockFootprints"
)
Back
|
FazBrowse Home
|
New Git URL