mirror of
https://github.com/csharpee/Map-Projections.git
synced 2025-10-10 00:00:11 -04:00
It's supermap!
I updated the supermap with some new city data I came across that makes it look way less lopsided than it did before. And then I fiddled with it a ton.
This commit is contained in:
parent
c739d5d612
commit
3e819d9fdb
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 4.8 MiB After Width: | Height: | Size: 28 MiB |
BIN
src/data/cities_capital.sbn
Normal file
BIN
src/data/cities_capital.sbn
Normal file
Binary file not shown.
BIN
src/data/cities_capital.sbx
Normal file
BIN
src/data/cities_capital.sbx
Normal file
Binary file not shown.
2
src/data/cities_capital.shp.xml
Normal file
2
src/data/cities_capital.shp.xml
Normal file
@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<metadata xml:lang="es"><Esri><CreaDate>20180214</CreaDate><CreaTime>16531700</CreaTime><ArcGISFormat>1.0</ArcGISFormat><SyncOnce>TRUE</SyncOnce><DataProperties><lineage><Process ToolSource="c:\program files (x86)\arcgis\desktop10.4\ArcToolbox\Toolboxes\Data Management Tools.tbx\CalculateField" Date="20180213" Time="212721">CalculateField cities CAPITAL "Y" VB #</Process></lineage></DataProperties></Esri></metadata>
|
BIN
src/data/cities_other.sbn
Normal file
BIN
src/data/cities_other.sbn
Normal file
Binary file not shown.
BIN
src/data/cities_other.sbx
Normal file
BIN
src/data/cities_other.sbx
Normal file
Binary file not shown.
2
src/data/cities_other.shp.xml
Normal file
2
src/data/cities_other.shp.xml
Normal file
@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<metadata xml:lang="es"><Esri><CreaDate>20180214</CreaDate><CreaTime>16535800</CreaTime><ArcGISFormat>1.0</ArcGISFormat><SyncOnce>TRUE</SyncOnce><DataProperties><lineage><Process ToolSource="c:\program files (x86)\arcgis\desktop10.4\ArcToolbox\Toolboxes\Data Management Tools.tbx\CalculateField" Date="20180213" Time="212721">CalculateField cities CAPITAL "Y" VB #</Process></lineage></DataProperties></Esri></metadata>
|
@ -104,36 +104,40 @@ def compose_orthodromes():
|
||||
def compose_everything():
|
||||
print('\t<g transform="matrix(1,0,0,-1,180,90)">')
|
||||
print('\t\t<g class="country">')
|
||||
generate_borders('ne_50m', trim_antarctica=True, borders_only=False)
|
||||
generate_borders('ne_10m', trim_antarctica=True, borders_only=False)
|
||||
print('\t\t<g class="border">')
|
||||
generate_borders('ne_10m', trim_antarctica=True, borders_only=True)
|
||||
print('\t\t</g>')
|
||||
print('\t\t</g>')
|
||||
print('\t\t<g class="sovereign">')
|
||||
plot_shapes('ne_50m_admin_0_map_units')
|
||||
plot_shapes('ne_10m_admin_0_map_units')
|
||||
print('\t\t</g>')
|
||||
print('\t\t<g class="admin">')
|
||||
plot_shapes('ne_50m_admin_1_states_provinces_lines')
|
||||
print('\t\t</g>')
|
||||
print('\t\t<g class="border">')
|
||||
generate_borders('ne_50m', trim_antarctica=True, borders_only=True)
|
||||
plot_shapes('ne_10m_admin_1_states_provinces_lines', filter_field='adm0_a3',
|
||||
filter_vals=['RUS','CAN','CHN','USA','BRA','AUS','IND','ARG','KAZ'])
|
||||
print('\t\t</g>')
|
||||
print('\t\t<g class="dispute">')
|
||||
plot_shapes('ne_50m_admin_0_boundary_lines_disputed_areas')
|
||||
plot_shapes('ne_10m_admin_0_boundary_lines_disputed_areas')
|
||||
print('\t\t</g>')
|
||||
print('\t\t<g class="coastline">')
|
||||
plot_shapes('ne_50m_coastline', trim_antarctica=True)
|
||||
plot_shapes('ne_10m_coastline', trim_antarctica=True)
|
||||
print('\t\t</g>')
|
||||
print('\t\t<g class="river">')
|
||||
plot_shapes('ne_50m_rivers_lake_centerlines')
|
||||
plot_shapes('ne_10m_rivers_lake_centerlines', max_rank=5)
|
||||
print('\t\t</g>')
|
||||
print('\t\t<g class="lakes">')
|
||||
plot_shapes('ne_50m_lakes')
|
||||
print('\t\t<g class="lake">')
|
||||
plot_shapes('ne_10m_lakes', max_rank=4)
|
||||
print('\t\t</g>')
|
||||
print('\t\t<g class="graticule">')
|
||||
generate_graticule(5, 1, include_tropics=True, adjust_poles=True)
|
||||
plot_shapes('ne_10m_geographic_lines', clazz="dateline", filter_field='name', filter_vals=["International Date Line"])
|
||||
print('\t\t</g>')
|
||||
print('\t</g>')
|
||||
generate_topographical_labels('ne_50m', max_rank=2, text_size=4)
|
||||
label_shapes('ne_50m_admin_0_countries', "pol", max_rank=4, text_size=2)
|
||||
label_points('ne_50m_populated_places', "urb", max_rank=1, text_size=1)
|
||||
label_shapes('ne_10m_lakes', "sea", max_rank=1, text_size=1)
|
||||
label_shapes('ne_10m_admin_0_countries', "pol", text_size=4)
|
||||
label_points('cities_capital', "cap", text_size=1)
|
||||
label_points('cities_other', "cit", text_size=0)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -9,7 +9,7 @@ from helpers import line_break, get_centroid
|
||||
def plot_texts(filename, label_class, max_rank, text_size, regulate_case=False, secondary_attr=None, force_points=False):
|
||||
"""data from http://www.naturalearthdata.com/"""
|
||||
sf = shapefile.Reader("../data/{}".format(filename))
|
||||
lat_idx = None
|
||||
rank_idx, type_idx, secd_idx, lat_idx, lon_idx = None, None, None, None, None
|
||||
for i, field in enumerate(sf.fields):
|
||||
if field[0] in ['scalerank', 'LABELRANK']:
|
||||
rank_idx = i-1
|
||||
@ -24,7 +24,7 @@ def plot_texts(filename, label_class, max_rank, text_size, regulate_case=False,
|
||||
if field[0] == 'long_x':
|
||||
lon_idx = i-1
|
||||
for record, shape in zip(sf.records(), sf.shapes()):
|
||||
rank = record[rank_idx]
|
||||
rank = record[rank_idx] if rank_idx is not None else 0
|
||||
if rank <= max_rank:
|
||||
if lat_idx is not None:
|
||||
x, y = record[lon_idx], record[lat_idx]
|
||||
@ -38,12 +38,12 @@ def plot_texts(filename, label_class, max_rank, text_size, regulate_case=False,
|
||||
if regulate_case:
|
||||
label = label.upper()
|
||||
if secondary_attr is not None and record[7] == 'Dependency':
|
||||
label = "{} ({})".format(label, record[secd_idx]) #indicate dependencies
|
||||
label = "{} ({})".format(label, record[secd_idx]) if secd_idx is not None else label #indicate dependencies
|
||||
label_size = ['xs', 'sm', 'md', 'lg', 'xl'][max(0, int(text_size-rank))] #lower ranks get bigger text
|
||||
print('\t<text class="label-{} label-{}" x="{:.03f}" y="{:.03f}">{}</text>'.format(
|
||||
label_class, label_size, 180+x, 90-y, label))
|
||||
if force_points or record[type_idx] in ['mountain', 'depression', 'pole', 'waterfall']: #add circles to the ones that need markers
|
||||
print('\t<circle cx="{:.03f}" cy="{:.03f}" r="{:.03f}" />'.format(180+x, 90-y, math.sqrt(max_rank-rank+1)*0.15))
|
||||
label_class, label_size, 180+x, 90-y, label.replace('&', '&')))
|
||||
if force_points or (type_idx is not None and record[type_idx] in ['mountain', 'depression', 'pole', 'waterfall']): #add circles to the ones that need markers
|
||||
print('\t<circle cx="{:.03f}" cy="{:.03f}" r="{:.03f}" />'.format(180+x, 90-y, math.sqrt(text_size-rank+1)*0.15))
|
||||
|
||||
def label_shapes(filename, label_class, max_rank=float('inf'), text_size=3):
|
||||
plot_texts(filename, label_class, max_rank, text_size, secondary_attr='NOTE_ADM0')
|
||||
|
@ -5,14 +5,19 @@ import shapefile
|
||||
from helpers import plot, trim_edges, lengthen_edges
|
||||
|
||||
|
||||
def plot_shapes(filename, max_rank=float('inf'), trim_antarctica=False, flesh_out_antarctica=False):
|
||||
def plot_shapes(filename, max_rank=float('inf'), clazz=None, trim_antarctica=False, flesh_out_antarctica=False, filter_field=None, filter_vals=['']):
|
||||
"""data from http://www.naturalearthdata.com/"""
|
||||
sf = shapefile.Reader("../data/{}".format(filename))
|
||||
rank_idx, filter_idx = None, None
|
||||
for i, field in enumerate(sf.fields):
|
||||
if 'rank' in field[0]:
|
||||
rank_idx = i-1
|
||||
if field[0] == filter_field:
|
||||
filter_idx = i-1
|
||||
for record, shape in zip(sf.records(), sf.shapes()):
|
||||
if record[rank_idx] <= max_rank:
|
||||
if filter_idx is not None and record[filter_idx] not in filter_vals:
|
||||
continue # skip it if it is filtered out
|
||||
if rank_idx is None or record[rank_idx] <= max_rank:
|
||||
if trim_antarctica:
|
||||
if shape.points[0][1] < -60: #if it is Antarctica (this will have a few false positives, but that's fine)
|
||||
shape.points = trim_edges(shape.points, shape.parts)
|
||||
@ -20,4 +25,4 @@ def plot_shapes(filename, max_rank=float('inf'), trim_antarctica=False, flesh_ou
|
||||
if shape.points[0][1] < -60:
|
||||
shape.points = lengthen_edges(shape.points)
|
||||
|
||||
plot(shape.points, midx=shape.parts, close=False, fourmat='xd')
|
||||
plot(shape.points, midx=shape.parts, close=False, clazz=clazz, fourmat='xd')
|
||||
|
Loading…
x
Reference in New Issue
Block a user