2016-10-24 3 views
2

ЦЕЛИBaseMap - Значения должны находиться в диапазоне от -90, 90 градусов

  • Загрузить ГИС, шейп (границы графства) в BaseMap
  • Использование BaseMap построить окружные границы
  • Определить, является ли или нет местоположение находится в пределах границ
  • Назначить вес точке, в зависимости от того, к какой границе они попадают в
  • Используйте DBSCAN для обнаружения кластерного центриода на основе координаты и вес

ПОДХОД

Использование this tutorial on Basemap, загрузить шейп для отображения.

#First, we have to import our datasets. 
#These datasets include store locations, existing distribution locations, county borders, and real estate by county 
walmartStores = pd.read_csv("data/walmart-stores.csv",header=0, encoding='latin1') 
propertyValues = pd.read_csv("data/property values.csv") 
shp = fiona.open('data/boundaries/Counties.shp') 


#We need to create a workable array with Walmart Stores 
longitude = walmartStores.longitude 
latitude = walmartStores.latitude 
stores = np.column_stack((longitude, latitude)) 

#We also need to load the shape file for county boundaries 
extra = 0.1 
bds = shp.bounds 
shp.close() 

#We need to assign the lower-left bound and upper-right bound 
ll = (bds[0], bds[1]) 
ur = (bds[2], bds[3]) 


#concatenate the lower left and upper right into a variable called coordinates 
coords = list(chain(ll, ur)) 
print(coords) 

#define variables for the width and the height of the map 
w, h = coords[2] - coords[0], coords[3] - coords[1] 

с print(coords) = [105571.4206781257, 4480951.235680977, 779932.0626624253, 4985476.422250552]

Все хорошо до сих пор, однако я столкнулся с проблемой ниже:

m = Basemap(
    #set projection to 'tmerc' to minimize map distortion 
    projection='tmerc', 

    #set longitude as average of lower, upper longitude bounds 
    lon_0 = np.average([bds[0],bds[2]]), 

    #set latitude as average of lower,upper latitude bounds 
    lat_0 = np.average([bds[1],bds[3]]), 

    #string describing ellipsoid (‘GRS80’ or ‘WGS84’, for example). 
    #Not sure what this does... 
    ellps = 'WGS84', 

    #set the map boundaries. Note that we use the extra variable to provide a 10% buffer around the map 
    llcrnrlon=coords[0] - extra * w, 
    llcrnrlat=coords[1] - extra + 0.01 * h, 
    urcrnrlon=coords[2] + extra * w, 
    urcrnrlat=coords[3] + extra + 0.01 * h, 

    #provide latitude of 'true scale.' 
    #check the Basemap API 
    lat_ts=0, 

    #resolution of boundary database to use. Can be c (crude), l (low), i (intermediate), h (high), f (full) or None. 
    resolution='i', 

    #don't show the axis ticks automatically 
    suppress_ticks = False) 


m.readshapefile(
    #provide the path to the shapefile, but leave off the .shp extension 
    'data/boundaries/Counties.shp', 

    #name your map something useful (I named this 'srilanka') 
    'nyCounties', 

    #set the default shape boundary coloring (default is black) and the zorder (layer order) 
    color='none', 
    zorder=2) 

Error: lat_0 must be between -90.000000 and 90.000000

ВОПРОСЫ

  1. lat_0 и lon_0 не находятся между -90 и 90. Однако lon_0 не выдает ошибку. Почему это так?
  2. Я смотрел онлайн для других, столкнувшихся с подобной проблемой, и пришел с пустыми руками. Есть что-то уникальное в моей записной книжке? (Примечание: conda list показывает `BaseMap 1.0.7, так что я знаю, что он установлен и запущен)

Спасибо!

ответ

0

Широта может быть только между -90 и 90 - ничего другого смысла не имеет. Северный полюс равен +90, а Южный полюс равен -90, а экватор равен 0. Других приемлемых значений нет!

Что касается долготы, то оно может быть только между -180 и 180. 0 находится на главном меридиане и идет до -180 (на запад) и +180 (восток)