SVG file with terrain. Rsvg does not align the terrain correctly, so do not use this SVG directly in Wikipedia at this point!
Code
Terrain shading layer was generated with the following Python script (requires Python Imaging Library and NumPy):
# Read SRTM3 file and create shaded relief# 2010-04-05fromstructimportunpack,calcsizefromnumpyimport*importnumpyasnpfromPILimportImagerow_length=1201# row_length is 1201 for SRTM3 or 3601 for SRTM1file_name="N40E014.hgt"# from http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/Eurasia/hlim=800# height limit for map [m]ref_lat=40.55# reference latitudeearth_eq=6371.*1000.*2.*pix_scale=1./360.*earth_eq*cos(ref_lat/180.*pi)/row_lengthy_scale=1./360.*earth_eq/row_lengthprint"1 pixel = %u * %u m"%(x_scale,y_scale)print"factor",y_scale/x_scaleh=zeros((row_length,row_length))f=open(file_name,'r')li=[]forjinrange(row_length):foriinrange(row_length):d=f.read(2)(height,)=unpack('>h',d)h[i,j]=heightifheight<-1000:li.append((i,j))hmax=h.max()h3=zeros_like(h)h3[:,:]=h[:,:]printlen(li),"missing data points"defget_nei(z):h2=h[z[0]-1:z[0]+2,z[1]-1:z[1]+2]nn=sum(where(h2<-1000,0,1))av=sum(where(h2>-1000,h2,0))/float(nn)returnnn,av# fill missing points with a nearest-neighbor averaging method:loop=len(li)lim=7whileloop>0:sd=Falseforqinrange(len(li)):ifh[li[q]]>-1000.:continuen,a=get_nei(li[q])ifn>=lim:printli[q],loop,n,a,limh3[li[q]]=aloop-=1sd=Trueifnotsd:lim-=1h[:,:]=h3[:,:]print"missing points done"defhext(a):"Hex color to triplet."r,g,b=a[0:2],a[2:4],a[4:6]returnint(r,16),int(g,16),int(b,16)# from http://en.wikipedia.org/key/Wikipedia:WikiProject_Maps/Conventions/Topographic_maps:col_sea=hext("0978ab")cols="""{{Mapcolor|r=245|v=244|b=242|hex=#F5F4F2|col=black}}{{Mapcolor|r=224|v=222|b=216|hex=#E0DED8|col=black}}{{Mapcolor|r=202|v=195|b=184|hex=#CAC3B8|col=black}}{{Mapcolor|r=186|v=174|b=154|hex=#BAAE9A|col=black}}{{Mapcolor|r=172|v=154|b=124|hex=#AC9A7C|col=black}}{{Mapcolor|r=170|v=135|b=83|hex=#AA8753|col=black}}{{Mapcolor|r=185|v=152|b=90|hex=#B9985A|col=black}}{{Mapcolor|r=195|v=167|b=107|hex=#C3A76B|col=black}}{{Mapcolor|r=202|v=185|b=130|hex=#CAB982|col=black}}{{Mapcolor|r=211|v=202|b=157|hex=#D3CA9D|col=black}}{{Mapcolor|r=222|v=214|b=163|hex=#DED6A3|col=black}}{{Mapcolor|r=232|v=225|b=182|hex=#E8E1B6|col=black}}{{Mapcolor|r=239|v=235|b=192|hex=#EFEBC0|col=black}}{{Mapcolor|r=225|v=228|b=181|hex=#E1E4B5|col=black}}{{Mapcolor|r=209|v=215|b=171|hex=#D1D7AB|col=black}}{{Mapcolor|r=189|v=204|b=150|hex=#BDCC96|col=black}}{{Mapcolor|r=168|v=198|b=143|hex=#A8C68F|col=black}}{{Mapcolor|r=148|v=191|b=139|hex=#94BF8B|col=black}}{{Mapcolor|r=172|v=208|b=165|hex=#ACD0A5|col=black}}"""col=[]forlincols.splitlines():iflen(l)<10:continuei=l.find('#')ifi>-1:col.append(hext(l[i+1:i+7]))col.reverse()# -> bottom to topo=Image.new('RGB',h.shape)definterp(c,f):"Interpolate into color table."r=int((1.-f)*col[c][0]+f*col[c+1][0])g=int((1.-f)*col[c][1]+f*col[c+1][1])b=int((1.-f)*col[c][2]+f*col[c+1][2])returnr,g,bforjinrange(row_length):foriinrange(row_length):c,f=divmod(h[j,i]/hmax*(len(col)-1),1)if0<h[j,i]<hmax:o.putpixel((j,i),interp(int(c),f))elifh[i,j]==hmax:o.putpixel((j,i),col[-1])else:o.putpixel((j,i),col_sea)o.save("map_height.png")# save height mapo2=o.crop((0,0,942,603))o2.save("map_height_cropped.png")# taken from hillshade.py:#def illumination(idata,azdeg=315.0,altdeg=45.):defillumination(idata,azdeg=225.0,altdeg=45.):# convert alt, az to radiansaz=azdeg*np.pi/180.0alt=altdeg*np.pi/180.0# gradient in x and y directionsdx,dy=np.gradient(idata)slope=0.5*np.pi-np.arctan(np.hypot(dx,dy))aspect=np.arctan2(dx,dy)odata=np.sin(alt)*np.sin(slope)+np.cos(alt)*np.cos(slope)*np.cos(-az-\
aspect-0.5*np.pi)# rescale to interval -1,1# 1 means maximum sun exposure and 0 means complete shade.odata=(odata-odata.min())/(odata.max()-odata.min())returnodatail=255*illumination(h)o4=Image.new('RGBA',il.shape)forjinrange(row_length-1):foriinrange(row_length-1):v=int(il[j,i])if0<=v<128:alpha=(255-2*v)o4.putpixel((j,i),(0,0,0,alpha))elifv==128:o4.putpixel((j,i),(0,0,0,0))elif128<v<256:alpha=2*(v-128)o4.putpixel((j,i),(255,255,255,alpha))else:o4.putpixel((j,i),(255,255,255,0))o4.save("il_NW_alpha.png")# NW-illuminated (alpha transparency for use with Inkscape)
Licensing
I, the copyright holder of this work, hereby publish it under the following licenses:
to share – to copy, distribute and transmit the work
to remix – to adapt the work
Under the following conditions:
attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled GNU Free Documentation License.http://www.gnu.org/copyleft/fdl.htmlGFDLGNU Free Documentation Licensetruetrue
You may select the license of your choice.
Captions
Add a one-line explanation of what this file represents