Ejemplo n.º 1
0
 def objective_a(k):
     mp.k = k
     iv = mapproj.transeach(mp.invtransform, gridp)
     arealist = []
     for p in iv.geometry:
         area, _ = geod.geometry_area_perimeter(p)
         arealist.append(area)
     return max(arealist)/min(arealist)
Ejemplo n.º 2
0
 def objective_l(k):
     mp.k = k
     iv = mapproj.transeach(mp.invtransform, gridp)
     alist = []
     for p in iv.geometry:
         coords = np.array(p.exterior.xy)
         l = geod.line_lengths(coords[0], coords[1])
         aspect = max(l)/min(l)
         alist.append(aspect)            
     return max(alist)
Ejemplo n.º 3
0
    ctrlpolys[name] = cp
    nctrlpts[name] = i
    #pois      = poi.to_crs(crs)
    dp = mapproj.ptseriestoarray(degpts.to_crs(crs)).reshape(adegpts.shape)
    if i == 3:
        gscale = cp[5].xy[1][0] / tgtpts3[1, 2]
    elif i == 4:
        gscale = cp[7].xy[1][0] * 2
    #gscale3 = pois[name][0].xy[1]/tgtpts3[1, 0]
    #dp = degptss[name]
    degptss[name] = dp / gscale

    def transform_gscale(x, y):
        return x / gscale, y / gscale

    worlds[name] = mapproj.transeach(transform_gscale, worlds[name])
    grats[name] = mapproj.transeach(transform_gscale, grats[name])
    ctrlpolys[name] = mapproj.transeach(transform_gscale, ctrlpolys[name])
    #pois[name] = mapproj.transeach(transform_gscale, pois[name])

#not-barycentric projections implemented here
projs = {  #'Chamberlin Trimetric': mapproj.ChambTrimetric(actrlpts, geod),#not polygonal
    #'Linear Trimetric':     mapproj.LinearTrimetric(actrlpts, geod),#not polygonal
    #'Conformal2': mapproj.ConformalTri(actrlpts, tgtpts),#buggy
    'Conformal': mapproj.ConformalTri3(actrlpts3, tgtpts3),
    'Crider': mapproj.CriderEq(actrlpts4),
    'Snyder Equal-Area 4': mapproj.SnyderEA4(actrlpts4)
}

for name in projs:
    print(name)
Ejemplo n.º 4
0
geod = pyproj.Geod(a=6371, f=0)
world = geopandas.read_file(geopandas.datasets.get_path('naturalearth_lowres'))
a = np.arctan(1 / 2) / np.pi * 180
actrlpts3 = np.array([[15 + 0, 15 + 36, 15 - 36], [-a, a, a]])
ctrlpoly3 = mapproj.geodesics(actrlpts3[0],
                              actrlpts3[1],
                              geod,
                              includepts=True)
a = 180 / np.pi * np.arctan(1 / np.sqrt(2))
actrlpts4 = np.array([[0, 90, 90, 0], [-a, -a, a, a]])
ctrlpoly4 = mapproj.geodesics(actrlpts4[0],
                              actrlpts4[1],
                              geod,
                              includepts=True)

antipodepoly3 = mapproj.transeach(mapproj.transform_antipode, ctrlpoly3)
antipodepoly4 = mapproj.transeach(mapproj.transform_antipode, ctrlpoly4)

#cycle3 = [0,1,2,0]
#sidelengths3 = geod.line_lengths(actrlpts3[0][cycle], actrlpts3[1][cycle])
#print(sidelengths3)
#tgtpts3 = mapproj.trigivenlengths(sidelengths3)

adegpts = np.array(
    np.meshgrid(np.linspace(-180, 180, 361), np.linspace(-90, 90, 181)))
#%%
projs = {  #'Conformal': mapproj.ConformalTri3(actrlpts3, tgtpts3),
    #'Linear Trimetric':        mapproj.LinearTrimetric(actrlpts3, geod),
    #'Areal':                   mapproj.Areal(actrlpts3),
    #'Fuller explicit':         mapproj.FullerEq(actrlpts3),
    #'Fuller':                  mapproj.FullerTri(actrlpts3, tweak=False),
Ejemplo n.º 5
0
         'Naive Slerp Quad 2 1':  mapproj.NSlerpQuad2(actrlpts4, k=1),
         'Naive Slerp Quad 2~ 1': mapproj.NSlerpQuad2(actrlpts4, k=1, exact=False),
         'Elliptical 0':  mapproj.EllipticalQuad(actrlpts4, k=0),
         'Elliptical 1':  mapproj.EllipticalQuad(actrlpts4, k=1),
         'Elliptical~ 1': mapproj.EllipticalQuad(actrlpts4, k=1, exact=False),
         'Snyder Equal-Area 4':  mapproj.SnyderEA4(actrlpts4)
         })

for name in projs:
    print(name)
    mp = projs[name]
    i = mp.nctrlpts
    nctrlpts[name] = i
    #invbary[name] = mapproj.transeach(mp.invtransform, bary)
    if i == 3:
        invframe[name] = mapproj.transeach(mp.invtransform, gridp3)
        testshapet[name] = mapproj.transeach(mp.invtransform, testshape3)
    elif i == 4:
        invframe[name] = mapproj.transeach(mp.invtransform, gridp4)
        testshapet[name] = mapproj.transeach(mp.invtransform, testshape4)
#%%
testshapez3 = mapproj.transeach(bp.transform, testshape3)
gridpz3 = mapproj.transeach(bp.transform, gridp3)
projs2 = {'Conformal':        mapproj.ConformalTri3(actrlpts3, tgtpts3),#slow
         #'Linear Trimetric': mapproj.LinearTrimetric(actrlpts3, geod),#no
         }
         
for name in projs2:
    print(name)
    mp = projs2[name]
    i = mp.nctrlpts