FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
geospatialpython/editshp.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
/
editshp.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
26 lines (26 loc) · 955 Bytes
Breadcrumbs
geospatialpython
/
editshp.py
Copy path
File metadata and controls
26 lines (26 loc) · 955 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
21
22
23
24
25
26
import
shapefile
# Polygon shapefile we are updating.
# We must include a file extension in
# this case because the file name
# has multiple dots and pyshp would get
# confused otherwise.
file_name
=
"ep202009.026_5day_pgn.shp"
# Create a shapefile reader
r
=
shapefile
.
Reader
(
file_name
)
# Create a shapefile writer
# using the same shape type
# as our reader
w
=
shapefile
.
Writer
(
r
.
shapeType
)
# Copy over the existing dbf fields
w
.
fields
=
list
(
r
.
fields
)
# Copy over the existing dbf records
w
.
records
.
extend
(
r
.
records
())
# Copy over the existing polygons
w
.
_shapes
.
extend
(
r
.
shapes
())
# Add a new polygon
w
.
poly
(
parts
=
[[[
-
104
,
24
],[
-
104
,
25
],[
-
103
,
25
],[
-
103
,
24
],[
-
104
,
24
]]])
# Add a new dbf record for our polygon making sure we include
# all of the fields in the original file (r.fields)
w
.
record
(
"STANLEY"
,
"TD"
,
"091022/1500"
,
"27"
,
"21"
,
"48"
,
"ep"
)
# Overwrite the old shapefile or change the name and make a copy
w
.
save
(
file_name
)
Back
|
FazBrowse Home
|
New Git URL