-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding very simple read-shapefile function
- Loading branch information
Showing
3 changed files
with
33 additions
and
13 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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
import shapefile | ||
|
||
def extract_polyline_from_shapefile(s): | ||
""" | ||
:param s: shapefile.shape | ||
returns: list of lon, list of lat | ||
""" | ||
return [coord[0] for coord in s.points], [coord[1] for coord in s.points]; | ||
|
||
|
||
def read_one_fault_from_shapefile(shape_file, fault_index): | ||
""" | ||
A wrapper for extracting lon/lat from a fault in a shapefile. | ||
One could also extract shapes = sf.shapes() | ||
""" | ||
sf = shapefile.Reader(shape_file); | ||
lonarray1, latarray1 = extract_polyline_from_shapefile(sf.shape(fault_index)); | ||
return lonarray1, latarray1; |
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,13 @@ | ||
|
||
|
||
def get_file_dictionary(config_filename): | ||
"""GET FILE NAMES from Brawley file dictionary.""" | ||
this_dict = {}; | ||
print("Reading file %s " % config_filename); | ||
ifile = open(config_filename); | ||
for line in ifile: | ||
data_type = line.split(':')[0]; | ||
total_data_files = line.split()[1]; # assuming one file per list entry | ||
this_dict[data_type] = total_data_files; | ||
ifile.close(); | ||
return this_dict; |
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